fix(coding-agent): preserve goal continuation after compaction - #1316
Conversation
Add an async bash() function to the RLM bootstrap code in ipython.ts
that uses asyncio.create_subprocess_exec to run shell commands without
blocking the kernel event loop. Unlike %%bash cells (which block the
kernel until the command finishes), await bash('...') keeps the kernel
responsive to interrupts and other messages while the process runs.
Supports optional timeout (raises TimeoutError) and cwd parameters.
Returns a _PrimeAgentBashResult with stdout, stderr, and returncode.
Update the RLM system prompt to prefer await bash('...') over %%bash
cells.
jonaowen
left a comment
There was a problem hiding this comment.
This prompt tells the agent to end the turn while an unowned asyncio.Task runs only in the kernel. That is not a persistent/durable task contract: kernel restart, session rotation, process teardown, or task GC/cancellation loses the command and its result. asyncio.create_task() also leaves exceptions unobserved until a later turn that may never occur, and there is no cleanup/adoption registry.
Moreover the stacked base #1187’s bash() explicitly terminates background descendants and drains pipes as part of collection. Turning its coroutine into a detached task does not provide receipt paths, durable process identity, restart reconstruction, or cancellation ownership—the properties needed for an actual long job. Do not describe this as “persistent.” Either scope the guidance to short same-kernel work and require an immediate owner plus exception-safe callback/finally cleanup, or land a real managed task registry/detached-job substrate with durable receipts, restart/adoption semantics, bounded output, terminal observation, and cancellation tests. It should also remain stacked until #1187’s contract is accepted.
…tion # Conflicts: # packages/coding-agent/CHANGELOG.md # packages/coding-agent/test/system-prompt.test.ts
…Intellect-ai#1316) * feat(coding-agent): add async bash() to IPython kernel Add an async bash() function to the RLM bootstrap code in ipython.ts that uses asyncio.create_subprocess_exec to run shell commands without blocking the kernel event loop. Unlike %%bash cells (which block the kernel until the command finishes), await bash('...') keeps the kernel responsive to interrupts and other messages while the process runs. Supports optional timeout (raises TimeoutError) and cwd parameters. Returns a _PrimeAgentBashResult with stdout, stderr, and returncode. Update the RLM system prompt to prefer await bash('...') over %%bash cells. * fix(coding-agent): bound async bash subprocesses * fix(coding-agent): fail closed for bash on Windows * fix(coding-agent): render async bash output * fix(coding-agent): clean completed bash sessions * fix(coding-agent): validate bash output bounds * fix(coding-agent): bound rendered bash output * fix(coding-agent): escalate bash group cleanup * fix(coding-agent): preserve bounded UTF-8 output * docs(coding-agent): qualify async bash platforms * fix(coding-agent): clarify bash truncation units * refactor(coding-agent): keep async bash POSIX-only * docs(coding-agent): guide background bash tasks closes PrimeIntellect-ai#1034 * docs(coding-agent): simplify background bash guidance * fix(coding-agent): preserve goal continuation after compaction * docs(coding-agent): explain continuation deduplication --------- Co-authored-by: Seth <seth@primeintellect.ai>
Summary
main.Root cause
_queuedGoalThresholdContinuationcan refer to the continuation that is currently running. If that continuation crosses the compaction threshold, the scheduler treated its running action as an already-pending successor and did not queue another goal continuation. After compaction, the running action completed, leaving no queued work.agent.continue()could not resume the assistant-last stop, so the active goal stalled.The fix only deduplicates undelivered continuation states:
queued,selected,preparing, andcommitting. Arunningcontinuation may now enqueue its successor.Validation
agent-session-compaction-continuation.test.ts: 7/7 passednpm run checkgit diff --check