anomalyco / anomalyco/opencode

core: SessionRunner sends forced tool_choice ("required"/"none"/named); providers that only support "auto" fail the whole session

Open
#45,953 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 28, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

OpenCode's server-side SessionRunner sends tool_choice values other than "auto" ("none", "required", or named-function choices) on some steps. Providers backed by models/gateways that only implement tool_choice: "auto" (in my case a provider labeled "Console Go") reject these requests with [invalid_request_error], which kills the entire session with "Failed to drain Session" — the subagent/step never completes. OpenCode should either degrade gracefully (retry with "auto"), make forced tool_choice configurable per provider/agent, or at minimum fail a single step instead of the session.

Environment

  • opencode version: 0.0.0-beta-18314 (beta channel; from runtime diagnostics snapshot — --version unavailable in this session)
  • OS: Linux 6.8.0-138-generic (x64)
  • Terminal: Unavailable (no terminal env vars set in this context)
  • Shell: /bin/bash
  • Install/channel: beta
  • Active plugins: none configured (only local/remote MCP servers: github, supabase, vercel, cloudflare)

Reproduction

  1. Configure a custom OpenAI-compatible provider whose backend only supports tool_choice: "auto" (observed with a provider labeled "Console Go").
  2. Run an agent/subagent turn that causes OpenCode to force a tool choice (observed on subagent runs and structured steps).
  3. The provider rejects the request and the session errors out.

Reproduces consistently: the same error appeared across multiple sessions on 2026-08-26 and 2026-08-27 (8+ occurrences in the server log).

Expected Behavior

The session/step should complete. If a provider doesn't support the requested tool_choice mode, OpenCode should fall back to "auto" (possibly with a warning), or the behavior should be configurable per provider/agent rather than hard-forced.

Actual Behavior

Session fails with:

Failed to drain Session
cause="AI.Error: RequestExecutor.execute: Error from provider (Console Go):
Upstream request failed: [invalid_request_error] only `"auto"` is supported for
`tool_choice`. `"none"`, `"required"`, and named function choices are not currently
supported"
at SessionRunner.callModel → SessionRunner.runSteps → SessionRunner.drain

Additional Context

  • The request emitter is OpenCode's server session runner; the rejection comes from the upstream model API behind the provider. Sending non-auto tool_choice is valid OpenAI-style behavior, so this is a provider-compat gap — but the current failure mode (whole session dies) is harsh.
  • Possibly related: #15226 (tool_choice: "required" incompatible with thinking-enabled models during structured output — closed as not planned) and #37672 (toolChoice plumbing unwired at v2 HEAD).
  • No workaround found on the OpenCode side; the practical workaround is to point agents at a provider/model that supports the full tool_choice surface.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.