fix(agents): preserve assistant text and use currentAttemptAssistant for incomplete-turn check#93805
fix(agents): preserve assistant text and use currentAttemptAssistant for incomplete-turn check#93805LiuwqGit wants to merge 1 commit into
Conversation
…for incomplete-turn check Bug 1: resolveIncompleteTurnPayloadText now uses currentAttemptAssistant as the authoritative source for the toolUse stopReason check, avoiding stale lastAssistant snapshots that silently discard the final answer. Bug 2: The incomplete-turn return path in runEmbeddedAgent now includes collected assistantTexts as non-error payloads alongside the warning, so the user's real output is never silently discarded. Fixes openclaw#80918
|
ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed June 16, 2026, 8:00 PM ET / 00:00 UTC. Summary PR surface: Source +12, Tests +3. Total +15 across 3 files. Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict. Risk before merge
Maintainer options:
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. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against f7d96c9301d1. Evidence reviewedPR surface: Source +12, Tests +3. Total +15 across 3 files. View PR surface stats
What I checked:
Likely related people:
How this review workflow works
|
|
Closing this PR because the proposed delivery change violates the existing incomplete-turn safety contract: it promotes pre-tool assistant narration into successful output even when the post-tool response never arrived. Current The narrower |
Summary
What problem does this PR solve?
When an agent's last tool call is
update_plan(or any tool with empty/no-op result), and the model then produces a final plain-text turn withstopReason="stop", three cascading bugs cause a silent send miss:resolveIncompleteTurnPayloadTextreads stalelastAssistant.stopReason === "toolUse"instead of the actual final assistant messageassistantTextsand returns only the error warningWhy does this matter now?
This fires for any agent following checklist discipline (closing tasks with
update_plan), which is the default behavior pattern, not an edge case. Impact is HIGH — silent data loss with no observability signal.What is the intended outcome?
currentAttemptAssistantas the authoritative source forstopReason, avoiding stale snapshotsWhat is intentionally out of scope?
delivery-queue/failed/logging,openclaw recover --run-id)What does success look like?
The
assistantTextscollected during the run are included as non-error payloads before the warning text, so even if the incomplete-turn classification is a false positive, the user still receives their content.What should reviewers focus on?
The
currentAttemptAssistant ?? lastAssistantresolution inresolveIncompleteTurnPayloadText: this is the fix for the stale snapshot. Verify it does not suppress legitimate incomplete-turn detection for the original#76477use case (interrupted tool chain with genuinely missing final text).Linked context
Which issue does this close?
Closes #80918
Which issues, PRs, or discussions are related?
Related #76477
Was this requested by a maintainer or owner?
No — contributor-identified and self-fixed.
Real behavior proof (required for external PRs)
lastAssistantsnapshot afterupdate_plantool call{ "test": "src/agents/embedded-agent-runner/run.incomplete-turn.test.ts", "result": "116 passed", "key_change": "payloads[0] is now assistantText (isError=false), payloads[1] is warning (isError=true)" }assistantTextsas deliverable non-error payloads before the warning. The classifier usescurrentAttemptAssistantfor thestopReasoncheck.trace.artifactsshowingdidSendViaMessagingTool=falseandmessagingToolSentTexts=[]Tests and validation
Which commands did you run?
What regression coverage was added or updated?
Updated existing test: "emits incomplete-turn warning when tool-use assistant dropped final text" now asserts that
assistantTexts[0]appears as payload[0] (isError=false) before the warning at payload[1] (isError=true).What failed before this fix, if known?
The test previously expected
payloads[0].isError === true. Now it expects the assistant text payload first, reflecting the fix.Risk checklist
Did user-visible behavior change? (
Yes/No)Yes — users now receive their agent's final answer instead of silence when the incomplete-turn classifier fires after a tool-use stop reason.
Did config, environment, or migration behavior change? (
Yes/No)No
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)No
What is the highest-risk area?
False-negative risk: if a truly incomplete turn now delivers partial text alongside the warning, users might see preliminary analysis. The warning text still clearly indicates the turn was classified as incomplete.
How is that risk mitigated?
currentAttemptAssistantresolution only changes behavior when the final message hasstopReason="stop"— genuinely interrupted tool chains still havestopReason="toolUse"and are unaffectedCurrent review state
What is the next action?
Wait for CI to complete; then maintainer review.
What is still waiting on author, maintainer, CI, or external proof?
Which bot or reviewer comments were addressed?
N/A — first submission