Repository navigation
Replies: 4 comments
|
Can confirm the job-completion-notice manifestation of this same retirement-window hole, on the shipped release. Environment: Deterministic repro (real AgentLoop + LocalJobRegistry + tool-jobs, scripted in-process LLM adapter, no API key):
Observed:
Control (settle strictly after idle): the notice itself opens turn 2, The abort-drain variant has the same signature: a notice injected while the driver drains an aborted turn is stranded the same way, since only waking sends latch Suggested fix stays the one proposed in the OP: at the retirement boundary, commit idle and then recheck pending work (e.g. |
|
I confirmed this is a driver-retirement race, and implementing the fix exposed a second re-entrancy hazard in the same transition. Root causeAfter The job-completion symptom is the same race: lane selection observes the stale Why an unconditional pending-work wake is too broadRestarting whenever FixThe patch publishes Each Additional race closedPublishing Regression evidence
Patch:
Validation: all 18 agent-loop test files passed (334/334); focused coverage reports 100% statements, branches, functions, and lines for If this lifecycle invariant matches the maintainers' intended semantics, the fork commit is ready to cherry-pick or adapt. |
|
Additional reproduction / data point for this retirement-race from the composer-visible side (rc.7, Web GUI, Windows 11): A background subagent's settlement notices were spliced into the parent session's inbox ( Parent-session timeline (timestamps from the session record):
This adds two details to the retirement-race picture:
The UI-side symptom was also reported in discussion #728 ("Subagent θΏεηζΆζ―δΌεΊη°ε¨δΈ»ε―Ήθ―ζ‘ηζιιεδΈ"). Environment: dsh 0.1.0-rc.7 (commit 99f6f02) installed from npm, Web GUI at 127.0.0.1:3080, Windows 11. |
|
I reproduced a related terminal-error variant on the current master ( I implemented and validated a narrow fix:
The implementation tracks wake ownership by queued message identity, transfers that ownership when queued input is replaced, and starts a replacement driver only when an admitted waking entry remains pending after a terminal error or retirement. Non-waking The regression failed before the code change with two failed adapter requests and a stranded follow-up. With the fix, the failed turn closes with The upstream repository currently has pull-request creation disabled, so I am posting the ready-to-cherry-pick commit here instead. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
A waking
Agent.followup()can be accepted intonext-turnbut never run when it arrives after the turn loop's final inbox check and before the driver commitsidle. The agent then reportsidlewhile holding pending user work. Another unrelated waking message is required to resume it.Tested on
masterat commit47f943859bef60e4160492346772ded9b24f765a, including a realdeepseek/deepseek-v4-pro-0813AgentLoop run through OpenRouter and the real Bash tool.Reproduction
turn/end.turn/endobserver, call:Scheduling outside the synchronous
session/eventcallback is necessary because nested session appends are intentionally rejected.agent.whenIdle()and wait another 500 ms.Observed:
After sending a second, unrelated
followup(), the parked request runs,retirement.txtcontainsRETIREMENT_FOLLOWUP\n, and the second message opens a third turn.The deterministic run reported:
{ "strandedWhileIdle": true, "pendingNextTurnWhileIdle": 1, "recoveredOnlyAfterSecondWake": true, "finalTurnCount": 3 }Expected behavior
A waking message accepted before the current driver retires should either be claimed by that driver or latch a replacement driver. An idle agent should not retain waking
next-turnwork indefinitely.Root cause
wakeDriver()returns for a live non-idle phase without settingwakeRequested; it only latches maintenance and post-abort wakes.The loop's last pending-work check and the subsequent driver retirement leave a window in which work is inserted, its wake is ignored, and the driver transitions to idle without rechecking the inbox.
The repository already documents the same retirement-window hole for job completion notices and steering. This reproduction shows that ordinary user follow-ups share the same path and impact.
Impact
Suggested fix
At the retirement boundary, atomically publish idle and then recheck pending waking work, or latch any waking send that arrives after the driver's final claim opportunity.
A regression test could schedule
followup()in a microtask fromturn/end, assert that the agent never remains idle with pending waking work, and verify that no second external wake is required.All reactions