Repository navigation
fix(ai): preserve structured Chat content, refusals, and reasoning - #117136
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 9:08 PM ET / August 1, 2026, 01:08 UTC. ClawSweeper reviewWhat this changesThe PR moves structured OpenAI Chat Completions content, refusal, and reasoning decoding into shared transport logic so package and managed streaming paths preserve the same assistant output. Merge readinessThe reported behavior remains unfixed on current Priority: P1 Review scores
Verification
How this fits togetherOpenAI Chat Completions streams enter OpenClaw through a package provider path and a managed transport path. Each path turns provider deltas into portable visible-text and private-thinking blocks, which are shown to the user and replayed on later provider requests. flowchart LR
Provider[OpenAI Chat stream] --> Package[Package provider stream]
Provider --> Managed[Managed transport stream]
Package --> Decoder[Shared content decoder]
Managed --> Decoder
Decoder --> Blocks[Visible text and private thinking]
Blocks --> Replay[Later provider request]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +47, Tests +464. Total +511 across 5 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the shared decoder and parity suite, then merge after the exact-head checks complete and a maintainer accepts the protected PR. Do we have a high-confidence way to reproduce the issue? Yes: current main's package stream checks Is this the best way to solve the issue? Yes: moving the common typed-content/refusal policy to the existing shared OpenAI transport owner removes duplicate decoding while preserving the two producers' distinct stream mechanics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 65717fd3be89. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: (217 commits) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133) fix(config): delete one array element per config patch delete (openclaw#116463) fix(plugins): report installed dependency health authoritatively (openclaw#117029) fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016) fix(ui): clear hidden session selection before bulk deletion (openclaw#117015) fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127) fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125) fix(models): expose runtime provider catalogs in browse views (openclaw#116857) ...
* commit 'c41f033b87545b658215a9c3bbe03f88fbaa867d': (347 commits) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133) fix(config): delete one array element per config patch delete (openclaw#116463) fix(plugins): report installed dependency health authoritatively (openclaw#117029) fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016) fix(ui): clear hidden session selection before bulk deletion (openclaw#117015) fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127) fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125) ...
* origin/main: (3706 commits) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) ...
* commit '7e78de747b8a64d52f30aee948b697bf4c528691': (359 commits) refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) ...
Co-authored-by: Peter Steinberger <[email protected]>
* commit '31f24547a94a8bd74a32e42cde1783591c5804d9': (347 commits) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133) fix(config): delete one array element per config patch delete (openclaw#116463) fix(plugins): report installed dependency health authoritatively (openclaw#117029) fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016) fix(ui): clear hidden session selection before bulk deletion (openclaw#117015) fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127) fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125) ...
* commit '5148236bbe050f6c05ee59190986a7215b41ce1c': (359 commits) refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) ...
* origin/main: (3706 commits) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) ...
What Problem This Solves
The two OpenAI Chat Completions streaming owners interpreted structured assistant content differently. The package owner could discard typed answers, stringify objects as
[object Object], or mishandle private reasoning; the managed owner could silently discard documented refusal parts. Mirrored reasoning/refusal payloads could duplicate or lose legitimate content, an explicitnonereasoning setting could be ignored, a synthetic thinking signature could overwrite the visible assistant answer on the next provider request, and unconditional strict inline-tag mode could withhold every answer token until completion.Exact frozen parent:
a1b41d5ddb057fe0956b1d53c19fdbf4d33430d9. Immutable candidate:ba13cc48699f39cb5e3726a37d5a2ea4d5858539.Why This Change Was Made
Move structured-content decoding and the existing thinking-effort policy into the existing private shared OpenAI transport owner; route both Chat streaming producers through that single canonical implementation. Preserve actual provider-provided thinking signatures, omit a signature entirely when a structured part supplies none, deduplicate only same-chunk exact mirrors, emit dedicated reasoning before visible content, and enter strict inline-tag buffering only when an actually pending partial tag requires it.
Production change: 166 additions / 119 deletions = +47 lines, explicitly maintainer-approved. Managed owner deletes its duplicate private decoder, type, and effort predicate. The only fifth touched file updates an existing sibling test's previously unsafe synthetic signature expectation. No public plugin SDK, configuration, auth, persistence, protocol, snapshot, or dependency surface changes.
User Impact
nonesuppresses thinking, and provider signatures are never invented.assistant.content.input=75,cacheRead=25,cost=.00012124999999999999; all four protected provider snapshots remain byte-identical.Evidence
Actual installed OpenAI SDK, real localhost HTTP
[email protected]made 44 real HTTP requests across 16 scenarios, including 12 actual next-turn outbound provider requests. Selected exact normalized results:[ { "scenario": "typed-text", "package": [ { "type": "text", "text": "Visible answer" } ], "managed": [ { "type": "text", "text": "Visible answer" } ], "input": 75, "cacheRead": 25 }, { "scenario": "private-reasoning-visible-text", "package": [ { "type": "thinking", "thinking": "Private thought" }, { "type": "text", "text": "Visible answer" } ], "managed": [ { "type": "thinking", "thinking": "Private thought" }, { "type": "text", "text": "Visible answer" } ], "input": 75, "cacheRead": 25 }, { "scenario": "distinct-dedicated-and-structured-reasoning_content", "package": [ { "type": "thinking", "thinking": "Dedicated private thought.Distinct structured private thought.", "thinkingSignature": "reasoning_content" }, { "type": "text", "text": "Visible answer" } ], "managed": [ { "type": "thinking", "thinking": "Dedicated private thought.Distinct structured private thought.", "thinkingSignature": "reasoning_content" }, { "type": "text", "text": "Visible answer" } ], "input": 75, "cacheRead": 25 }, { "scenario": "explicit-none-structured-reasoning", "package": [ { "type": "text", "text": "Visible answer" } ], "managed": [ { "type": "text", "text": "Visible answer" } ], "input": 75, "cacheRead": 25 }, { "scenario": "documented-refusal", "package": [ { "type": "text", "text": "Safety refusal." } ], "managed": [ { "type": "text", "text": "Safety refusal." } ], "input": 75, "cacheRead": 25 }, { "scenario": "mirrored-structured-top-level-refusal", "package": [ { "type": "text", "text": "Safety refusal." } ], "managed": [ { "type": "text", "text": "Safety refusal." } ], "input": 75, "cacheRead": 25 }, { "scenario": "distinct-structured-top-level-refusals", "package": [ { "type": "text", "text": "Provider refusal. Operator guidance." } ], "managed": [ { "type": "text", "text": "Provider refusal. Operator guidance." } ], "input": 75, "cacheRead": 25 }, { "scenario": "split-structured-top-level-refusal", "package": [ { "type": "text", "text": "Safety refusal." } ], "managed": [ { "type": "text", "text": "Safety refusal." } ], "input": 75, "cacheRead": 25 }, { "scenario": "repeated-separate-chunk-refusal", "package": [ { "type": "text", "text": "Safety refusal.Safety refusal." } ], "managed": [ { "type": "text", "text": "Safety refusal.Safety refusal." } ], "input": 75, "cacheRead": 25 } ]Actual next-turn assistant messages preserve the visible answer and do not invent a reasoning field for unsigned structured thoughts:
[ { "scenario": "private-reasoning-visible-text", "lane": "package", "assistantContent": "Visible answer", "providerReasoningFields": [] }, { "scenario": "private-reasoning-visible-text", "lane": "managed", "assistantContent": "Visible answer", "providerReasoningFields": [] }, { "scenario": "mirrored-dedicated-and-structured-reasoning", "lane": "package", "assistantContent": "Visible answer", "providerReasoningFields": [ "reasoning_content" ] }, { "scenario": "mirrored-dedicated-and-structured-reasoning", "lane": "managed", "assistantContent": "Visible answer", "providerReasoningFields": [] }, { "scenario": "distinct-dedicated-and-structured-reasoning_content", "lane": "package", "assistantContent": "Visible answer", "providerReasoningFields": [ "reasoning_content" ] }, { "scenario": "distinct-dedicated-and-structured-reasoning_content", "lane": "managed", "assistantContent": "Visible answer", "providerReasoningFields": [] } ]Delayed real SDK streaming; terminal intentionally withheld
The regression suite additionally feeds partial
<thifollowed by structured thinking andnk>SECRET</think>SAFE; both producers returnSAFEand never exposeSECRET.Full hosted type and owner proof
Blacksmith Testbox lease
tbx_01kyxcycme3d367hneahmmrxnr: exact-head hosted verification.Wrapper exit:
0; run status:succeeded; lease independently verifiedcompleted/stopped. The backing Actions step can report cancellation during successful externally owned Testbox teardown; the authoritative wrapper exit and timing JSON both report success.Independent review and protected contracts
gpt-5.6-solhigh-reasoning autoreview against exact parent, explicit--max-priority P3: zero findings, confidence 0.87; genuine TruffleHog clean.e2a1b1100acdf7c5f24c5c7cadd60e924c29b2ab; OpenAI error4156ead6875cd55590550f5313f7fd69e72c9a4b; Anthropic success84170ce01bdf669d23d22abb9d280c70ea2fb614; Anthropic error1cde0a07d3c44dcd1719e74da77db5139e37edc5.a7b4a4735628c5b411adc361b8289f3cc41ed271: zero touched-owner changes since the frozen parent; clean merge treec188f4d5eb662825a35fe8878f50727ac5d7926a.