anomalyco / anomalyco/opencode
core: SessionRunner sends forced tool_choice ("required"/"none"/named); providers that only support "auto" fail the whole session
@jlongster is already working on this.
Since Aug 28, 2026.
- 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 —
--versionunavailable 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
- Configure a custom OpenAI-compatible provider whose backend only supports
tool_choice: "auto"(observed with a provider labeled "Console Go"). - Run an agent/subagent turn that causes OpenCode to force a tool choice (observed on subagent runs and structured steps).
- 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-
autotool_choiceis 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 (toolChoiceplumbing 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_choicesurface.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.