fix(provider-protocol): preserve tool content and response semantics - #2233
Merged
Conversation
Codex ReviewVerdict: mergeable No actionable findings. Summary: Static inspection of the base-to-HEAD changes found no concrete merge-blocking defects. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Provider protocol conversion can silently change tool results and completion semantics: tool images become text or disappear, truncated answers look complete, cached input is undercounted, xAI Chat SSE omits requested usage, parallel tools have no stream index, malformed tool arguments become
{}, multiline native SSE loses tool identity, and request sanitization removes legitimate schema fields and null constraints.Proposed change
cache_creation_input_tokenscompatibility extension. Emit requested xAI SSE usage with emptychoicesbefore[DONE]and add stable parallel tool indexes at Chat serialization.{}remains allowed.Scope and non-goals
Six existing production files, no new production module or public export. No database/schema migration, application enum, persisted format, historical backfill, UI component, dependency or subscription owner. Correct future usage can flow through existing persistence consumers. Existing unknown/omitted-status compatibility is covered separately from explicit failure handling.
Images use supported upstream content parts; this does not enable new models or change the application's saved user messages. No automatic continuation/retry or tool execution is added. No UI screenshots apply because renderer pages and error presentation are unchanged; HTTP error behavior is tested, not claimed as a UI reproduction.
Acceptance criteria and validation
The final regression suite contains 41 cases. Against the unchanged base production files, 36 cases failed and 5 controls passed on each of two runs. Failures were behavioral assertions matching R01–R08, not startup errors. The same suite passes 41/41 after the fix. Existing captured Codex/Claude image requests and real loopback HTTP bridges are used; no production test seam was introduced.
All checks below ran after the last material edit. The worktree reused the root installation for Vitest:
node ../../node_modules/vitest/vitest.mjs run src/main/settings/provider-protocol-regressions.test.ts src/main/settings/chat-provider-compatibility.test.ts src/main/acp/codebuddy-turn-adapter.test.ts src/main/agent-framework/codebuddy.test.ts src/shared/settings.test.ts --maxWorkers=2npm run test:module -- settings_backend_resolutionnpm run typechecknpm run lintprettier --check <11 changed files>;git diff --checknpm run test:affected:explain -- --base f4897533d853740320dbbf29b4e0aa7dd92c9d68 --head HEADThe module set covers Claude Code, OpenCode, Codex Responses and Codex Chat routes; supplemental checks cover CodeBuddy. No local full
npm testwas run, per maintainer instruction. The exact-head PR Gate remains authoritative for full and platform-risk lanes. Independent AI review is pending CI; local checks are not a claim of completed independent review.Limitations: deterministic upstream fixtures establish wire contracts, not real-provider acceptance, real CLI tool execution, UI billing, or historical data recovery. The R05 consumer composition demonstrates the index contract and is not presented as a real CodeBuddy-to-Responses production chain. Four module tests remain skipped under their existing environment gates.
Review focus
Image association and parallel-result ordering; completion versus truncation/error semantics; cache totals and the additive cache-write field; no fabricated tool arguments; SSE metadata/limits preservation; sanitization boundaries. Local planning files and raw evidence are excluded from the PR.