[AI-assisted] fix(agents): normalize malformed assistant content#82748
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Real behavior proof Next step before merge Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9f112a1a7a40. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
745ea7a to
7dd55c6
Compare
7dd55c6 to
608fa05
Compare
c67d031 to
fcd4895
Compare
|
Verification for head fcd4895: Behavior addressed: malformed assistant replay content shaped as a single object or null is normalized before transport conversion, and zero-usage empty/null stop turns still get the replay sentinel instead of regressing to silent empty content.
|
Summary
contentreplayed from provider/session history can be an object ornull, then reach transport conversion code that expects iterable content and fail withv.content is not iterable.null/other malformed non-array shapes to[]; transport conversion also has a final defensive guard for malformed assistant content.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
normalizeAssistantReplayContent -> transformTransportMessagespath; object-shaped assistant content is preserved as one content block;null/other malformed non-array content becomes an empty content array; the transport conversion path completes without the iterable crash.Root Cause (if applicable)
contentwas already iterable.Regression Test Plan (if applicable)
src/agents/pi-embedded-runner/replay-history.test.tssrc/agents/transport-message-transform.test.tsnullassistant content is normalized to[]; transport conversion keeps valid arrays and guards malformed non-arrays.User-visible / Behavior Changes
No intended change for valid messages. Malformed assistant replay/provider content is normalized instead of crashing transport conversion.
Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/A.Repro + Verification
Environment
Steps
pnpm check:changedandgit diff --check.Expected
Actual
check:changedandgit diff --check.Evidence
Human Verification (required)
What I personally verified:
nullassistant content through a non-test runtime proof that imports the real replay and transport functions; valid array content, valid string content, and direct transport conversion through focused regression tests.null/other malformed shapes become[]; existing string/array behavior remains covered.Review Conversations
N/A - no review conversations yet.
Compatibility / Migration
Yes)No)No)Risks and Mitigations