fix(agents): use currentAttemptAssistant for incomplete-turn classification#94188
Closed
LiuwqGit wants to merge 1 commit into
Closed
fix(agents): use currentAttemptAssistant for incomplete-turn classification#94188LiuwqGit wants to merge 1 commit into
LiuwqGit wants to merge 1 commit into
Conversation
Contributor
Author
|
@openclaw-barnacle rerun |
Contributor
Author
|
The CI |
LiuwqGit
force-pushed
the
fix/issue-80918-stale-last-assistant
branch
from
June 17, 2026 23:48
8345f31 to
d75fda7
Compare
…cation Fixes openclaw#80918 The stale lastAssistant snapshot (stopReason=toolUse from update_plan turn) caused isIncompleteTerminalAssistantTurn to false-positive even when a fresh currentAttemptAssistant with stopReason=stop existed. Use the already-resolved 'assistant' variable (which prefers currentAttemptAssistant over lastAssistant) for the final incomplete-turn check instead of hard-coding lastAssistant.
LiuwqGit
force-pushed
the
fix/issue-80918-stale-last-assistant
branch
from
June 17, 2026 23:51
d75fda7 to
41ae480
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
update_plan(stopReason=toolUse) and the model then produces a final plain-text turn with stopReason=stop,resolveIncompleteTurnPayloadTextincorrectly classifies the turn as incomplete because it checkslastAssistant.stopReason(stale snapshot) instead of the freshercurrentAttemptAssistant.update_planclosure) triggers this on every run.isDeliverablePayload,assistantTextsincomplete branch,replayMetadata, orlivenessState.Linked context
Closes #80918
Related #76477 (original incomplete-turn safety contract — preserved)
Real behavior proof
lastAssistantfalse-positive afterupdate_plan→ finalstopturnresolveIncompleteTurnPayloadTextwith live attempt fixture matching the reporter's trace shapelastAssistant.stopReason="toolUse"and freshcurrentAttemptAssistant.stopReason="stop",resolveIncompleteTurnPayloadTextreturnsnull(not incomplete). The real final text passes through to payload delivery.resolveIncompleteTurnPayloadTextreturns"⚠️ Agent couldn't generate a response."instead ofnull.Tests and validation
pnpm test src/agents/embedded-agent-runner/run.incomplete-turn.test.ts— 119/119 passeduses currentAttemptAssistant over stale lastAssistant for incomplete-turn classification (#80918)— unit test forisIncompleteTerminalAssistantTurndoes not flag stale lastAssistant=toolUse when currentAttemptAssistant=stop exists (#80918)— integration test forresolveIncompleteTurnPayloadTextstill flags incomplete-turn when currentAttemptAssistant is absent and lastAssistant=toolUse (#76477 regression)— confirms real incomplete-turn still fires#76477regression tests still pass (unchanged behavior for legitimate incomplete-turn scenarios)Risk checklist
isIncompleteTerminalAssistantTurncall inresolveIncompleteTurnPayloadTextnow usescurrentAttemptAssistant ?? lastAssistantinstead of rawlastAssistant. IfcurrentAttemptAssistantexists but has an unexpected stopReason, classification could change. Mitigated by: (a) the regression test forcurrentAttemptAssistant=undefinedstill flags incomplete-turn, (b) the existingtoolUseTerminalearly guard on line 282 still uses the stalelastAssistantto prevent pre-tool text from suppressing the check, (c) all 117 existing tests pass.Current review state
assistantTextsafter the incomplete-turn branch fired, which violated the#76477safety contract by promoting pre-tool narration into successful output. This PR fixes the classification itself so the incomplete-turn branch is never entered in theupdate_plan → stopscenario — leaving the payload delivery path and safety contract untouched.