Repository navigation
fix(llm): preserve non-array tool result replay text - #98826
snowzlmbot wants to merge 4 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 12:15 AM ET / 04:15 UTC. Summary PR surface: Source +79, Tests +102. Total +181 across 12 files. Reproducibility: yes. Source inspection gives a high-confidence path: replay a text-only model context with a raw string toolResult content value, and transformMessages can turn it into one-character blocks before provider conversion. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Normalize non-array tool-result content at the session/transcript boundary or before transformMessages image downgrade, keep provider replay contracts array-shaped where possible, and add focused text-only provider replay proof. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection gives a high-confidence path: replay a text-only model context with a raw string toolResult content value, and transformMessages can turn it into one-character blocks before provider conversion. Is this the best way to solve the issue? No. Provider-boundary normalization is useful but not sufficient because the pre-provider transform path can corrupt raw string tool results first; the safer fix is to normalize loaded/session toolResult content before provider replay. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6e79ca3cbc7d. Label changesLabel justifications:
Evidence reviewedPR surface: Source +79, Tests +102. Total +181 across 12 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Closing: the underlying bug (#98825) is fixed on We took a different approach than this PR: instead of widening the shared replay helpers to tolerate non-array Thanks for digging into this — the character-by-character iteration analysis in #98825 was exactly right. If you hit a path where non-array tool-result content still reaches the extractors after e095dc8 (i.e. one that doesn't enter via session-file load), please open a fresh issue with the repro and we'll extend the boundary normalization there. |
Thanks for submitting the PR. I'll pull this PR patch locally and test it again to make sure the bug is actually fixed and no new bugs are introduced |
Summary
Preserve useful provider replay text when tool-result content reaches the shared replay boundary as a plain string, primitive value, single structured object, or text-like object instead of the canonical content-block array.
What Problem This Solves
After #97742 introduced shared structured tool-result replay extraction, non-canonical or legacy tool-result content can still reach provider replay as a non-array value. The previous draft normalized only inside
extractToolResultText(), but several provider callers still inspected the originalmsg.contentwith.some(),.filter(), or direct iteration for image/media handling. That meant the stated string or single-object replay path could still throw or suppress useful output before provider payload creation finished.Review Context Addressed
text/output/contentobject fields through the existing redaction, inline-data omission, and provider truncation safeguards before replay.Implementation
normalizeToolResultBlocks()helper for provider replay boundaries..some()/.filter()calls on the original value.Validation
git diff --checkwere attempted in a local OpenClaw checkout. The local session is affected by the tool-result replay output-loss symptom being fixed here, so local terminal output is not used as merge proof.Evidence
src/llm/providers/tool-result-text.tsfor redacted text-like object handling and normalized caller media checks.Risk
Low to moderate. The change broadens defensive handling for non-canonical replay content at provider boundaries, but it preserves canonical array behavior and keeps media payload handling restricted to validated image blocks with string MIME/data fields. The security-sensitive part is text-like object replay; that path now applies redaction, inline-data omission, and truncation before provider-bound text is produced.
Rollback
Revert this PR to restore the previous strict array-shaped replay behavior. No data migration or configuration rollback is required.
Docs Updated
No user-facing docs were changed. This is a defensive runtime compatibility fix with regression coverage.
Related Issue / PR
Not Tested / Limitations