Repository navigation
fix(schema): accept compatibility.requireSignature in model and provider config - #68062
Conversation
|
Hey @opencodejr[bot] can you double check with the official documentation and tell me whether that lines up? |
There was a problem hiding this comment.
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.
|
The models docs now list every provider and model ID that I checked the new
The rest of the row matches the code: unset is 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[bot] can you cite me sources where on how is the field accepted on those providers? |
There was a problem hiding this comment.
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.
|
This PR doesn't change any defaults. It only lets
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. |
Issue for this PR
Closes #68060
Type of change
What does this PR do?
See #68060.
Anthropic-compatible endpoints that serve open-weight models (GLM, DeepSeek) stream thinking blocks with an empty signature.
requireThinkingSignatureinpackages/ai/src/protocols/anthropic-messages.tsreturns 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 arequireSignaturecompatibility override, but the configCompatibilityschema (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
requireSignatureto the model compatibility schema, which the provider schema inherits. The model resolver already passes non-capability compatibility keys through to the AI model, socompatibility.requireSignature: falsenow sends unsigned thinking back withsignature: "". 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-rsapi-types/src/types.rsandplugin/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-compatiblewith a custom baseURL and modelglm-4.6. Commands:opencode run "say hi", thenopencode run --continue "again".[{"type":"text","text":"hi"}]."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.tspassed (9 tests).packages/core:bun test test/model-resolver.test.ts test/config/provider.test.tspassed (96 tests).Type checks:
bun run typecheck:tscwas clean inpackages/schemaandpackages/core. Thetypecheckscripts usebun check, which the installed Bun lacks, so they did not run.Generated files:
packages/protocol:check:generatedpassed.packages/cli-rs: ranbun run generatewith rustfmt 1.99.1. TherequireSignaturehunks incrates/api-types/src/types.rsandcrates/plugin/src/script/opencode-plugin.d.tsmatch the generator output exactly, andcargo check -p opencode-api-typespassed.bun run check:driftstill lists 10 files. Their drift comes from changes already on dev before this PR:session.tool.durableevents, theautomation.runendpoint, thecompat.js/events.gen.tsbundle, andparity/fixtures/F.7/folds.json. None of it involvesrequireSignature, so I left it out of this PR.Screenshots / recordings
The reproduction on #68060 has the recording and script, where there is one.
Checklist
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.requireSignatureto model and provider config (backwards compatible)