fix(opencode): honor OPENCODE_TOOL_CHOICE on live SessionPrompt path - #15
Conversation
m19 only forced tool_choice on the V2 SessionRunner. caseforge investigate uses `verdict run` → SessionPrompt, which ignored the flag. Shared resolveAgentToolChoice now drives both paths (required on non-final steps, none on max-steps exit). Unknown/invalid tool errors list available names so weak models can self-correct instead of looping until timeout.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e516d7ce2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| readonly isLastStep: boolean | ||
| readonly structuredRequired?: boolean | ||
| }): "auto" | "required" | "none" | undefined { | ||
| if (input.isLastStep) return "none" |
There was a problem hiding this comment.
Preserve required tool choice for structured output
When a JSON-schema response runs on an agent's final allowed step (for example steps: 1, or after tool continuations consume the step budget), this returns none before checking structuredRequired. The live SessionPrompt path still adds the StructuredOutput tool and later treats a normal text finish as StructuredOutputError, so these requests can no longer succeed even though they previously forced toolChoice: "required" for all json_schema turns.
Useful? React with 👍 / 👎.
Summary
m19 (#14) forced
tool_choice: requiredonly on the V2 SessionRunner. Liveverdict run(what caseforgeinvestigatespawns) still goes through SessionPrompt, which ignoredOPENCODE_TOOL_CHOICE/VERDICT_FORCE_TOOL_CHOICEand only setrequiredforjson_schematurns.This residual still showed up as intermittent invalid tool-name loops / timeouts on m20 even when caseforge exported the force flags.
Changes
resolveAgentToolChoice()used by both V2 runner and SessionPromptrequirednone(early stop)requiredtoolChoice: requiredNot claimed
Test plan
packages/coretypecheckpackages/opencodetypecheckbun test test/tool-choice-flag.test.ts test/tool-choice-resolve.test.ts test/session-runner-tool-registry.test.tsbun test test/session-runner.test.ts -t "forces tool_choice required|durably settles local tool failures|forces a text response"bun test test/application-tools.test.ts