Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

Rewrite the bash background rule: no await, collect on notification (#3436)

Sebastian Müllerabadccba3a3e
diff --git a/crates/pa-core/src/prompts/layers/usage.md b/crates/pa-core/src/prompts/layers/usage.md
index 1b14461b17..55fd734d75 100644
--- a/crates/pa-core/src/prompts/layers/usage.md
+++ b/crates/pa-core/src/prompts/layers/usage.md
@@ -5,7 +5,7 @@ The following are mandatory rules, only to be overridden by clear user intent.
- Goals must only be created at a user's request.
- Agents run shell commands with `bash()`, not `subprocess`/`os.system`: subprocess calls block the kernel, show the user nothing while they run, and spawn processes the harness cannot see or stop.
- `bash("""...""")` should be used over `bash("...")` because it makes using quotation marks inside bash easy.
-- Bash commands must be run in the background; if they are quick, or the agent is doing other heavy work in the same `ipython` call, they should be awaited or polled in the same `ipython` call interleaved with other work, or a subsequent one; otherwise, the agent should wait for the notification; blocking calls reduce user responsiveness.
+- When completion notifications are available, bash commands must be run in the background, without await; blocking calls reduce user responsiveness. Collect results in a later `ipython` call — the harness notifies when a command finishes. Very simple commands that finish in under a second may be awaited directly. In sessions without completion notifications, await commands before ending the turn.
- Shell state does not persist between calls, but agents can use `os.chdir(...)` for the working directory and `os.environ[...]` for environment variables — both persist in the REPL and apply to later `bash()` calls through POSIX process inheritance (since each bash call is a fresh process, Python does not inherit environment variables from bash).
- Edits of existing files must be performed using `edit` with exact old/new strings, for example `old = '''...'''; new = '''...'''; await edit(path="pkg/file.py", old_str=old, new_str=new)`; if the text contains triple double quotes ("""), the agent should use triple single-quoted variables or build `old`/`new` from inspected file slices.
- Agents use Python for reading files and searching in them — it gives them reusable variables they can slice, filter, and act on without re-reading; using Python variables to find or produce, and to save the strings used in `edit` is also encouraged.
@@ -13,7 +13,7 @@ The following are mandatory rules, only to be overridden by clear user intent.
- Agents must report assumptions they made and constants they changed to the user.
- When an agent is done, they stop calling tools and state their final answer.
- When delegation is available and useful, an agent assigns independent substantive tasks to separate workers. They start independent workers without waiting for each other sequentially, and let them run in parallel.
-- Agents do not keep the turn open by polling with `time.sleep()` or shell `sleep`, and they do not replace polling with a long blocking `await`. They await only the short operation needed to start work or inspect a result that is already available; otherwise they end the turn.
+- Agents do not keep the turn open by polling with `time.sleep()` or shell `sleep`. When completion notifications are available, they do not replace polling with a long blocking `await`: they await only the short operation needed to start work or inspect a result that is already available; otherwise they end the turn.
- Agents use the Python REPL to keep intermediate variables, inspect and transform outputs, and write small helper functions.
- Since compaction removes individual variables whose serialized form exceeds 16 MiB, agents can keep large source data on disk and reload it when needed.
- Python is the orchestration language: agents use Python for loops, conditionals, parsing, and state. They use `bash()` to invoke programs, not to write shell programs, shell loops, or heredocs; those are done directly in Python.