Repository navigation
Description
Summary
When the active model returns assistant content as phase-tagged text blocks (type: "text" with textSignature.phase), buildEmbeddedRunPayloads ships the raw streamed assistantTexts to channel-delivery payloads, which includes the commentary phase blocks. The final_answer-only filter (extractAssistantVisibleText) is only consulted as a fallback when streaming captured nothing.
End-user impact: reasoning summaries ("Need answer. Current? ...", "Responding to user's food list...") get delivered to iMessage / Telegram / etc. alongside or instead of the final reply.
Version: 2026.5.7. Provider: openai-codex/gpt-5.5 via OAuth. The same issue would affect any provider whose responses include textSignature.phase blocks.
Reproduction
- Configure an agent with
model: "openai-codex/gpt-5.5"(or any other provider that returns phase-tagged blocks). - Send a non-trivial question (one that elicits some internal reasoning).
- Observe the channel-delivered reply (iMessage / Telegram / etc).
The delivered text frequently contains both a commentary-phase preamble and the final_answer. Sometimes only the commentary if the run terminated before final_answer was emitted.
An openclaw agent --json probe of the same agent + session is clean, because result.payloads[*].text comes from a separate construction path that already calls extractAssistantVisibleText correctly. So the bug isn't visible from CLI testing — only from real channel delivery.
Root cause
dist/pi-embedded-Bcz04p2i.js, function buildEmbeddedRunPayloads (around line 1346 in 2026.5.7):
const answerTexts = suppressAssistantArtifacts ? [] : (
shouldPreferRawAnswerText && fallbackRawAnswerText ? [fallbackRawAnswerText]
: hasAssistantTextPayload ? nonEmptyAssistantTexts // <-- raw streamed chunks, includes commentary
: fallbackAnswerText ? [fallbackAnswerText] // <-- phase-filtered, only used as fallback
: []
).filter((text) => !shouldSuppressRawErrorText(text));nonEmptyAssistantTexts is params.assistantTexts.filter(...) — the raw streamed chunks the provider emitted during the run. The codex stream doesn't surface textSignature.phase per-chunk, so these contain both phases concatenated.
fallbackAnswerText is extractAssistantVisibleText(params.lastAssistant), which already correctly filters for phase: "final_answer" (or returns the unphased content when no phase tags exist). But it's only used when hasAssistantTextPayload is false — i.e. when streaming was empty, which is rare for non-empty turns.
The filter logic exists elsewhere in the codebase and works:
extractAssistantVisibleText(used by CLI/JSON output path)shouldSuppressAssistantEventForLiveChatinlive-chat-projector(used by TUI display)- The
commentaryenum is documented inprotocol-validatorswith the comment "Classifies an assistant message as interim commentary or final answer text"
The channel-delivery payload builder is just the one place this filter isn't applied.
Suggested fix
When the assistant message has explicit phase metadata, route through the already-phase-filtered fallbackAnswerText instead of the raw stream. Non-phase-tagged providers (Anthropic API, OpenAI API path, etc.) are unaffected because lastAssistantHasPhaseMetadata returns false for them.
const lastAssistantHasPhaseMetadata = (() => {
const c = params.lastAssistant && params.lastAssistant.content;
if (!Array.isArray(c)) return false;
for (const b of c) {
if (!b || b.type !== "text" || !b.textSignature) continue;
try {
const sig = typeof b.textSignature === "string"
? JSON.parse(b.textSignature) : b.textSignature;
if (sig && sig.phase) return true;
} catch (e) {}
}
return false;
})();
const answerTexts = suppressAssistantArtifacts ? [] : (
lastAssistantHasPhaseMetadata && fallbackAnswerText ? [fallbackAnswerText]
: shouldPreferRawAnswerText && fallbackRawAnswerText ? [fallbackRawAnswerText]
: hasAssistantTextPayload ? nonEmptyAssistantTexts
: fallbackAnswerText ? [fallbackAnswerText]
: []
).filter((text) => !shouldSuppressRawErrorText(text));I've been running this patch locally against 2026.5.7 for a few hours without regressions; reasoning-trigger probes and plain conversational turns both deliver only the final_answer block.
Why this matters
Affects every channel-delivered reply on phase-tagging providers — iMessage (BlueBubbles), Telegram, etc. The CLI path being clean made it hard to spot until I started reading session JSONL files and comparing messageContent.content[*].textSignature.phase against what landed in the actual channel.
Happy to open a PR if helpful.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 10, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Close: current main no longer lets a single raw streamed commentary-plus-final assistant text win over the canonical final answer, and the same behavior is present in the v2026.6.6 release.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the current canonical final-answer payload selection and regression coverage; no further OpenClaw core work is needed for this report.
Do we have a high-confidence way to reproduce the issue?
Yes. The historical failure is source-reproducible with one raw streamed
assistantTextsentry containing commentary plus final text and structured assistant blocks carryingcommentaryandfinal_answer; current tests now lock that case down.Is this the best way to solve the issue?
Yes. The current implementation is the better fix because it prefers canonical structured final-answer text before raw accumulated assistant text while preserving existing media-directive behavior.
Security review:
Security review: Non-PR issue triage; no patch security review applies.
AGENTS.md: found and applied where relevant.
What I checked:
buildEmbeddedRunPayloadscomputesfallbackAnswerSourceTextfrom the phase-filtered visible/final assistant answer and selects it beforehasAssistantTextPayload, so raw accumulated assistant text no longer wins in normal successful replies. (src/agents/embedded-agent-runner/run/payloads.ts:479, f1b8827d20c8)assistantTexts: ["Need inspect.\n\nDone."]with structuredcommentaryandfinal_answerblocks and asserts the delivered payload is onlyDone.. (src/agents/embedded-agent-runner/run/payloads.test.ts:123, f1b8827d20c8)src/agents/embedded-agent-runner/run/payloads.ts:484, a15427d605fe)src/agents/pi-embedded-runner/run/payloads.test.ts:119, 6ebe91d92b2a)src/agents/embedded-agent-runner/run/payloads.test.ts:123, 8c802aa68351)MessagePhaseascommentaryfor interim assistant text andfinal_answerfor terminal answer text; its Python SDK result helper also prefersfinal_answerand does not promote commentary-only output. (codex-rs/protocol/src/models.rs:737, dfd03ea01bbe)Likely related people:
src/agents/pi-embedded-runner/run.ts,src/agents/pi-embedded-runner/run/payloads.ts,src/agents/pi-embedded-runner/run/payloads.test.ts)src/agents/pi-embedded-runner/run/payloads.test.ts)src/agents/pi-embedded-runner/run/payloads.ts,src/agents/pi-embedded-runner/run/payloads.test.ts)src/agents/embedded-agent-runner/run/payloads.ts,src/agents/embedded-agent-runner/run/payloads.test.ts)Codex review notes: model internal, reasoning high; reviewed against f1b8827d20c8; fix evidence: release v2026.6.6, commit 8c802aa68351.
fix(channel): filter commentary phase from channel delivery on phase-…
HangGlidersRule commentedon May 27, 2026
Confirming this bug still reproduces on 2026.5.22 (a374c3a) against
openai-responsesprovider pointing at Azure AI Foundry's OpenAI Responses endpoint with gpt-5.5, on Slack channel delivery.Environment
2026.5.22 (a374c3a)(Homebrew global)openai-responsesagainst Azure AI Foundry's OpenAI Responses APIgpt-5.5{ "id": "gpt-5.5", "api": "openai-responses", "reasoning": true, "input": ["text", "image"] }medium(session override; problem also reproduces athigh)streaming.mode:partial(channel-level and global)Reproduction
gpt-5.5via theopenai-responsesprovider against Azure AI Foundry. Reasoning enabled, summaryauto(the OpenClaw transport default).What lands in the channel
A delivered Slack message containing first-person stream-of-consciousness commentary, often in fragmented prose with no markdown formatting, e.g. (real captured leak, redacted secrets and project names):
That is GPT-5.5's commentary-phase content. It's not the model's final answer — the model also emits a real answer in a separate
final_answer-phase block in the same turn. The CLI / agent JSON path delivers only the final_answer; only channel delivery is affected.Session JSONL evidence
In the agent session file, one assistant turn shows up as paired blocks:
type: "thinking"block — Anthropic-style reasoning summary captured fromresponse.reasoning_summary_text.deltaevents (OK — this stays hidden).type: "text"block with atextSignaturecarrying phase metadata, containing the commentary-style prose.When this single text block makes it to channel delivery, the commentary becomes the visible Slack reply.
Root cause confirmation
Source-tracing on the installed dist matches the codex review of 2026-05-10 against
758a5f1eda7f:pi-embedded-CsSFzly6.jsbuildEmbeddedRunPayloads(the function this issue's title references, in 5.22 still in the same shape):extractAssistantVisibleTextcorrectly prefersphase: "final_answer"text blocks when phase metadata is present. ButhasAssistantTextPayloadwins ahead of it whenever there's a single raw streamed entry — which is exactly the GPT-5.5 Responses shape when commentary + final_answer arrive as one streamed block.So when GPT-5.5 streams commentary text then final answer text into the same streamed text payload entry, the payload builder ships the raw streamed text (commentary included) to the channel instead of consulting the phase-filtered
fallbackAnswerText.Why the existing channel-side guards do not catch this
streaming.modeconfig has no effect — the leak happens in payload selection for the final reply, not in the live preview path.pushReasoningProgressearly-returns whenstreamMode !== "progress", so changing streaming mode does not help.stripReasoningTagsFromTextonly strips<thinking>/<think>style XML tags. GPT-5.5 commentary-phase content has no such tags; it's plain prose with phase metadata on the block envelope, not in the text.type: "thinking"block for the same turn is correctly hidden — only the commentary-phasetype: "text"block leaks.redact-thinking-*controls do not apply: commentary is not athinkingblock, it's atextblock.What 5.26 did not fix
5.26 (current
latest) includes reply/perf, transcript, and provider improvements, but no entry that touchesbuildEmbeddedRunPayloadsphase selection. We verified the same code shape remains in the 5.26 dist. The PRs that attempted #80458 fixes (#80491, #82645, #83340) are all closed without merge.Workarounds we tried
compat.supportedReasoningEfforts— only affects effort level routing; doesn't change phase handling.streaming.modebetweenpartial/block/progress— leak persists; onlyoffsuppresses it by removing the streaming path entirely./reasoning off— model still emits commentary because OpenClaw'sopenai-transport-streamalways requestsreasoning.summary: "auto"for any reasoning-capable OpenAI model (options?.reasoningSummary || "auto"is hardcoded), so we get summary blocks regardless of channel display settings.Recommended fix direction (echoing the May 10 review)
In
buildEmbeddedRunPayloads, prefer the phase-filteredfallbackAnswerTextwheneverlastAssistantcontent blocks carry explicit phase metadata, regardless ofnonEmptyAssistantTexts.length. The currentlength > 1guard misses the single-streamed-entry case.Adding regression coverage for:
nonEmptyAssistantTexts.length === 1, single entry containing commentary + final_answer concatenated.lastAssistant.content[*].textSignature.phase === "final_answer"on at least one block.Happy to test a candidate fix against this Slack repro path before any merge.
WarrenJones commentedon May 27, 2026