fix(agents): serialize structured non-image tool-result blocks in extractToolResultText (fixes #97267)#97276
Conversation
…ractToolResultText (openclaw#97267) extractToolResultText only collected explicit text content blocks. When a tool result contained only structured non-image blocks (json, resource, etc.), it returned undefined — causing the tool result to collapse to an attachment placeholder in the visible transcript. Add a fallback that serializes structured non-image blocks via JSON.stringify when no text blocks are present. Text and image blocks are skipped in the fallback; images remain handled by media delivery, and text blocks are returned as before.
|
Codex review: needs real behavior proof before merge. Reviewed June 27, 2026, 2:44 PM ET / 18:44 UTC. Summary PR surface: Source +27, Tests +64. Total +91 across 2 files. Reproducibility: yes. at source level: current Review metrics: none identified. 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:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one narrow helper-boundary fix after redacted rebuilt-session proof, preferably the smaller branch if maintainers choose it, then let the linked issue close on merge. Do we have a high-confidence way to reproduce the issue? Yes at source level: current Is this the best way to solve the issue? Yes for the code shape after the cap follow-up: the helper boundary is narrow and preserves existing text and image behavior. It is not merge-ready until real behavior proof is added and maintainers choose it over the same-root sibling PR. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ebf1ba70d590. Label changesLabel justifications:
Evidence reviewedPR surface: Source +27, Tests +64. Total +91 across 2 files. View PR surface stats
Acceptance criteria:
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
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…penclaw#97267) Preserve the existing TOOL_RESULT_MAX_CHARS truncation invariant in the new structured-block JSON serialization fallback path. ClawSweeper review noted the path was added without cap coverage.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Superseded by #97268, which landed in Both PRs address #97267 in Focused proof on the prepared head passed 159 tests, a direct helper probe, clean final autoreview, and exact-head CI run 28317871184. Closing this same-root alternative so the cluster has one canonical implementation. |
What Problem This Solves
Fixes #97267.
extractToolResultTextonly collected explicittextcontent blocks from tool results. When a tool result contained only structured non-image blocks (JSON, resource, etc.), it returnedundefined— causing the tool result to collapse to an attachment placeholder in the visible transcript.Changes Made
src/agents/embedded-agent-subscribe.tools.ts: Added a structured-block fallback insideextractToolResultText. When no text blocks are present, the fallback serializes structured non-image blocks viaJSON.stringify.textandimageblocks are skipped in the fallback: images remain handled by media delivery, and text blocks already returned directly.src/agents/embedded-agent-subscribe.tools.test.ts: Added 5 focused tests covering structured fallback, image skip, mixed text+structured separation, and edge cases.Evidence
node scripts/run-vitest.mjs run src/agents/embedded-agent-subscribe.tools.test.ts— 56/56 passednpx oxlint --tsconfig tsconfig.json src/agents/embedded-agent-subscribe.tools.ts src/agents/embedded-agent-subscribe.tools.test.ts— cleanTest coverage
What was not tested: Live end-to-end tool subscription path (fix is in the shared
extractToolResultTextutility, unit-level verification suffices).AI Assistance 🤖