fix(agents): preserve final text after stale incomplete-turn state#80931
fix(agents): preserve final text after stale incomplete-turn state#80931hclsys wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. source-level reproduction is high confidence: current main reads stale Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the narrow terminal-assistant selection fix with its regression tests if required checks stay green, and track any broader observability or recovery work separately. Do we have a high-confidence way to reproduce the issue? Yes, source-level reproduction is high confidence: current main reads stale Is this the best way to solve the issue? Yes, this is a narrow maintainable fix: selecting What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against da7f9a62676c. |
Fixes #80918
Summary
currentAttemptAssistantas the freshest terminal assistant state for incomplete-turn detection.update_planfinal answer whenlastAssistantis still the previoustoolUsesnapshot.Real behavior proof
assistant(toolUse update_plan) -> toolResult(empty) -> assistant(stop, visible final text)must not be classified as incomplete just becauselastAssistantstill points at the previoustoolUsesnapshot.src/agents/pi-embedded-runner/run/incomplete-turn.tswithnode --conditions=openclaw-source --import tsx. No live WhatsApp/OpenRouter credentials were used.node --conditions=openclaw-source --import tsx -e '<imports resolveIncompleteTurnPayloadText from source; stale lastAssistant=toolUse; fresh currentAttemptAssistant=stop; payloadCount=1>'pnpm test src/agents/pi-embedded-runner/run.incomplete-turn.test.ts -- --reporter=verbosepnpm test src/agents/pi-embedded-runner/run/payloads.test.ts src/cron/isolated-agent/helpers.test.ts -- --reporter=verbosepnpm run check:changedSupplemental local checks also passed:
run.incomplete-turn.test.ts94/94,run/payloads.test.ts24/24,cron/isolated-agent/helpers.test.ts22/22, andcheck:changedexited 0 with 0 oxlint warnings/errors plus 0 runtime value import cycles.lastAssistant.stopReason = "toolUse"and freshcurrentAttemptAssistant.stopReason = "stop", the patched source returnsincompleteTurnPayload: nullwhile preserving the visible final text. That is the non-error branch needed for the issue's post-update_planfinal answer.Risk
#76477guard remains covered: terminaltoolUsewith only pre-tool text still surfaces the incomplete-turn error.