Skip to content

feat: OPENCODE_TOOL_CHOICE=required for agent tool binding - #14

Merged
TimothyVang merged 1 commit into
mainfrom
agent/m19-tool-choice-required
Jul 9, 2026
Merged

feat: OPENCODE_TOOL_CHOICE=required for agent tool binding#14
TimothyVang merged 1 commit into
mainfrom
agent/m19-tool-choice-required

Conversation

@TimothyVang

Copy link
Copy Markdown
Owner

Summary

  • OPENCODE_TOOL_CHOICE=required / VERDICT_FORCE_TOOL_CHOICE=1 forces OpenAI-compatible tool_choice: required on non-final agent steps.
  • Enables agent-path seal with tool-capable local models (verified: gpt-oss:20b → used_fallback=0).

Evidence (operator host)

PASS: sealed with ed25519 (agent path; used_fallback=0)
signature_kind=ed25519 overall=true used_fallback=0
model=gpt-oss:20b OPENCODE_TOOL_CHOICE=required

Test plan

  • bun test packages/core/test/tool-choice-flag.test.ts
  • rebuild binary + live spark seal smoke

Local models often answer with prose/JSON instead of MCP tool invocations.
When OPENCODE_TOOL_CHOICE=required (or VERDICT_FORCE_TOOL_CHOICE=1), non-final
session runner steps send tool_choice: required. Final max-steps exit still uses none.
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@TimothyVang
TimothyVang merged commit 0aff752 into main Jul 9, 2026
7 of 8 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9380c82dda

ℹ️ 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".

Comment on lines +213 to +214
: Flag.OPENCODE_TOOL_CHOICE === "required"
? "required"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve a final turn when forcing tool choice

When OPENCODE_TOOL_CHOICE=required or VERDICT_FORCE_TOOL_CHOICE=1 is set for an agent without a configured steps limit (the built-in build agent leaves steps unset), isLastStep never becomes true, so every provider turn is sent with toolChoice: "required". Any local tool call then sets needsContinuation and the runner starts another turn that again cannot produce a final text answer, causing default sessions to keep issuing tools until an error/context limit instead of settling. Only force required when there is a finite final step or otherwise disable it after tool settlement.

Useful? React with 👍 / 👎.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant