Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs real behavior proof before merge. What this changesReplay historical calls to unavailable Chat Completions tools and their results as text while preserving native protocol for available tools. Example: History contains session_status, but the outgoing catalog contains only lookup_weather.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR addresses a concrete upstream replay defect still present on current main; inspection found no actionable introduced bug, and exact-head CI is green. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared Chat Completions request builder converts conversation history and the accepted tool catalog into provider messages for direct and managed transports. flowchart LR
A[Conversation history] --> C[Shared request builder]
B[Accepted tool catalog] --> C
C --> D[History converter]
E[Captured prefix IDs] --> D
D --> F[Native calls and textual history]
F --> G[Chat Completions transport]
Technical reviewBest possible solution: Keep the repair in the shared request projection, preserving stored transcripts, accepted native calls, and captured-prefix result identities. Do we have a high-confidence way to reproduce the issue? The linked report identifies OpenClaw 2026.10.4 and a concrete GigaChat rejection, and current-main source confirms that unavailable historical tools remain native protocol; no target code was executed during this review. Is this the best way to solve the issue? The shared converter is the appropriate owner: the patch uses the accepted outgoing catalog, preserves error context and stored history, and retains native result ordering and captured-prefix IDs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ca94e80cb29f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +29, Tests +155, Docs +5. Total +189 across 13 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 17, 2026, 3:44 AM ET / 07:44 UTC (Revision 4). |
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* fix(ai): claim undeclared historical tool replay repair * fix(ai): replay unavailable historical tools as text * test(ai): align replay HTTP regression with lint lifecycle rules * fix(ai): reconcile history with the prepared tool catalog * fix(ai): keep late history results aligned with native prefix calls * docs(ai): state the prepared suffix carrier invariant * fix(ai): simplify unavailable tool history projection Keep unavailable tool errors in deterministic request text without rewriting stored history. Consolidate result text after native batches and cover the request builder directly. Co-authored-by: Eric Cai <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Eric Cai <[email protected]>
…iders that reject assistant prefill (#202436) Root cause: `packages/ai/src/transports/openai-completions-params.ts:300` gave the Chat Completions history converter only the tools in the outgoing `tools` list, so a Tool Search directory tool that a direct call hydrates (kept out of that list so the tool block stays cache-stable) was treated as an unavailable historical tool, and `openai-completions-messages.ts:185`/`:287` replayed its call and result as assistant text, leaving the follow-up request ending with an assistant message. Fixes #202415 Thanks @paulsimmondsplato for the detailed report, including the request shapes and the `exec` control. ## What Problem This Solves With Tool Search in directory mode on an OpenAI-compatible chat-completions provider (for example LiteLLM in front of Anthropic), every turn that called `web_search` failed: the follow-up request carried the search as assistant text instead of a tool call and result, and ended with that assistant message. Anthropic rejects that as assistant prefill, so the turn errored. This started in 2026.11.6. ## User Impact Turns that use a Tool Search directory tool such as `web_search` work again on chat-completions providers that require the conversation to end with a user or tool message. Tools that are truly no longer available in a conversation's history still replay as text, as before. ## Why This Change Was Made #174797 (8fc3509, first shipped in 2026.11.6) made the request builder replay calls to tools missing from the outgoing tool list as text, so strict providers stop rejecting hallucinated or removed tools. Hydrated directory tools are never in that list by design, so they were caught by the same check. The embedded runner now tells the request builder which directory tools are callable in this run, and the builder treats those as current. The tool list itself is unchanged, and the projection is the same on every request of the session, so prompt-cache prefixes stay append-only. ## Evidence Real Gateway from source (`ocx src`), isolated state, openai-completions provider pointed at a loopback fixture that records request shapes and returns Anthropic's prefill 400 for an assistant tail, `tools.toolSearch.mode: "directory"`, bundled SearXNG `web_search` pointed at the fixture. Same session: a `read` turn, a `web_search` turn, then a restart with `tools.deny: ["read"]` and one more turn. - Base `217bb899f09f`: the `web_search` follow-up ends `assistant text:"[tool call id=... name=web_search]" "[tool result ...]"`, fixture answers 400, turn fails with `LLM request rejected: This model does not support assistant message prefill`. - Candidate: the same request ends `assistant tool_calls[web_search]`, `tool tool_call_id=...`; the turn answers. `web_search` is still absent from `tools` on every request. - Controls: the `read` call (directly exposed) is `tool_calls[read]` + `tool` on both; after `read` is denied, its history replays as text on both (the #174797 behavior), and on the candidate the earlier `web_search` exchange stays native, matching the previous request. - New regression in `openai-completions-replay.test.ts` fails on base and passes here; `agent-tools.prefix-stability.test.ts` passes. Observed proof lines: #202436 (comment) Merge danger: two-way door. No stored state, config or published contract changes; a revert restores the 2026.11.6 projection. Blast radius: embedded runs with Tool Search directory mode on chat-completions providers. A strict provider that rejects tool calls to tools absent from `tools` would now see those calls natively, which is how 2026.10.33 sent them. Co-authored-by: Ayaan Zaidi <[email protected]>
…iders that reject assistant prefill (openclaw#202436) Root cause: `packages/ai/src/transports/openai-completions-params.ts:300` gave the Chat Completions history converter only the tools in the outgoing `tools` list, so a Tool Search directory tool that a direct call hydrates (kept out of that list so the tool block stays cache-stable) was treated as an unavailable historical tool, and `openai-completions-messages.ts:185`/`:287` replayed its call and result as assistant text, leaving the follow-up request ending with an assistant message. Fixes openclaw#202415 Thanks @paulsimmondsplato for the detailed report, including the request shapes and the `exec` control. ## What Problem This Solves With Tool Search in directory mode on an OpenAI-compatible chat-completions provider (for example LiteLLM in front of Anthropic), every turn that called `web_search` failed: the follow-up request carried the search as assistant text instead of a tool call and result, and ended with that assistant message. Anthropic rejects that as assistant prefill, so the turn errored. This started in 2026.11.6. ## User Impact Turns that use a Tool Search directory tool such as `web_search` work again on chat-completions providers that require the conversation to end with a user or tool message. Tools that are truly no longer available in a conversation's history still replay as text, as before. ## Why This Change Was Made openclaw#174797 (ddca1ff, first shipped in 2026.11.6) made the request builder replay calls to tools missing from the outgoing tool list as text, so strict providers stop rejecting hallucinated or removed tools. Hydrated directory tools are never in that list by design, so they were caught by the same check. The embedded runner now tells the request builder which directory tools are callable in this run, and the builder treats those as current. The tool list itself is unchanged, and the projection is the same on every request of the session, so prompt-cache prefixes stay append-only. ## Evidence Real Gateway from source (`ocx src`), isolated state, openai-completions provider pointed at a loopback fixture that records request shapes and returns Anthropic's prefill 400 for an assistant tail, `tools.toolSearch.mode: "directory"`, bundled SearXNG `web_search` pointed at the fixture. Same session: a `read` turn, a `web_search` turn, then a restart with `tools.deny: ["read"]` and one more turn. - Base `cba4f7c518ae`: the `web_search` follow-up ends `assistant text:"[tool call id=... name=web_search]" "[tool result ...]"`, fixture answers 400, turn fails with `LLM request rejected: This model does not support assistant message prefill`. - Candidate: the same request ends `assistant tool_calls[web_search]`, `tool tool_call_id=...`; the turn answers. `web_search` is still absent from `tools` on every request. - Controls: the `read` call (directly exposed) is `tool_calls[read]` + `tool` on both; after `read` is denied, its history replays as text on both (the openclaw#174797 behavior), and on the candidate the earlier `web_search` exchange stays native, matching the previous request. - New regression in `openai-completions-replay.test.ts` fails on base and passes here; `agent-tools.prefix-stability.test.ts` passes. Observed proof lines: openclaw#202436 (comment) Merge danger: two-way door. No stored state, config or published contract changes; a revert restores the 2026.11.6 projection. Blast radius: embedded runs with Tool Search directory mode on chat-completions providers. A strict provider that rejects tool calls to tools absent from `tools` would now see those calls natively, which is how 2026.10.33 sent them. Co-authored-by: Ayaan Zaidi <[email protected]>
…iders that reject assistant prefill (#202436) Root cause: `packages/ai/src/transports/openai-completions-params.ts:300` gave the Chat Completions history converter only the tools in the outgoing `tools` list, so a Tool Search directory tool that a direct call hydrates (kept out of that list so the tool block stays cache-stable) was treated as an unavailable historical tool, and `openai-completions-messages.ts:185`/`:287` replayed its call and result as assistant text, leaving the follow-up request ending with an assistant message. Fixes #202415 Thanks @paulsimmondsplato for the detailed report, including the request shapes and the `exec` control. ## What Problem This Solves With Tool Search in directory mode on an OpenAI-compatible chat-completions provider (for example LiteLLM in front of Anthropic), every turn that called `web_search` failed: the follow-up request carried the search as assistant text instead of a tool call and result, and ended with that assistant message. Anthropic rejects that as assistant prefill, so the turn errored. This started in 2026.11.6. ## User Impact Turns that use a Tool Search directory tool such as `web_search` work again on chat-completions providers that require the conversation to end with a user or tool message. Tools that are truly no longer available in a conversation's history still replay as text, as before. ## Why This Change Was Made #174797 (8fc3509, first shipped in 2026.11.6) made the request builder replay calls to tools missing from the outgoing tool list as text, so strict providers stop rejecting hallucinated or removed tools. Hydrated directory tools are never in that list by design, so they were caught by the same check. The embedded runner now tells the request builder which directory tools are callable in this run, and the builder treats those as current. The tool list itself is unchanged, and the projection is the same on every request of the session, so prompt-cache prefixes stay append-only. ## Evidence Real Gateway from source (`ocx src`), isolated state, openai-completions provider pointed at a loopback fixture that records request shapes and returns Anthropic's prefill 400 for an assistant tail, `tools.toolSearch.mode: "directory"`, bundled SearXNG `web_search` pointed at the fixture. Same session: a `read` turn, a `web_search` turn, then a restart with `tools.deny: ["read"]` and one more turn. - Base `217bb899f09f`: the `web_search` follow-up ends `assistant text:"[tool call id=... name=web_search]" "[tool result ...]"`, fixture answers 400, turn fails with `LLM request rejected: This model does not support assistant message prefill`. - Candidate: the same request ends `assistant tool_calls[web_search]`, `tool tool_call_id=...`; the turn answers. `web_search` is still absent from `tools` on every request. - Controls: the `read` call (directly exposed) is `tool_calls[read]` + `tool` on both; after `read` is denied, its history replays as text on both (the #174797 behavior), and on the candidate the earlier `web_search` exchange stays native, matching the previous request. - New regression in `openai-completions-replay.test.ts` fails on base and passes here; `agent-tools.prefix-stability.test.ts` passes. Observed proof lines: #202436 (comment) Merge danger: two-way door. No stored state, config or published contract changes; a revert restores the 2026.11.6 projection. Blast radius: embedded runs with Tool Search directory mode on chat-completions providers. A strict provider that rejects tool calls to tools absent from `tools` would now see those calls natively, which is how 2026.10.33 sent them. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2d7934a) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit cd173fd98fc20582634c3347b741144012cde29b) (cherry picked from commit 010988e602cb51ce1889e54bc029203846016abc)
…ers no tools - With no tools offered there is no catalog to reconcile history against, so calls and results stay native tool_calls/tool messages instead of assistant bracket text the model imitates. - Denied or removed tools in a non-empty catalog still replay as text (openclaw#174797); supportsTools=false models unchanged. Fixes openclaw#205127
…ers no tools (#206864) Root cause: `packages/ai/src/transports/openai-completions-params.ts:302` built an empty `declaredToolNames` set when a Chat Completions request offers no tools, so `packages/ai/src/openai-completions-messages.ts:189` turned every earlier tool call and result into assistant-role `[tool call id=… name=…]` / `[tool result id=… name=…]` text. The tool-free request that writes the final answer after a cut-off tool turn then showed the model its own turn in that format, and the model copied it into the reply. Fixes #205127 Thanks @ningchen-2333 for the report and screenshot, and @zsicheng0214 for the first fix and for pinning down the exact frame format. This PR keeps their commit and builds on it. ## What Problem This Solves When a tool-heavy turn ended without a final answer, OpenClaw sent one more request with tools turned off to get the answer. Since #174797 (`8fc3509a66ad`), that request sent the turn's tool calls and results as plain assistant text. The model (DeepSeek in the report, and our scripted model) copied that text, so the user got `[tool call id=… name=exec] {…}` and `[tool result id=…]` lines instead of an answer. ## Fix A request that offers no tools has no tool list to check history against, so its history now stays in normal `tool_calls` + `tool` messages, as it did before #174797. The change is about 5 production lines in the two files above. Unchanged: - A tool that was denied or removed, in a request that still offers other tools, is still replayed as text (#174797). - Models with `compat.supportsTools: false` still get text. - Tool Search directory tools such as `web_search` stay native (#202436). The first commit removes the display filter change from this PR's original approach. It hid the lines after the model had already written them, so the user still got no real answer, and it had an open edge case with ids like `read:0`. Not in this PR: orphan DeepSeek DSML closing tags (`</||DSML|| parameter>`) are tracked in #198042 / #198043. ## Evidence Gateway from source with isolated state. An openai-completions provider points at a loopback fixture that records each request. The scripted model makes two `exec` calls, then sends an empty `stop` reply so the final-answer request runs. When a request offers no tools, the model repeats any bracket frames in the last assistant text, otherwise it says "Summary: done." | | base `f77ce263f6a1` | this PR | |---|---|---| | final-answer request history | assistant text with 4 `[tool call/result id=…]` frames | `assistant tool_calls[exec,exec]`, 2× `tool` | | reply and `chat.history` | the 4 frames with the `exec` arguments and output | `Summary: done.` | | control: `exec` denied after use | history as text | history as text | | control: `supportsTools: false` model | history as text | history as text | | control: Tool Search `web_search` | native | native | Unit: the new case in `openai-completions-replay.test.ts` (tools `[]` and absent) and the restored pre-#174797 expectation in `openai-completions-params.test.ts` fail on base and pass here. Proof lines: #206864 (comment) Not run: a real `deepseek-v4-flash` session (no DeepSeek key is available to us). `strictMessageKeys`: no bundled provider sets it. It is a user opt-in for local servers. Such backends get `role`/`content` only, as before #174797, which is what they get on every normal turn with tools. Merge danger: two-way door. No stored state, config or published contract changes, and a revert restores the current text projection. Blast radius: Chat Completions requests with tool history and no tools (the final-answer request after a cut-off turn, `/btw`, keep-warm forks). A provider that rejects `tool_calls` history without a tools list would now see it again; that was the shipped behavior before 2026.11.6. Co-authored-by: Ayaan Zaidi <[email protected]>
…ers no tools (#206864) Root cause: `packages/ai/src/transports/openai-completions-params.ts:302` built an empty `declaredToolNames` set when a Chat Completions request offers no tools, so `packages/ai/src/openai-completions-messages.ts:189` turned every earlier tool call and result into assistant-role `[tool call id=… name=…]` / `[tool result id=… name=…]` text. The tool-free request that writes the final answer after a cut-off tool turn then showed the model its own turn in that format, and the model copied it into the reply. Fixes #205127 Thanks @ningchen-2333 for the report and screenshot, and @zsicheng0214 for the first fix and for pinning down the exact frame format. This PR keeps their commit and builds on it. ## What Problem This Solves When a tool-heavy turn ended without a final answer, OpenClaw sent one more request with tools turned off to get the answer. Since #174797 (`8fc3509a66ad`), that request sent the turn's tool calls and results as plain assistant text. The model (DeepSeek in the report, and our scripted model) copied that text, so the user got `[tool call id=… name=exec] {…}` and `[tool result id=…]` lines instead of an answer. ## Fix A request that offers no tools has no tool list to check history against, so its history now stays in normal `tool_calls` + `tool` messages, as it did before #174797. The change is about 5 production lines in the two files above. Unchanged: - A tool that was denied or removed, in a request that still offers other tools, is still replayed as text (#174797). - Models with `compat.supportsTools: false` still get text. - Tool Search directory tools such as `web_search` stay native (#202436). The first commit removes the display filter change from this PR's original approach. It hid the lines after the model had already written them, so the user still got no real answer, and it had an open edge case with ids like `read:0`. Not in this PR: orphan DeepSeek DSML closing tags (`</||DSML|| parameter>`) are tracked in #198042 / #198043. ## Evidence Gateway from source with isolated state. An openai-completions provider points at a loopback fixture that records each request. The scripted model makes two `exec` calls, then sends an empty `stop` reply so the final-answer request runs. When a request offers no tools, the model repeats any bracket frames in the last assistant text, otherwise it says "Summary: done." | | base `f77ce263f6a1` | this PR | |---|---|---| | final-answer request history | assistant text with 4 `[tool call/result id=…]` frames | `assistant tool_calls[exec,exec]`, 2× `tool` | | reply and `chat.history` | the 4 frames with the `exec` arguments and output | `Summary: done.` | | control: `exec` denied after use | history as text | history as text | | control: `supportsTools: false` model | history as text | history as text | | control: Tool Search `web_search` | native | native | Unit: the new case in `openai-completions-replay.test.ts` (tools `[]` and absent) and the restored pre-#174797 expectation in `openai-completions-params.test.ts` fail on base and pass here. Proof lines: #206864 (comment) Not run: a real `deepseek-v4-flash` session (no DeepSeek key is available to us). `strictMessageKeys`: no bundled provider sets it. It is a user opt-in for local servers. Such backends get `role`/`content` only, as before #174797, which is what they get on every normal turn with tools. Merge danger: two-way door. No stored state, config or published contract changes, and a revert restores the current text projection. Blast radius: Chat Completions requests with tool history and no tools (the final-answer request after a cut-off turn, `/btw`, keep-warm forks). A provider that rejects `tool_calls` history without a tools list would now see it again; that was the shipped behavior before 2026.11.6. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 5218d21)
…ers no tools (openclaw#206864) Root cause: `packages/ai/src/transports/openai-completions-params.ts:302` built an empty `declaredToolNames` set when a Chat Completions request offers no tools, so `packages/ai/src/openai-completions-messages.ts:189` turned every earlier tool call and result into assistant-role `[tool call id=… name=…]` / `[tool result id=… name=…]` text. The tool-free request that writes the final answer after a cut-off tool turn then showed the model its own turn in that format, and the model copied it into the reply. Fixes openclaw#205127 Thanks @ningchen-2333 for the report and screenshot, and @zsicheng0214 for the first fix and for pinning down the exact frame format. This PR keeps their commit and builds on it. ## What Problem This Solves When a tool-heavy turn ended without a final answer, OpenClaw sent one more request with tools turned off to get the answer. Since openclaw#174797 (`ddca1ffc7df8`), that request sent the turn's tool calls and results as plain assistant text. The model (DeepSeek in the report, and our scripted model) copied that text, so the user got `[tool call id=… name=exec] {…}` and `[tool result id=…]` lines instead of an answer. ## Fix A request that offers no tools has no tool list to check history against, so its history now stays in normal `tool_calls` + `tool` messages, as it did before openclaw#174797. The change is about 5 production lines in the two files above. Unchanged: - A tool that was denied or removed, in a request that still offers other tools, is still replayed as text (openclaw#174797). - Models with `compat.supportsTools: false` still get text. - Tool Search directory tools such as `web_search` stay native (openclaw#202436). The first commit removes the display filter change from this PR's original approach. It hid the lines after the model had already written them, so the user still got no real answer, and it had an open edge case with ids like `read:0`. Not in this PR: orphan DeepSeek DSML closing tags (`</||DSML|| parameter>`) are tracked in openclaw#198042 / openclaw#198043. ## Evidence Gateway from source with isolated state. An openai-completions provider points at a loopback fixture that records each request. The scripted model makes two `exec` calls, then sends an empty `stop` reply so the final-answer request runs. When a request offers no tools, the model repeats any bracket frames in the last assistant text, otherwise it says "Summary: done." | | base `92610aca7d2c` | this PR | |---|---|---| | final-answer request history | assistant text with 4 `[tool call/result id=…]` frames | `assistant tool_calls[exec,exec]`, 2× `tool` | | reply and `chat.history` | the 4 frames with the `exec` arguments and output | `Summary: done.` | | control: `exec` denied after use | history as text | history as text | | control: `supportsTools: false` model | history as text | history as text | | control: Tool Search `web_search` | native | native | Unit: the new case in `openai-completions-replay.test.ts` (tools `[]` and absent) and the restored pre-openclaw#174797 expectation in `openai-completions-params.test.ts` fail on base and pass here. Proof lines: openclaw#206864 (comment) Not run: a real `deepseek-v4-flash` session (no DeepSeek key is available to us). `strictMessageKeys`: no bundled provider sets it. It is a user opt-in for local servers. Such backends get `role`/`content` only, as before openclaw#174797, which is what they get on every normal turn with tools. Merge danger: two-way door. No stored state, config or published contract changes, and a revert restores the current text projection. Blast radius: Chat Completions requests with tool history and no tools (the final-answer request after a cut-off turn, `/btw`, keep-warm forks). A provider that rejects `tool_calls` history without a tools list would now see it again; that was the shipped behavior before 2026.11.6. Co-authored-by: Ayaan Zaidi <[email protected]>
…ers no tools (#206864) Root cause: `packages/ai/src/transports/openai-completions-params.ts:302` built an empty `declaredToolNames` set when a Chat Completions request offers no tools, so `packages/ai/src/openai-completions-messages.ts:189` turned every earlier tool call and result into assistant-role `[tool call id=… name=…]` / `[tool result id=… name=…]` text. The tool-free request that writes the final answer after a cut-off tool turn then showed the model its own turn in that format, and the model copied it into the reply. Fixes #205127 Thanks @ningchen-2333 for the report and screenshot, and @zsicheng0214 for the first fix and for pinning down the exact frame format. This PR keeps their commit and builds on it. When a tool-heavy turn ended without a final answer, OpenClaw sent one more request with tools turned off to get the answer. Since #174797 (`8fc3509a66ad`), that request sent the turn's tool calls and results as plain assistant text. The model (DeepSeek in the report, and our scripted model) copied that text, so the user got `[tool call id=… name=exec] {…}` and `[tool result id=…]` lines instead of an answer. A request that offers no tools has no tool list to check history against, so its history now stays in normal `tool_calls` + `tool` messages, as it did before #174797. The change is about 5 production lines in the two files above. Unchanged: - A tool that was denied or removed, in a request that still offers other tools, is still replayed as text (#174797). - Models with `compat.supportsTools: false` still get text. - Tool Search directory tools such as `web_search` stay native (#202436). The first commit removes the display filter change from this PR's original approach. It hid the lines after the model had already written them, so the user still got no real answer, and it had an open edge case with ids like `read:0`. Not in this PR: orphan DeepSeek DSML closing tags (`</||DSML|| parameter>`) are tracked in #198042 / #198043. Gateway from source with isolated state. An openai-completions provider points at a loopback fixture that records each request. The scripted model makes two `exec` calls, then sends an empty `stop` reply so the final-answer request runs. When a request offers no tools, the model repeats any bracket frames in the last assistant text, otherwise it says "Summary: done." | | base `f77ce263f6a1` | this PR | |---|---|---| | final-answer request history | assistant text with 4 `[tool call/result id=…]` frames | `assistant tool_calls[exec,exec]`, 2× `tool` | | reply and `chat.history` | the 4 frames with the `exec` arguments and output | `Summary: done.` | | control: `exec` denied after use | history as text | history as text | | control: `supportsTools: false` model | history as text | history as text | | control: Tool Search `web_search` | native | native | Unit: the new case in `openai-completions-replay.test.ts` (tools `[]` and absent) and the restored pre-#174797 expectation in `openai-completions-params.test.ts` fail on base and pass here. Proof lines: #206864 (comment) Not run: a real `deepseek-v4-flash` session (no DeepSeek key is available to us). `strictMessageKeys`: no bundled provider sets it. It is a user opt-in for local servers. Such backends get `role`/`content` only, as before #174797, which is what they get on every normal turn with tools. Merge danger: two-way door. No stored state, config or published contract changes, and a revert restores the current text projection. Blast radius: Chat Completions requests with tool history and no tools (the final-answer request after a cut-off turn, `/btw`, keep-warm forks). A provider that rejects `tool_calls` history without a tools list would now see it again; that was the shipped behavior before 2026.11.6. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 5218d21) Companion audit: 7b82c14 no-empty-tools is present in stable and must be preserved; ac3a457 tool-schema strictness is independent. Release adaptation: Adapt stable paired result classification as well as tool call classification. Keep omitted request tools and results with a declared catalog unchanged. Co-authored-by: RomneyDa <[email protected]>
Fixes #174779.
What Problem This Solves
A hallucinated or removed tool in completed conversation history makes strict Chat Completions providers reject every subsequent turn, repeatedly triggering fallback.
User Impact
Affected conversations can continue without starting a new session or rewriting stored history. The model still sees the original “Tool … not found” result. No configuration, migration, schema, or public SDK changes are required.
Why This Change Was Made
The shared Chat Completions request builder supplies its accepted outgoing tool catalog to the existing history converter. Unavailable calls and results become readable text; declared calls keep native protocol, and native parallel results stay contiguous. Both managed and direct transports use this owner. Captured-prefix late results keep their original wire IDs. Other provider protocols are unchanged.
Maintainer cleanup combines text-result appending, replaces the loopback HTTP fixture with synchronous regressions at the production request builder, and documents transcript preservation. Projection is deterministic for the same history and catalog. There are no new detached or deferred effects; captured prefix IDs remain immutable facts about the request prefix supplied by the session-fork owner.
Original fix by @ericcaiwx-star; maintainer cleanup simplifies replay and regression coverage while preserving contributor credit.
Evidence
852875eebb993ddd040aba344e93d36dd31518f0: the converter emits native historical calls whenever tools are supported, without checking the outgoing catalog. Collision checks found no competing fix.79b7c9d004430a08f474b9b23ce9cb19d488a3fb, after merging main without rebasing. Exact-head CI run 39009882614 completed with 49 successful jobs, 28 skipped jobs, one failing test-typecheck job, and the consequent failing aggregate gate. The selected test jobs, lint, and production typechecks passed.openai-completions-replay.test.ts:projects undeclared history against the outgoing catalog without changing the transcript (direct/managed)andkeeps captured-prefix native result IDs and projects unavailable suffix results as text. These check unknown and schema-rejected tools, mixed native ordering, retained error text, same-model IDs, unchanged history, follow-up prefix stability, and late suffix results.Delta against the PR base: production +51/-22 (net +29), tests +165/-10 (net +155), docs +5/-0. The remaining production growth connects the accepted tool catalog and captured-prefix IDs to the existing projection owner; deleting unrelated checks to force a negative delta would weaken this fix. Compared with the contributor head, the maintained candidate removes the server fixture and reduces total change size.
Remaining landing gate
The PR is open and ready for review, but is not fully land-ready while
check-test-types-core-1and the aggregate gate are red. Job 117330504961 reports TS2741 atsrc/config/io.health-state-scope.test.ts:71and:78:ConfigHealthStateStorelacks[Symbol.dispose]but two fixtures still declare it withusing.These files are outside this PR's diff. Source history traces the removed disposal contract and incomplete fixture conversion to main commit
8d8944985883a74484c0ca397c535e5291fddcda, merged before this PR's required main integration. A fresh latest-scheduled-CI lookup returned main run 39006528379 atbbb775bd011b435f51a0d0ee2df2b51285f16761, created 2026-10-17 05:30 UTC, before that change at 06:15 UTC; its corresponding job 117320109150 passed. Consequently there is no matching scheduled-main failure evidence yet, and this report does not claim the campaign's inherited-failure exception. The coordinator needs the upstream fixture correction integrated or qualifying scheduled-main attribution before landing. No gate was waived and no CI rerun was requested.