Repository navigation
fix(agent-core): restore drained steer/follow-up to its source queue on abort - #128695
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
7e261cf to
a3b351c
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 6:39 AM ET / 10:39 UTC. ClawSweeper reviewWhat this changesThis PR restores steering and follow-up messages to their originating Agent queue when an abort occurs after destructive drain but before transcript injection. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThe current main loop still destructively drains messages without restoring them on the abort path, while this PR adds a source-aware restoration at the Agent-owned queue boundary. The patch is a focused repair with no remaining correctness finding; exact-head CI completion remains the merge gate. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherAgent Core accepts steering during tool execution and follow-up input after an otherwise completed run, draining both into the loop before injecting them into the transcript. The Agent owns those queues, so an abort in that handoff window must return uncommitted messages to the correct queue for a later prompt. flowchart LR
A[User steering or follow-up] --> B[Agent-owned queues]
B --> C[Agent loop drains input]
C --> D{Abort before transcript injection}
D -->|Yes| E[Restore source queue]
D -->|No| F[Add to transcript]
E --> G[Next prompt]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +34, Tests +133. Total +167 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the source-aware Agent-owned restoration once exact-head CI validates the abort regressions, retaining steering and follow-up as separate scheduling queues. Do we have a high-confidence way to reproduce the issue? Yes. Current main visibly drains queue state into pendingMessages and its abort closure does not restore it; the PR body also supplies an after-fix Agent runtime trace for that sequence. Is this the best way to solve the issue? Yes. Source-aware restoration at the loop's abort choke point and Agent-owned queues preserves the documented distinction between immediate steering and deferred follow-up scheduling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2abc76d1aebe. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
a3b351c to
bfb7c6f
Compare
bfb7c6f to
848b0f0
Compare
Keep drained steering and follow-up messages owned by their original queue until message_end commits them. Restore any uncommitted batch when the run settles so aborts cannot silently discard accepted input. Co-authored-by: SunnyShu0925 <[email protected]>
848b0f0 to
6855014
Compare
|
Thanks @SunnyShu0925! Proof: A real Agent run sent two ordered steering messages and two ordered follow-ups through the OpenAI Responses HTTP transport. Main lost both pairs after abort. The merged repair delivered steering in the next provider request, kept follow-ups deferred until the request after that, preserved both orders, and never ran the skipped tail tool.
|
|
@obviyus Thanks too. It's a pleasure working with you! |
Keep drained steering and follow-up messages owned by their original queue until transcript commit, then restore uncommitted messages after abort. This prevents silent message loss without changing queue scheduling. Co-authored-by: SunnyShu0925 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #128008
What Problem This Solves
An accepted steering or follow-up message could disappear when the Agent drained it from its queue and the run then aborted before transcript injection. The message was no longer queued, never reached the provider, and could remain visible as a ghost pending entry.
Why This Change Was Made
Agentowns both queues, so each queue now keeps drained messages in its own in-flight state untilmessage_endcommits them to the transcript. When a run settles with an uncommitted message, the same queue restores it ahead of messages accepted later.This keeps steering and follow-up scheduling separate by construction. It also replaces the earlier loop-level source flag and optional public callback with one private queue lifecycle. The maintainer rewrite keeps the behavior and credit from @SunnyShu0925's PR and the original reproduction from @yetval.
User Impact
Evidence
The live proof used the real
Agent, real steering and follow-up queues, real sequential tool execution, a real awaitedturn_endabort, and the built-in OpenAI Responses HTTP transport against a loopback provider that recorded each request.1dba34be9be1249c0e35badcb5ec887ce5d71c72685501499843f4f6be7d8c66d92f038824091640The skipped sequential tail tool ran zero times on both revisions.
Focused validation:
node scripts/run-vitest.mjs packages/agent-core/src— 206 tests passed.node scripts/run-vitest.mjs src/agents/sessions/agent-session-loop-correctness.test.ts src/agents/sessions/agent-session-loop-next-turn.test.ts— 40 tests passed.git diff --check— passed.openclaw/ci-gate— passed.The two new regressions fail on pre-fix production code at the queue-retention assertion and pass with this repair.
AI Assistance