Repository navigation
refactor(agents): fold assistant string normalization into transcript ingest - #98908
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 1:39 AM ET / 05:39 UTC. Summary PR surface: Source 0, Tests +97. Total +97 across 9 files. Reproducibility: yes. source-reproducible. Current main only normalizes loaded JSONL Review metrics: 1 noteworthy metric.
Stored data model 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:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the ingest-boundary normalization after maintainer approval and clean exact-head checks, while keeping Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible. Current main only normalizes loaded JSONL Is this the best way to solve the issue? Yes. Normalizing persisted legacy strings at JSONL ingest is the clean owner boundary, and keeping the AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c8dba85b5d41. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0, Tests +97. Total +97 across 9 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
|
085f105 to
55f59ff
Compare
55f59ff to
f5b25d8
Compare
|
Landed via squash onto
|
Session ingest has normalized legacy assistant string content into
[{ type: "text" }] blocks since #98908, which updated the core
cli-runner session-history analog but missed this extension file.
The suite only runs in full local runs and the dispatch-only
plugin-prerelease lane, so push/PR CI stayed green while local
scripts/pr prepare-gates failed on any OS.
refs #99857
Session ingest has normalized legacy assistant string content into
[{ type: "text" }] blocks since openclaw#98908, which updated the core
cli-runner session-history analog but missed this extension file.
The suite only runs in full local runs and the dispatch-only
plugin-prerelease lane, so push/PR CI stayed green while local
scripts/pr prepare-gates failed on any OS.
refs openclaw#99857
What Problem This Solves
Follow-up to #98891.
src/llm/providers/transform-messages.tscarried a second, older copy of the "JSONL replay can hand us a raw string" normalization for assistant content — a special case at provider-conversion altitude, duplicating what the session-ingest boundary now owns. Worse, transport streams (anthropic-transport-stream,openai-transport-stream, google/xai extensions) never calltransformMessages, so a replayed assistant message with string content was still mis-shaped on those paths — the same latent bug class #98891 fixed for tool results.Why This Change Was Made
normalizeLoadedFileEntry(the fix(agents): normalize non-array tool-result content at transcript ingest #98891 ingest boundary insrc/agents/sessions/session-manager.ts) now also normalizes assistant string content to[{ type: "text", text }]at JSONL parse time, covering providers and transport streams alike. User messages are untouched —UserMessage.contentis legitimatelystring | blocks[]by type.transformMessagesstring branch is kept, not deleted: it is a shipped plugin-SDK surface (src/plugin-sdk/llm.tsexportstransformMessages, published as./plugin-sdk/llm), so external provider adapters may legally pass string assistant content. Its comment now names that contract instead of the stale JSONL-replay claim, and the oldas unknown as stringdouble-cast is gone in favor of real narrowing.anthropic-payload-policy.tsstring handling was inspected and deliberately left alone: it normalizes outbound Anthropic wire payloads (where string content is valid API shape) for the transport stream, cache-control wrappers, andplugin-sdk/provider-stream-shared— a wire-format contract, not replay defense.Coverage map verified before deciding: all six
transformMessagescallers (anthropic, openai-completions, openai-responses-shared, google-shared, mistral, amazon-bedrock), live-runner assistant construction (always block arrays), the normalized JSONL replay path, and CLI/foreign transcript readers.User Impact
Evidence
src/agents/sessions/session-manager.tool-result-replay.test.ts; existing raw-entry assertions updated to the canonical normalized shape (disk bytes still asserted unchanged).node scripts/run-vitest.mjs src/agents/sessions/session-manager.tool-result-replay.test.ts src/agents/sessions/session-manager.test.ts— 52 tests passing.node scripts/run-tsgo.mjs -p tsconfig.core.jsonand-p test/tsconfig/tsconfig.core.test.json— both green.node scripts/run-oxlint.mjson touched files — clean.