Skip to content

docs(coding-agent): guide non-blocking long bash tasks - #1316

Open
samsja wants to merge 2 commits into
feat/async-bash-toolfrom
feat/async-bash-background-tasks
Open

docs(coding-agent): guide non-blocking long bash tasks#1316
samsja wants to merge 2 commits into
feat/async-bash-toolfrom
feat/async-bash-background-tasks

Conversation

@samsja

@samsja samsja commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds one concrete prompt example for running a long command without holding the agent turn open:

check = asyncio.create_task(bash("npm run check", timeout=1800))

The prompt tells the model to end the turn, inspect check.done() later, and call check.result() after completion instead of waiting with sleep loops.

Stacked on #1187. Supersedes #1188.

Validation

  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/system-prompt.test.ts
  • npm run check

closes #1034

Note

Add guidance for running long bash commands as non-blocking asyncio tasks in coding agent prompts

Adds a new guidance block to the IPYTHON_CONTROL_PROMPT in rlm.ts instructing the agent to wrap long-running shell commands in asyncio.create_task(bash(...)) so they run without blocking the current agent turn. Includes a concrete example using asyncio.create_task(bash("npm run check", timeout=1800)). Updates the system prompt snapshot test to reflect the new prompt content.

Macroscope summarized 8e42a5d.

@jonaowen jonaowen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants