Skip to content

fix(ai): support Sonnet 5.5 Messages request shapes - #52045

Closed
opencode-agent[bot] wants to merge 1 commit into
devfrom
sonnet55-request-shape
Closed

opencode-agent[bot] wants to merge 1 commit into
devfrom
sonnet55-request-shape

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Why

Anthropic's September 28 Sonnet 5.5 launch introduced thinking: { type: "between_tools" }, but @opencode/ai rejected that valid input. Its existing default thinking-binding policy would also append block_binding to this shape, which Sonnet 5.5 rejects. The model additionally rejects forced tool choice, legacy thinking controls, and non-default sampling. These are Sonnet 5.5 native Messages request constraints, distinct from the closed, unmerged Opus 5.5 PR #51302.

Change

  • Encode explicit between_tools unchanged without a binding field or binding beta header; retain adaptive thinking's existing binding default.
  • Reject incompatible between_tools fields, effort levels, and per-message effort changes, rather than stripping requested controls.
  • Give Sonnet 5.5 callers a typed InvalidRequest for forced tool selection, disabled/manual thinking, and disallowed sampling, instead of silently changing intent. Preserve accepted auto/none, temperature 1, and top-p >= 0.99.
  • Scope the compatibility checks to Sonnet 5.5 on the native Anthropic Messages protocol, including gateway-qualified IDs. Older models keep their request behavior.

Verification

  • Regression tests failed before the implementation and now pass: bun test test/provider/anthropic-messages.test.ts test/provider/anthropic-thinking-binding.test.ts test/effort-updates.test.ts --only-failures — 129 passed.
  • bun typecheck from packages/ai, bun run lint, Prettier check, and git diff --check passed.
  • Root bun run check is blocked by this host's Node 18: @opencode/posts requires Node >=22.12 for Astro; the affected AI package typecheck passed independently.

Sources: Sonnet 5.5 migration guide, Sonnet 5.5 API changes, and Messages API sampling parameter compatibility.

Requested by: @nexxeln (nexxel via Slack)

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:22
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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