Repository navigation
Description
Summary
In a fallback run using an OpenAI/Codex-style CLI backend with output: "jsonl", OpenClaw can surface commentary/intermediate text instead of the terminal answer.
This looks adjacent to the broader “text between tool calls leaks to messaging channels” issue family, but narrower: in the captured fallback run, the JSONL stream already contained explicit phase markers plus a terminal task_complete.last_agent_message. The failure appears to be that the CLI JSONL parser loses those semantics and collapses the wrong text into the outbound reply.
Why this seems distinct from #25592
#25592 and related reports describe intermediate assistant text leaking from normal multi-turn tool loops.
In this case, the captured fallback JSONL already distinguishes:
phase: "commentary"phase: "final_answer"- terminal
task_complete.last_agent_message
So the problem here seems to be later in the pipeline: the CLI JSONL parser for fallback delivery is not preferring the terminal fields and can therefore surface commentary instead of the final answer.
Verified on
- OpenClaw
2026.4.2 (d74a122) - npm-installed build on macOS arm64
- Channel: WhatsApp DM
- Trigger path: primary model stalled after a tool result, then fallback switched to an OpenAI CLI backend configured with
output: "jsonl"
Observed chain
- Primary model started normally and made one tool call.
- The tool result came back.
- The primary model then stalled and OpenClaw recorded
LLM idle timeout (60s): no response from model. - Fallback switched to an OpenAI CLI backend with
output: "jsonl". - The fallback run itself completed successfully.
- User-visible delivery surfaced commentary/intermediate text instead of the final answer.
Important evidence
The captured fallback JSONL already had a clean separation between commentary and final answer. Sanitized shape:
{"type":"event_msg","payload":{"type":"agent_message","phase":"commentary","message":"..."}}
{"type":"response_item","payload":{"type":"message","role":"assistant","phase":"commentary","content":[{"type":"output_text","text":"..."}]}}
{"type":"event_msg","payload":{"type":"agent_message","phase":"final_answer","message":"..."}}
{"type":"response_item","payload":{"type":"message","role":"assistant","phase":"final_answer","content":[{"type":"output_text","text":"..."}]}}
{"type":"event_msg","payload":{"type":"task_complete","last_agent_message":"..."}}So the terminal answer was already present twice:
- as an assistant message tagged
phase: "final_answer" - as
task_complete.last_agent_message
Current parser gap
In the shipped 2026.4.2 build, the CLI JSONL parsing path still appears to:
- special-case Claude CLI
type: "result"lines - otherwise fall back to collecting generic text from parsed items
- not prefer
task_complete.last_agent_message - not prefer assistant messages tagged
phase: "final_answer" - not ignore
phase: "commentary"for outbound user delivery
I realize that statement is based on inspection of the installed npm dist build rather than the TypeScript source tree, but it matches the observed runtime behavior on 2026.4.2.
Expected behavior
For JSONL-style CLI backends used as user-visible fallbacks:
- Prefer
task_complete.last_agent_messagewhen present. - Otherwise prefer assistant messages explicitly tagged
phase: "final_answer". - Ignore
phase: "commentary"for outbound user delivery. - Preserve current Claude CLI handling separately if needed.
Related
- Related to Text between tool calls leaks to messaging channels #25592, but narrower: this looks like phase-loss in the CLI fallback JSONL parser rather than generic inter-tool narration leakage.
- Agents: suppress block reply delivery for intermediate tool-call messages #25659 is also related, but it targets streaming/block reply delivery for intermediate tool-call messages.
- feat(agents): add replyMode tool-only to suppress auto-delivery #57914 (
replyMode: "tool-only") also does not solve this path; its author already noted that it does not fixcommentary/ raw-wire-format leaks.
Happy to test a patch build if maintainers want a real-world confirmation case.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
mySebbe commentedon Apr 2, 2026
Opened a matching PR for this parser path: #59920
Scope is intentionally narrow:
src/agents/cli-output.tssrc/agents/cli-output.test.tsThe patch prefers
task_complete.last_agent_message, thenphase:"final_answer", and skipscommentarytext for the generic fallback path.Verified locally with:
pnpm exec vitest run src/agents/cli-output.test.ts src/agents/cli-backends.test.tspnpm checkduring commitIf maintainers want, I can also attach a sanitized real-world JSONL fixture from the failing fallback shape, but I kept the initial PR test coverage synthetic and minimal on purpose.
clawsweeper commentedon Apr 26, 2026
Closing this as duplicate or superseded after Codex automated review.
#59918 should close as superseded by the matching open PR #59920. Current main does not yet implement the requested parser behavior, but the remaining work is already tracked in the reporter's narrow parser PR.
What I checked:
parseCliJsonl()still only special-cases Claudetype: "result"events and then falls back to genericparsed.item.text; it does not readtask_complete.last_agent_message,phase: "final_answer", or skipphase: "commentary". (src/agents/cli-output.ts:440, b64bfc5d9abf)item.textfor missing/message-like item types, which is the phase-blind behavior described in the issue. (src/agents/cli-output.ts:451, b64bfc5d9abf)parseCliJsonltests cover Claude stream-json result events, empty Claude result metadata, multiple JSON objects on one line, and error extraction, but nottask_complete.last_agent_messageorphase: "final_answer"precedence. (src/agents/cli-output.test.ts:162, b64bfc5d9abf)src/agents/cli-output.tsplus parser regression tests and explicitly says it closes [Bug]: CLI JSONL fallback parser drops final-answer semantics and can surface commentary instead #59918. The PR is open in the provided GitHub context.So I’m closing this here and keeping the remaining discussion on the canonical linked item.
Codex Review notes: model gpt-5.5, reasoning high; reviewed against b64bfc5d9abf.