Skip to content

fix(schema): accept compatibility.requireSignature in model and provider config - #68062

Merged
rekram1-node merged 2 commits into
devfrom
opencodejr/issue-fix-68060
Dec 3, 2026
Merged

rekram1-node merged 2 commits into
devfrom
opencodejr/issue-fix-68060

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #68060

Type of change

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

What does this PR do?

See #68060.

Anthropic-compatible endpoints that serve open-weight models (GLM, DeepSeek) stream thinking blocks with an empty signature. requireThinkingSignature in packages/ai/src/protocols/anthropic-messages.ts returns true for any provider outside its built-in list, so those blocks are dropped from later requests and the model loses its earlier reasoning every turn. The AI library already has a requireSignature compatibility override, but the config Compatibility schema (packages/schema/src/model-compatibility.ts) did not include it, so config normalization dropped the field and users had no way to keep unsigned thinking.

This adds requireSignature to the model compatibility schema, which the provider schema inherits. The model resolver already passes non-capability compatibility keys through to the AI model, so compatibility.requireSignature: false now sends unsigned thinking back with signature: "". The default is unchanged.

Also in this PR: the field is documented in the Compatibility table of models.mdx; the generated artifacts are regenerated (client types, openapi.json, and the cli-rs api-types/src/types.rs and plugin/src/script/opencode-plugin.d.ts); and the existing schema and model-resolver tests now cover the field.

How did you verify your code works?

Reproduction: a mock Anthropic Messages SSE server streams a thinking block with an empty signature, then a text block. A custom provider uses @opencode/ai/providers/anthropic-compatible with a custom baseURL and model glm-4.6. Commands: opencode run "say hi", then opencode run --continue "again".

  • Before (2.4.4 and dev@ca18a9d1): the continue request's assistant message was only [{"type":"text","text":"hi"}].
  • After, from source with "compatibility": { "requireSignature": false }: it is [{"type":"thinking","thinking":"PRIOR-REASONING: user wants a greeting.","signature":""},{"type":"text","text":"hi"}]. A non-empty signature is still sent back as before.

Tests:

  • packages/schema: bun test test/model.test.ts passed (9 tests).
  • packages/core: bun test test/model-resolver.test.ts test/config/provider.test.ts passed (96 tests).

Type checks: bun run typecheck:tsc was clean in packages/schema and packages/core. The typecheck scripts use bun check, which the installed Bun lacks, so they did not run.

Generated files:

  • packages/protocol: check:generated passed.
  • packages/cli-rs: ran bun run generate with rustfmt 1.99.1. The requireSignature hunks in crates/api-types/src/types.rs and crates/plugin/src/script/opencode-plugin.d.ts match the generator output exactly, and cargo check -p opencode-api-types passed.
  • bun run check:drift still lists 10 files. Their drift comes from changes already on dev before this PR: session.tool.durable events, the automation.run endpoint, the compat.js/events.gen.ts bundle, and parity/fixtures/F.7/folds.json. None of it involves requireSignature, so I left it out of this PR.

Screenshots / recordings

The reproduction on #68060 has the recording and script, where there is one.

Checklist

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

Opened by the bot from its reproduction of #68060 (simulated), fixed in a sandbox and reviewed in a separate session. A maintainer should review it before merging.


Added by the opencode bot (AI-generated).

Public API: adds optional compatibility.requireSignature to model and provider config (backwards compatible)

@neriousy

neriousy commented Dec 3, 2026

Copy link
Copy Markdown
Member

Hey @opencodejr[bot] can you double check with the official documentation and tell me whether that lines up?

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reproduced the problem on the base and it's fixed with this change. I ran the #68060 mock-server script from source in both checkouts. On the base, unsigned thinking is dropped from the follow-up request, and setting compatibility.requireSignature: false makes no difference because the key is thrown away. With this PR, the same setting on the model or on the provider sends the block back with signature: "". With the setting unset, behaviour is unchanged. Non-empty signatures are still sent back as before. The schema and model-resolver tests pass, and tsc is clean in packages/schema and packages/core.

Public API: adds one optional boolean, requireSignature, to Model.Compatibility and Provider.Compatibility. That covers the config schema, the OpenAPI spec, the generated client types, the cli-rs API types and the plugin .d.ts. It's backwards compatible: nothing is removed or changed, and leaving it unset keeps the current behaviour.

The change is sound and I have no concerns.

@opencodejr

opencodejr Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

The models docs now list every provider and model ID that requireSignature defaults to false for, matching the code: the Alibaba, Z.AI Coding Plan, Moonshot and MiniMax provider packages, Vercel AI Gateway models outside anthropic/, Kimi and Xiaomi MiMo, and qwen/minimax- model IDs. They also say that empty thinking is dropped whatever the setting. The code is unchanged.

I checked the new requireSignature row in models.mdx against the code, and it didn't fully match, so I updated it.

  • Defaults: the row named only Kimi, Moonshot, Xiaomi MiMo, Qwen and MiniMax. The code also defaults to false in the Alibaba and Z.AI Coding Plan provider packages (alibaba.ts, zai-coding-plan.ts) and for Vercel AI Gateway models outside anthropic/ (vercel-ai-gateway.ts). Moonshot and MiniMax also set it in their own provider packages, on top of the ID and base-URL detection in requireThinkingSignature.
  • Empty thinking: whitespace-only thinking is never sent back, even with false. The row now says so.

The rest of the row matches the code: unset is true everywhere else, and false sends unsigned thinking back with signature: "". This is also how the PR's reproduction behaved.

I did not find anything in Anthropic's extended-thinking page about how unsigned thinking blocks are handled, so I'm not claiming anything about their rules. The code is unchanged; this revision only touches the docs.

Pushed in 58baf99 on opencodejr/issue-fix-68060.

@neriousy

neriousy commented Dec 3, 2026

Copy link
Copy Markdown
Member

@opencodejr[bot] can you cite me sources where on how is the field accepted on those providers?

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The new commit only changes the docs row for requireSignature, and it now matches the code: the unset defaults match requireThinkingSignature and the provider packages that set the flag themselves. My earlier review had no open points. No code changed since the version I verified, and the public API impact is unchanged: an optional requireSignature in model and provider compatibility config, backwards compatible.

@opencodejr

opencodejr Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

This PR doesn't change any defaults. It only lets compatibility.requireSignature be set in config. The defaults in the docs row were already in packages/ai. What I found per provider:

  • Moonshot / Kimi: detected in requireThinkingSignature (anthropic-messages.ts), added in fix(ai): require thinking signature with provider-aware fallback #44713 ("some Anthropic-compatible APIs accept unsigned thinking only when it is sent with an empty signature"). The recording moonshot-messages/kimi-k3-preserves-reasoning-through-a-tool-loop-and-follow-up.json sends thinking back with "signature":"" to api.moonshot.ai/anthropic/v1/messages and gets HTTP 200. Kimi's Messages API page lists only type and thinking as required on thinking blocks, but that schema covers responses, not requests.
  • Alibaba / Qwen: alibaba.ts. The recording alibaba-messages/qwen-3-8-max-replays-reasoning-through-a-tool-loop-and-follow-up.json sends "signature":"" back to dashscope-intl.aliyuncs.com/apps/anthropic and gets HTTP 200. I found no Alibaba doc about it.
  • MiniMax: minimax.ts (fix(ai): stop demoting unsigned and interrupted reasoning to text #60498). MiniMax's docs only say to return the signature "unchanged in later turns", and the MiniMax recordings carry non-empty signatures. I found no source for empty ones.
  • Vercel AI Gateway: only the code comment in vercel-ai-gateway.ts (feat(ai): add native Vercel AI Gateway language models #52643). I found no recorded Messages request that sends an empty signature back.
  • Z.AI Coding Plan, Xiaomi MiMo: I found no doc or recording.

So the evidence is the two recordings plus maintainer PRs, not official provider docs. If you'd rather the docs row not list providers without a source, I can trim it to describe the override only.

@rekram1-node
rekram1-node merged commit 061e8a8 into dev Dec 3, 2026
11 of 12 checks passed
@rekram1-node
rekram1-node deleted the opencodejr/issue-fix-68060 branch December 3, 2026 20:24
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.

V2 drops unsigned thinking blocks for Anthropic-compatible providers, with no config to keep them

2 participants