Repository navigation
fix(agents): Astra answer dropped for a generic warning when its follow-up is NO_REPLY - #164774
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 10:22 AM ET / 14:22 UTC (Revision 20). ClawSweeper reviewWhat this changesThe PR preserves completed agent answers after empty or NO_REPLY follow-ups, prevents duplicate streamed delivery, and carries the retained answer through finalization and subagent announcements. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. The pinned patch has no remaining actionable findings, and the matching exact-head live evidence supports its intended behavior. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw's built-in agent runtime turns model responses and tool results into channel replies. Its subscriber records answer boundaries, which finalization and delivery consume to select and send the user's answer. flowchart TD
A[Model response] --> B[Async tool splitting]
B --> C[Answer subscriber]
D[Tool results and follow-up] --> C
C --> E{Follow-up adds an outcome?}
E -->|No| F[Retain completed answer]
E -->|Yes| G[Use newer outcome]
F --> H[Finalization and channel delivery]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +113, Tests +664. Total +777 across 19 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one subscriber-owned answer decision across payload selection, finalization, and delivery, with later substantive outcomes retaining supersession precedence. Do we have a high-confidence way to reproduce the issue? Yes: async tool calls followed by a completed answer and a NO_REPLY continuation establish a concrete failing path in current source, backed by reported live baseline runs. This review did not execute it. Is this the best way to solve the issue? Yes: the patch repairs response classification and uses the existing subscriber as the answer owner, while preserving tool continuation and later-answer supersession. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 15e6a60139df. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (19 earlier review cycles; latest 8 shown)
|
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
… retries The subscriber now records once, at message_end, whether a NO_REPLY or empty terminal keeps the input's completed answer. Payloads and the terminal snapshot (finalAssistantVisibleText/RawText, terminalReply for subagents and A2A) consume that fact instead of re-parsing the terminal. The input's answer survives an in-attempt overflow compaction retry and is carried into run-loop retry attempts, which continue the transcript after it.
…not a silent stop
Remove the cross-attempt carryover of the input's answer (createAttemptCarryover, dispatch input, initialInputAnswer, subscriber seed). A compaction retry clears the answer again, so retries behave as on main. Within one attempt the subscriber stays the single owner of keptAnswer.
A kept answer no longer regenerates its reasoning in the final payloads; the reasoning was already emitted at its own message_end. The keep rule also reads the stored audioAsVoice fact, so a voice NO_REPLY that persistence normalized before the subscriber still supersedes the earlier answer.
… message Block replies now record their physical message start, and final-payload dedupe walks per-item indexes only back to that start. An unsent answer of a later message is no longer covered by an earlier message's delivered text.
Hidden commentary takes a per-item index without a block, so the joined-answer dedupe stopped at that gap and re-sent a streamed answer. Runs now skip empty indexes down to the physical message start.
Hidden commentary after the answer rotated the text baseline, so message_end re-added the answer under the commentary's index. The final reply then missed the streamed blocks and sent the answer twice. message_end now treats the last visible item as recorded, and a kept answer takes its last recorded text index.
… later NO_REPLY A completed silent attachment or speech cleared only the kept answer, so a later plain NO_REPLY restored the superseded text answer. Any response end that adds its own outcome now clears the input's earlier answer.
…later NO_REPLY Only a stop could replace the input's earlier answer, so a length-limited attachment left it in place and a later NO_REPLY restored it. Every outcome except tool-call progress and an interim stop now supersedes it.
25dc7e4 to
69b4a7b
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…n recovery and before_agent_finalize
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed as 83e6cb9. Checked on the exact head 9756e05: fresh gpt-6-astra reviewer LAND, ClawSweeper ready, live Telegram E2E in the body. Admin merge past one inherited red: |
…ow-up is NO_REPLY (openclaw#164774) When a split OpenAI Responses response ends in a call-free final answer, that fragment ends with stop. If the turn then ends in NO_REPLY or empty, the completed answer is kept and delivered once instead of the "couldn't generate a response" warning; subagent/A2A terminal snapshots carry the same answer. Also fixes duplicate block delivery for multi-item answers with trailing commentary.
…ow-up is NO_REPLY (#164774) When a split OpenAI Responses response ends in a call-free final answer, that fragment ends with stop. If the turn then ends in NO_REPLY or empty, the completed answer is kept and delivered once instead of the "couldn't generate a response" warning; subagent/A2A terminal snapshots carry the same answer. Also fixes duplicate block delivery for multi-item answers with trailing commentary. (cherry picked from commit 83e6cb9)
What Problem This Solves
With GPT-6 Astra async tools, an answer the model had already finished was dropped. The user got "⚠️ Agent couldn't generate a response. Note: some tool actions may have already been executed" instead.
This happened on our setup (Telegram,
openai/gpt-6-astraoveropenai-responses). One model response emitted asyncweb_search/web_fetchcalls and then afinal_answermessage with the full answer. OpenClaw sent the async results in a follow-up request, the model repliedNO_REPLY("nothing to add"), and the answer never reached Telegram.User Impact
An answer the model finished is delivered exactly once, even when the model's follow-up after the async results is
NO_REPLYor empty. There are no new messages, notices, or settings. A later answer still replaces the earlier one, a later attachment, voice reply or cut-off response still supersedes it, a repeated answer is sent once, text written before or alongside a tool call stays silent, and quiet mode stays quiet. Responses that end in twofinal_answeritems, or in an answer followed by hidden commentary, are no longer re-sent after their streamed blocks.Root cause (with provenance)
Stop reason (agent-core). The Responses transport maps a completed response that contains any call to
toolUse(packages/ai/src/transports/openai-responses-stream-internal.ts:690-695). The async splitter (feat(openai): support Astra async tools, steering, and effort updates #138046) commits each call as its owntoolUsefragment (packages/agent-core/src/agent-stream-response.ts:347-373), and the call-free tail inherited the whole-responsetoolUse(:400-412). The tail now getsstop. The loop still continues because of the executed calls (agent-loop.ts:325-330), so the results still reach the model.One owner for the kept answer, within one attempt.
buildEmbeddedRunPayloadstreats the input's last assistant message as the answer (Telegram direct replies can duplicate because accumulated assistantTexts are emitted as separate messages after context-engine maintenance #79621) and honors a silent one (fix(agents): deliver one answer per steered user input #149925). The subscriber (handleMessageEnd) now records, once per message:inputAnswer, the input's latest answer that ended its response (stop, notendTurn: false, visible, not silent), andkeptAnswer, that answer while the latest assistant message is aNO_REPLYor empty stop with no media, voice (parsed or already stored by persistence) or TTS. Every other assistant message clearskeptAnswer. Any other outcome except tool-call progress and an interimendTurn: falsestop (a silent attachment, speech, a cut-offlengthresponse) also clearsinputAnswer, so a laterNO_REPLYcannot bring back a superseded answer. A new user input and a compaction retry clear both. Consumers:payloads.tsuseskeptAnswerfor the answer lane and its message index. Reasoning still comes from the terminal message, because the kept answer's reasoning was already emitted at its ownmessage_end.terminal-preparation.tsderivesfinalAssistantVisibleText/RawText(and soterminalReplyfor subagent announce, A2A and run-wait) fromkeptAnswer ?? terminal.This mirrors
src/agents/AGENTS.md"Source Reply Completion" (afinal: falsesend becomes the reply when the terminal response is empty orNO_REPLY).Warning. With zero payloads and a required reply, the incomplete-turn path posted the generic warning (
reply-completion.ts:52-59,incomplete-turn-resolution.ts). With the answer in the payloads that path is not reached. It is unchanged for turns that have no answer.Dedupe. The subscriber streams each Responses text item under its own
assistantMessageIndex, but a message's final payload joins every item under the last index, soblock-reply-pipeline.tsfailed to match a two-item answer against its streamed blocks and sent it again. This was already true on base for plain two-final_answerresponses with block streaming on. Block replies now record their physical message start (assistantMessageStartIndex), andmatchingAttemptsmatches item runs ending at the payload's index, bounded by that start and skipping the indexes of hidden commentary items, so another message's delivered text never covers an unsent answer.Trailing commentary. Each streamed item rotates the subscriber's text baseline. When hidden commentary followed the answer in the same message,
message_endsaw no text "added during the message" and re-added the answer under the commentary's index; the final payload then missed the streamed blocks and the answer was sent twice. This also happens on base for a plain terminal[final_answer, commentary]response.message_endnow treats the last visible item as already recorded, and the kept answer takes its last recorded text index, the same index the terminal reply uses.Sub-agent announce hydration. The parent's announcement re-reads the child's answer from the latest
visible-finaltranscript row of the run (readSubagentRunAnnounceResultUsing→isVisibleAssistantResultEventForRun,src/sessions/transcript-visible-record.ts). That classifier accepted anendTurn: falseinterim stop, so after [async-tail answer, interim progress,NO_REPLY] the parent got the progress text instead of the kept answer. The classifier now rejectsendTurn: falserows, the same rule as the subscriber andattempt-decision-context.ts. Its only production readers are sub-agent announce (live session and the deletion-archive fallback); history views useisVisibleTranscriptRecord, and run-wait and A2A read theterminalReplysnapshot, so neither changes.resolveTerminalAssistantTranscriptRunIdis left as is: its transcript-updaterunId(narration, chat dedupe, abort identity) and the aborted-partial check must keep attributing the last interim row of a run aborted mid-continuation.Design decision: A (this PR) vs B (end the turn at
final_answer)final_answerand carry the async results to the next turn. Rejected on evidence. Codex does not do this. Any tool call setsneeds_follow_upand the turn samples again (../codexc248f6d48b:codex-rs/core/src/stream_events_utils.rs:356,session/turn.rs:2780,566,653). Codex's next-turn deferral (stream_events_utils.rs:122-135,session/input_queue.rs:275-296) applies only to inter-agent mailbox mail. A tool call even re-accepts mail for the current turn (stream_events_utils.rs:332-338). OpenClaw also has no late async results to carry: agent-core awaits every async execution before the response ends (agent-stream-response.ts:425).sessions_yieldrequires earlier async results to reach a follow-up request ("Finish this response to receive them", fix(agents): recover yielded subagents and preserve sidebar nesting #146667/fix(agents): report deferred sessions_yield as a normal outcome #149983). B would hide tool results and failures from the model until the user writes again.stream_events_utils.rs:383-397). That is why the model'sfinal_answershould not be lost to a laterNO_REPLY.Evidence
Live runs: Telegram Test Server DM, real
gpt-6-astra, isolated gateway state; a logging HTTPS proxy in front ofapi.openai.comonly forwarded and logged (no shaping). Same prompt both times: fetch example.com, answer in the same response without waiting, replyNO_REPLYif the fetch confirms it.origin/maina6b9da2bdee). Request 2 returned[function_call tool_search, web_search_call, function_call tool_call(web_fetch), message:final_answer "It is almost certainly the IANA “Example Domain” placeholder page used in documentation…"]; request 5 returnedNO_REPLY. Telegram: progress draft, then "incomplete turn detected … payloads=0.4d86dd72d77b, rerun on164e94c7cc68). Request 2 had the same shape and request 5 wasNO_REPLY. Telegram: progress draft, then one bot message "It is almost certainly the IANA “Example Domain” placeholder page used in documentation. The page says it is for documentation examples. (example.com)", then the draft was deleted. No warning, 0incomplete turnlog lines. The later commits changehandleMessageEnddecisions only when hidden commentary follows the answer in its message, or when a non-tool, non-interim message adds an outcome other than an answer (attachment, speech, cut-off). The live sequence (call fragments, thefinal_answertail as the last item, thenNO_REPLY) contains neither; an instrumented run of the matching table row showed the same text-baseline and index decisions as164e94c.embedded-agent-subscribe.subscribe-embedded-agent-session.final-answer-delivery.test.ts, "Astra async response tails"): real Responses wire events →processResponsesStream→runAgentLoopasync splitting → subscriber → real block-reply handler and pipeline →prepareEmbeddedRunTerminal→buildReplyPayloads, asserting what the user receives and theterminalReplysnapshot:NO_REPLYfollow-up: answer delivered once (deferred delivery; heartbeat with block streaming off);terminalReplyvisible. Fails on base.NO_REPLY, under live block streaming: sent once. The terminal variant also fails on base.NO_REPLYthat persistence normalized before the subscriber supersedes.max_output_tokens, followed by another async round andNO_REPLY: only the attachment is delivered and the terminal reply is silent, the same as on base.NO_REPLY, and anend_turn:falseinterim stop plusNO_REPLY, stay silent.end_turn:falseinterim stop, thenNO_REPLY: the answer is delivered once, and the sub-agent announcement hydrated from the run's persisted rows (realreadSubagentRunAnnounceResultUsingandmatchesTranscriptEvent) carries the answer, not the progress. Fails on031ad79.message_tool_only) stays private.NO_REPLY.block-reply-pipeline.multi-message.test.ts: an unsent later message's answer that matches an earlier delivered message is still delivered.pnpm tsgo:coreandpnpm tsgo:core:testpass. Focused suites pass:src/agents/embedded-agent-subscribe*(479 agents-core + the unit shards),src/agents/embedded-agent-runner/(all shards),src/auto-reply/reply/(all shards),packages/agent-core/src(276). The only red is 2auth-controller.test.tsOAuth cases, which fail identically on this PR's base8a0b0c458bbdand pass on currentorigin/main(unrelated to this diff).25dc7e4:pnpm tsgo:coreandpnpm tsgo:core:testpass; the final-answer delivery table,src/agents/subagents/announce/,src/sessions/transcript-events.test.ts,session-transcript-match.worker.test.tsandsession-accessor.sqlite-archive-read.test.tspass (32 files, 528 tests).pnpm test <file> --maxWorkers=1, local): the final-answer delivery file (35 tests) about 18 s, mostly transform (tests about 2 s);block-reply-pipeline.multi-message.test.ts(6 tests) about 16 s, nearly all transform.Rebased head 9756e05 re-run
Head
9756e0514426: clean worktree,git rev-parse HEADanddist/build-info.jsonmatch, built withscripts/build-all.mts. Base comparison: merge base7de09d5a2337, built the same way, with build-info matching. Each run used a fresh isolated gateway on built dist, the Telegram Test Server, and realgpt-6-astra. A logging HTTPS proxy in front ofapi.openai.comonly forwarded and logged.[function_call tool_search, web_search_call, function_call tool_call(web_fetch), message:final_answer "It is almost certainly the IANA “Example Domain” placeholder page used in documentation…"]. Request 5 returnedNO_REPLY. Telegram: progress draft, then one bot message at +14.7 s, "It is almost certainly the IANA “Example Domain” placeholder page used in documentation. The page identifies itself as intended for documentation examples. (example.com)", then the draft was deleted. No warning. Gateway log has 0incomplete turn, 0settled post-tool turn lacked a final answerand 0before_agent_finalizelines. First attempt.NO_REPLY, DM ("Reply with exactly NO_REPLY and nothing else."). Request 2 returnedNO_REPLY. The empty-response retry ran once, and the retry also returnedNO_REPLY. Telegram showed "7de09d5a2337does the same with the same prompt: twoNO_REPLYrequests, the sameempty response detected→incomplete turn detected … payloads=0 tools=0lines, and the same warning. A user DM turn requires a reply, so this is not a regression.messages.groupChat.unmentionedInbound: "room_event", where a reply is optional). One request returnedNO_REPLY. There was no retry and no warning, and the bot produced no Telegram events at all. 0incomplete turnlines.messages.visibleReplies: "message_tool", prompt asking for step narration). The model wrote 4messagetool sends (3 short step notes and the summary), then onemessageedit, and everyfinal_answerwas empty. Telegram showed exactly those 4 messages and the edit, plus the tool-progress draft, which was deleted. No commentary or answer text was sent outside the message tool.final_answerafter the two fetch calls. Request 5 returned a different final summary. Telegram: progress draft, then exactly one bot message (the request-5 summary), then the draft was deleted. The earlier tail answer was superseded as documented. 0incomplete turnlines.The earlier live proof stays valid. The rebase was clean, and the only behavior change since (
9756e051, below) applies only when the subscriber kept an answer. Run 1 confirms the incident path on the exact head.Regressions added in
9756e051(embedded-agent-subscribe.astra-async-tails.test.ts; the PR's Astra suite moved here fromfinal-answer-delivery.test.tsfor the test-file line cap):resolveSettledTurnFinalizationRequestwith the subscription's realtoolMetasand item lifecycle. For "a later NO_REPLY keeps the completed answer" (deferred, required user turn), it requested isolated finalization before the fix, which could replace the kept answer. Fails on69b4a7b8.onBeforeTerminalDeliveryinput, whichbefore_agent_finalizeprojects intolastAssistantMessage, now carries the delivered answer. Three rows gotNO_REPLYbefore the fix. Fails on69b4a7b8.Bounded cost
message_end. Block-dedupe run matching walks only the indexes of one physical message. No new requests, storage, or settings.4d86dd7and on164e94c), each with 2gpt-6-astrarequests, 2gpt-5.6-lunautility requests and a few embedding requests.Not changed / deferred
NO_REPLY, behaves exactly asorigin/main(maintainer decision: cross-attempt retries are deferred). An in-session retry resets the subscriber's answer state (origin/mainf0a63179594:src/agents/embedded-agent-subscribe.ts:248-261, called fromembedded-agent-subscribe.handlers.compaction.ts:171; this PR clearsinputAnswer/keptAnswerthere too,src/agents/embedded-agent-subscribe.ts:261-262), and a run-loop retry starts a fresh subscriber (src/agents/embedded-agent-runner/run/attempt-stream-prepare.ts:328). A cross-attempt carryover was tried and removed; it also carried message indexes across attempts that restart at 0.stop), andpayloads.ts(lastAssistantNeedsErrorSurface,origin/mainpayloads.ts:167) skips the answer block.NO_REPLY… including normal-stop tails of async responses"). We saw this a second time on our setup: a tail answer with a link, followed by more tool work and a new answer written as if the first had been seen; only the second was delivered. The trade-off is written up in the dependent draft fix(agents): deliver final answers that end a response before more same-input work #164803.src/auto-reply/heartbeat-reply-payload.ts:30-42).message_tool_onlywith no message-tool send, a substantive kept answer reaches the existing stranded-reply one-shot retry, the same as that answer as a terminal.Review
Earlier heads: several BLOCK rounds; fixes include silent terminal media superseding, the two-item dedupe, the
end_turn:falseinterim stop, subagent/A2A terminal snapshots, and commentary clearing the kept answer.Fresh reviewers, exact heads:
2076441BLOCK (reasoning replayed with a kept answer; stored voice intent missed) → fixed in211f30c;211f30cBLOCK (joined-answer dedupe crossed physical messages) → fixed in4d86dd7;4d86dd7LAND, no findings, plus two extra passes (delivery/duplicates/quiet mode across Telegram, Slack, Web UI, subagent/A2A; stop-reason mapping and Codex parity), both LAND.ClawSweeper on
4d86dd7: hidden commentary between two answer items broke the dedupe walk → fixed in164e94c.164e94cBLOCK (commentary trailing the answer sent it twice) → root cause fixed in2a7e56f;2a7e56fBLOCK (a silent attachment did not supersede the earlier answer for a laterNO_REPLY) → fixed inb1885b4;b1885b4BLOCK (same, for alengthresponse) → fixed in031ad79;031ad79LAND-WITH-CHANGES (announce hydration pickedendTurn:falseprogress) → fixed in25dc7e4.Rebased onto
main7de09d5a2337with no conflicts. A fresh review at69b4a7b8returned BLOCK with two findings, both fixed in9756e051:countSettledTurnDeliveryPayloads) didn't count a kept answer that precedes the last tool result, so a deferred required turn could run isolated finalization over it. A kept answer now counts as the turn's composed answer.before_agent_finalizesaw the terminalNO_REPLYinstead of the kept answer it delivers.handleAgentEndnow passes the kept answer aslastAssistant.Fresh review at
9756e051: LAND, no findings.CI:
checks-node-changed-compact-large-22fails only insrc/agents/embedded-agent-runner/run.plugin-runtime-refresh.integration.test.ts("real workspace consumer was exercised: expected 0 to be greater than 0"). The same file fails the same way locally on cleanorigin/main7de09d5a233. This PR does not touch it or its workspace/plugin-metadata path.LOC vs merge base
7de09d5a2337: production +131/−18; tests and test support +664/−0.