Repository navigation
Bug: background bash() task completion is lost across kernel restarts (one-shot [bash-done] + non-restorable BashHandle) — suggest a persistent task registry
#3781
Replies: 1 comment
|
Follow-up suggestion (different mechanism from the restart-loss above, same symptom of "the agent goes silent and a human has to ask"): what about tasks that simply run long or hang? When a background task never completes (e.g. the For comparison, most agent harnesses avoid this class of failure with blocking tool calls that return a bounded timeout — "command still running after 120 s, here is the partial output" — which is a guaranteed wake-up primitive: the model gets called back periodically and decides whether to keep waiting, inspect output, or kill the task. Humans never have to nudge. Prime's async design (fire-and-forget + one completion notification) is strictly better for long-running and parallel tasks — that is one of its strengths — but it dropped that wake-up guarantee along the way. Today the model is expected to compensate with a heartbeat/polling watch, which means correctness depends on model discipline. I think this burden belongs in the harness:
With both in place, heartbeats/polling become a convenience for the model rather than a required safety net. Happy to test patches on Windows (repro: |
Uh oh!
There was an error while loading. Please reload this page.
Environment: Windows 10/11 x64, prime-agent 0.10.1 (release binary), Python kernel on uv-managed CPython 3.11.17,
PRIME_AGENT_BASH_SHELL= Git'ssh.exe(MSYS). Reproduced across ~20 background-task runs in one long session (source-code analysis, multi-process test matrices), including runs where the kernel survived and runs where it restarted.Related to #3727 but a separate mechanism gap: background task completion notifications (
[bash-done]) are one-shot volatile events, andBashHandleis dropped on kernel restart — so a task that completes while the kernel is down finishes silently and its result is never surfaced.What I observe
The default
bash()flow: a command that runs longer thanyield_afterreturns a snapshot with a liveBashHandle, and the harness pushes[bash-done pid:… exit:…]as acustom_messagewhen it finishes. That works — I have 3 such notifications persisted in my session log (async_bash_completionentries) and they arrived without any polling on my part.The gap appears when the kernel restarts mid-flight (in my case: my own
taskkillmistakes killed the daemon, taking the kernel with it several times):BashHandleis not serializable, so state restoration discards it ("objects that cannot be serialized are dropped"). The spawned process keeps running at the OS level, but nothing in the session remembers it.In practice this looks exactly like "the agent forgets about its own background jobs": the task finishes, no notification arrives, and the result sits on disk unretrieved until a human asks "did you check?". My session had several such lapses after kernel restarts; polling via
handle.poll()or arlm_heartbeatwatch fixes it manually, but that shouldn't be the model's job to remember.The asymmetry worth noting
Kernel state restoration already solves this class of problem for REPL variables: a
dillsnapshot persists Python state across restarts, and restored sessions resume seamlessly ([python-state-restored]). Background tasks are the one runtime object with no equivalent: no persistent registry, no replay, no post-restore summary.Suggestion
A small persistent background-task registry would close the gap:
bash()registers{pid, command, started_at, session_id}before returning the snapshot;async_bash_completionrecord so the next kernel start replays/summarizes it;Happy to test patches on Windows — the repro is trivial (
bash("sleep 25 && touch marker"), kill the kernel, restart, observe silence).All reactions