← Back to PRs

#16100: fix: convert unsigned thinking blocks to text to prevent signature error

by claw-sylphx open 2026-02-14 08:31 View on GitHub →
stale size: M
## Summary Fixes #15681 When using Claude thinking models via the `google-antigravity` provider, accumulated thinking blocks in session history cause API failures with `thinking.signature: Field required`. This happens because: 1. **`transform-messages.ts`**: When `isSameModel` is true, thinking blocks without `thinkingSignature` are kept as `type: "thinking"` instead of being converted to plain text. 2. **`google-shared.ts` `convertMessages()`**: Sends `thought: true` without `thoughtSignature` to the Google Cloud Code Assist API. The Antigravity proxy does not map the missing `thoughtSignature` to Anthropic's required `signature` field, causing rejection. ## Changes Patches `@mariozechner/pi-ai@0.52.10` (via `pnpm patch`): ### `transform-messages.js` - Remove the fallback that keeps unsigned thinking blocks as `type: "thinking"` when `isSameModel` is true - Unsigned thinking blocks are now always converted to `type: "text"`, regardless of model match - Signed thinking blocks (with `thinkingSignature`) are still preserved for replay ### `google-shared.js` `convertMessages()` - When `isSameProviderAndModel` is true but `resolveThoughtSignature()` returns no valid signature, convert the thinking block to plain text instead of sending `thought: true` without `thoughtSignature` - This prevents the Antigravity proxy from forwarding unsigned thinking blocks to Anthropic ### Tests - `transform-messages.unsigned-thinking.test.ts` — 4 tests covering unsigned/signed/empty thinking block handling - `google-shared.unsigned-thinking-blocks.test.ts` — 6 tests covering `convertMessages` behavior for unsigned, signed, invalid-signature, empty, multi-turn, and cross-provider scenarios All 10 new tests pass. All 31 existing provider tests still pass. <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR fixes API failures when using Claude thinking models via the `google-antigravity` provider (#15681). The root cause was that unsigned thinking blocks (without `thinkingSignature`) were being sent to the Anthropic API via the Antigravity proxy, which requires the `signature` field on all thinking blocks. The fix is applied as a `pnpm patch` to `@mariozechner/pi-ai@0.52.10`, modifying two files: - **`transform-messages.js`**: Removes the `if (isSameModel) return block;` fallback that preserved unsigned thinking blocks as `type: "thinking"`. Signed blocks (with `thinkingSignature`) are still preserved via the earlier guard at line 32. Unsigned blocks now always convert to `type: "text"`. - **`google-shared.js`**: Adds an explicit check — when `resolveThoughtSignature()` returns no valid signature, the thinking block is converted to plain text instead of being sent with `thought: true` but without `thoughtSignature`. - 10 new tests cover unsigned, signed, invalid-signature, empty, multi-turn, and cross-provider scenarios across both patched functions - The lockfile includes minor `axios`/`follow-redirects` deduplication changes as a side effect of running `pnpm install` <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — the patch correctly addresses a targeted API compatibility bug with defensive changes and thorough test coverage. - Score of 4 reflects: (1) the patch logic is correct — signed blocks are still preserved by existing guards while unsigned blocks are safely converted to text, (2) 10 new tests cover the key scenarios comprehensively, (3) the change is narrowly scoped to a specific bug fix with no functional regression risk to other providers. Deducted 1 point because patching a dependency introduces maintenance overhead — this fix should ideally be upstreamed. - The `patches/@mariozechner__pi-ai@0.52.10.patch` file should be tracked as a maintenance item — this patch will need to be verified or removed when `@mariozechner/pi-ai` is upgraded. <sub>Last reviewed commit: c2bd83c</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs