Skip to content

server: session fails at steps limit because Zen gateway rejects tool_choice none #51906

Closed

Description

@Sirawit-Thong

Summary

A session whose agent hits its steps limit fails to drain on free-tier (opencode provider / Zen gateway) models with only "auto" is supported for 'tool_choice'. The documented final-step behavior (remove tools, ask model to summarize) cannot complete because the gateway rejects the tool_choice: "none" request.

Environment

  • opencode version: 2.0.18
  • OS: Windows_NT 10.0.26200 (win32 x64)
  • Terminal: Unavailable: terminal environment variables are not set
  • Shell: PowerShell (COMSPEC: C:\WINDOWS\system32\cmd.exe)
  • Install/channel: latest (npm @opencode/cli)
  • Active plugins: none found in config

Reproduction

  1. Define a custom agent with a steps cap (e.g. steps: 10).
  2. Select a free-tier model (e.g. opencode/muse-spark-1.3-contributor-free#xhigh).
  3. Run a task that needs more model steps than the cap (e.g. DB migration, test pass, code review via the subagent tool).
  4. When the step count reaches the cap, the drain fails.

Expected Behavior

Reaching the steps limit should produce a text summary as documented ("On the final step, OpenCode removes tools and asks the model to summarize in text") instead of a provider error.

Actual Behavior

Failed to drain Session, cause AI.Error: Error from provider (Console): only '"auto"' is supported for 'tool_choice'. '"none"', '"required"', and named function choices are not currently supported.

Additional Context

  • Observed 3 times, deterministically: assistant message counts matched caps exactly (30/30 backend, 25/25 qa, 10/10 reviewer), all on providerID: opencode free-tier models.
  • Server log shows the failure in SessionStep.attempt / SessionRunner.drain.
  • Workaround: raise steps caps so real tasks finish before the cap (backend 30->100, qa 25->80, reviewer 10->40, etc.). Removing caps entirely was avoided to prevent runaway sessions.
  • Possibly related: free-tier sessions whose agent denies the shell tool fail with a different provider error (free tier can only be used from within OpenCode), suggesting the gateway validates request shape beyond auth.

Activity

  1. github-actions commented on Sep 28, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The Bug Report template requires a Description field. The issue currently has a Summary section instead; please add or rename it to Description and keep the problem description there.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions