Skip to content

feat(opencode): let tools opt into strict mode - #40216

Closed
mayshwartz2 wants to merge 2 commits into
anomalyco:devfrom
mayshwartz2:tool-strict-mode
Closed

feat(opencode): let tools opt into strict mode#40216
mayshwartz2 wants to merge 2 commits into
anomalyco:devfrom
mayshwartz2:tool-strict-mode

Conversation

@mayshwartz2

@mayshwartz2 mayshwartz2 commented Aug 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40214

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Lets a tool ask for strict mode, instead of it being decided only by which provider you're on.

strict?: boolean is added to the tool definition and to the tool.definition plugin hook, and passed to the AI SDK Tool only when explicitly set. The strict: false injection from #33392 for @ai-sdk/openai, @ai-sdk/azure and @ai-sdk/amazon-bedrock/mantle is untouched and still wins, so nothing changes unless a tool opts in.

It reaches the model because strict?: boolean is a documented field on the AI SDK Tool type, @ai-sdk/amazon-bedrock@4.0.112 forwards it into toolSpec, and Bedrock's Converse API enforces it.

Five lines of production code, the rest is tests. AI SDK path only — the TODO at packages/llm/src/protocols/openai-responses.ts:264 is a separate change.

How did you verify your code works?

  • Root bun run typecheck: 30/30 tasks pass.
  • bun test test/tool/ test/provider/: 872 pass. bun test test/session/ test/plugin/: 536 pass.
  • New tests: a custom .opencode/tool declaring strict: true reaches the registry with it set and doesn't leak onto other tools, and it survives LLMRequestPrep.prepare on @ai-sdk/amazon-bedrock while still being forced to false on mantle.
  • Checked against Bedrock directly (us.anthropic.claude-sonnet-4-6) that the flag does something: optional properties are fine, additionalProperties must be explicitly false, and minimum/maximum/maxItems are rejected.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Tools can now declare strict: true, and the tool.definition plugin hook can
set or override it. The flag is passed through to the AI SDK Tool, which
providers that support structured outputs forward to the model.

The existing hardcoded strict: false for @ai-sdk/openai, @ai-sdk/azure and
@ai-sdk/amazon-bedrock/mantle is unchanged.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

What needs to be fixed:

  • Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.

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.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 4, 2026
@github-actions github-actions Bot closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Let tools opt into strict mode

1 participant