A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
bash: await always yields after 1 s; remove yield_after (#3828)
Sebastian Müller98bf740b001b
diff --git a/.changes/bash-yield-1s.md b/.changes/bash-yield-1s.mdnew file mode 100644index 0000000000..4a28063b5d--- /dev/null+++ b/.changes/bash-yield-1s.md@@ -0,0 +1 @@+- `await bash(cmd)`, `await handle` and `await r.handle` now always return after at most 1 second in sessions with `[bash-done]` notifications: a command still running by then returns the usual snapshot (`r.running` True, `r.handle` the live handle) and its `[bash-done]` notification arrives on completion. The `yield_after` parameter is gone; passing it raises a `TypeError`.diff --git a/crates/pa-core/src/kernel/bootstrap/runtime_code.rs b/crates/pa-core/src/kernel/bootstrap/runtime_code.rsindex 83b0f66e39..ee60d03276 100644--- a/crates/pa-core/src/kernel/bootstrap/runtime_code.rs+++ b/crates/pa-core/src/kernel/bootstrap/runtime_code.rs@@ -43,7 +43,7 @@ try:/// One line inside the bootstrap's try block, emitted only when the host/// registered the [`crate::kernel::shared::BASH_COMPLETED_REQUEST_TYPE`]-/// handler: turns the runtime's bounded `await bash()` default on. Without+/// handler: turns the runtime's bounded `await bash()` on. Without/// the notice nothing wakes a cell that ended its turn on a degraded command,/// so daemonless sessions keep the unbounded await.const RLM_BOOTSTRAP_BASH_NOTICES_LINE_CODE: &str =@@ -79,7 +79,7 @@ except Exception as _prime_agent_rlm_error:rlm = _PrimeAgentMissingRlm()- def bash(command, yield_after=None, persistent=False):+ def bash(command, persistent=False):rlm._raise_missing()"#;diff --git a/crates/pa-core/src/kernel/bootstrap/venv/probe.rs b/crates/pa-core/src/kernel/bootstrap/venv/probe.rsindex 3b50e17851..2420ad825b 100644--- a/crates/pa-core/src/kernel/bootstrap/venv/probe.rs+++ b/crates/pa-core/src/kernel/bootstrap/venv/probe.rs@@ -28,7 +28,7 @@ fn run_quiet(command: &str, args: &[&str]) -> bool {/// The runtime-ready assertion from the TS product: a current/// prime-agent-runtime with the callable RLM surface, harness CRUD, bash/// handles, and protocol version 3.-const RUNTIME_READY_CHECK: &str = "import inspect; import rlm; from rlm import McpIntegration; import rlm.mcp as mcp; from rlm.harness import HarnessEntry; _harness_methods = ['create_memory', 'update_memory', 'delete_memory', 'create_skill', 'update_skill', 'delete_skill', 'create_subagent', 'update_subagent', 'delete_subagent', 'create_prompt_note', 'update_prompt_note', 'delete_prompt_note', 'record_refinement']; _mcp_discovery_methods = ['list_plugins', 'search_plugins', 'list_connections', 'search_tools', 'describe_tool']; assert callable(mcp.list_tools); assert callable(mcp.call_tool); assert all(callable(getattr(mcp, _m, None)) for _m in _mcp_discovery_methods), \"rlm.mcp is missing MCP discovery methods (list_plugins, search_plugins, list_connections, search_tools, describe_tool); the kernel venv needs a current prime-agent-runtime\"; assert callable(rlm.spawn); assert hasattr(rlm, 'rlm'); assert callable(rlm.rlm.spawn); assert inspect.signature(rlm.spawn).parameters['name'].default is inspect.Parameter.empty; assert not hasattr(rlm, 'run'); assert not hasattr(rlm.rlm, 'run'); assert callable(rlm.host_request); assert callable(rlm.find_models); assert callable(rlm.rlm.find_models); assert callable(rlm.create_session); assert callable(rlm.rlm.create_session); assert callable(rlm.progress_note); assert callable(rlm.rlm.progress_note); assert callable(rlm.rename); assert callable(rlm.rlm.rename); assert hasattr(rlm, 'harness'); assert hasattr(rlm, 'get_harness_state'); assert hasattr(rlm.rlm, 'harness'); assert hasattr(rlm.rlm, 'get_harness_state'); assert all(callable(getattr(_harness, _method, None)) for _harness in (rlm.harness, rlm.rlm.harness) for _method in _harness_methods); assert 'reference' in HarnessEntry.__dataclass_fields__; assert 'scope' in HarnessEntry.__dataclass_fields__; assert 'reference' in inspect.signature(rlm.harness.create_skill).parameters; assert 'reference' in inspect.signature(rlm.harness.update_skill).parameters; assert 'global_' in inspect.signature(rlm.harness.create_memory).parameters; assert 'global_' in inspect.signature(rlm.get_harness_state).parameters; assert not hasattr(rlm, 'background'); assert not hasattr(rlm.rlm, 'background'); from rlm.bash import BashHandle, BashResult; assert callable(rlm.bash); assert {'persistent', 'yield_after'} <= set(inspect.signature(rlm.bash).parameters); assert callable(rlm.persistent_shells); assert callable(rlm._set_completion_notices_wired); assert all(callable(getattr(BashHandle, _m, None)) for _m in ('tail', 'output', 'poll', 'kill')); assert {'exit_code', 'output', 'duration'} <= set(BashResult.__dataclass_fields__); import rlm.repl as _repl; assert callable(_repl.main); assert callable(_repl.emit); assert callable(_repl.host_request); assert callable(_repl.is_active); assert _repl.PROTOCOL_VERSION == 3; assert callable(rlm.emit); assert not hasattr(rlm, 'HOST_COMM_TARGET'); assert not hasattr(mcp, 'install_shutdown_hook')";+const RUNTIME_READY_CHECK: &str = "import inspect; import rlm; from rlm import McpIntegration; import rlm.mcp as mcp; from rlm.harness import HarnessEntry; _harness_methods = ['create_memory', 'update_memory', 'delete_memory', 'create_skill', 'update_skill', 'delete_skill', 'create_subagent', 'update_subagent', 'delete_subagent', 'create_prompt_note', 'update_prompt_note', 'delete_prompt_note', 'record_refinement']; _mcp_discovery_methods = ['list_plugins', 'search_plugins', 'list_connections', 'search_tools', 'describe_tool']; assert callable(mcp.list_tools); assert callable(mcp.call_tool); assert all(callable(getattr(mcp, _m, None)) for _m in _mcp_discovery_methods), \"rlm.mcp is missing MCP discovery methods (list_plugins, search_plugins, list_connections, search_tools, describe_tool); the kernel venv needs a current prime-agent-runtime\"; assert callable(rlm.spawn); assert hasattr(rlm, 'rlm'); assert callable(rlm.rlm.spawn); assert inspect.signature(rlm.spawn).parameters['name'].default is inspect.Parameter.empty; assert not hasattr(rlm, 'run'); assert not hasattr(rlm.rlm, 'run'); assert callable(rlm.host_request); assert callable(rlm.find_models); assert callable(rlm.rlm.find_models); assert callable(rlm.create_session); assert callable(rlm.rlm.create_session); assert callable(rlm.progress_note); assert callable(rlm.rlm.progress_note); assert callable(rlm.rename); assert callable(rlm.rlm.rename); assert hasattr(rlm, 'harness'); assert hasattr(rlm, 'get_harness_state'); assert hasattr(rlm.rlm, 'harness'); assert hasattr(rlm.rlm, 'get_harness_state'); assert all(callable(getattr(_harness, _method, None)) for _harness in (rlm.harness, rlm.rlm.harness) for _method in _harness_methods); assert 'reference' in HarnessEntry.__dataclass_fields__; assert 'scope' in HarnessEntry.__dataclass_fields__; assert 'reference' in inspect.signature(rlm.harness.create_skill).parameters; assert 'reference' in inspect.signature(rlm.harness.update_skill).parameters; assert 'global_' in inspect.signature(rlm.harness.create_memory).parameters; assert 'global_' in inspect.signature(rlm.get_harness_state).parameters; assert not hasattr(rlm, 'background'); assert not hasattr(rlm.rlm, 'background'); from rlm.bash import BashHandle, BashResult; assert callable(rlm.bash); assert list(inspect.signature(rlm.bash).parameters) == ['command', 'persistent']; assert callable(rlm.persistent_shells); assert callable(rlm._set_completion_notices_wired); assert all(callable(getattr(BashHandle, _m, None)) for _m in ('tail', 'output', 'poll', 'kill')); assert {'exit_code', 'output', 'duration'} <= set(BashResult.__dataclass_fields__); import rlm.repl as _repl; assert callable(_repl.main); assert callable(_repl.emit); assert callable(_repl.host_request); assert callable(_repl.is_active); assert _repl.PROTOCOL_VERSION == 3; assert callable(rlm.emit); assert not hasattr(rlm, 'HOST_COMM_TARGET'); assert not hasattr(mcp, 'install_shutdown_hook')";pub(crate) fn has_prime_agent_runtime(python: &str) -> bool {run_quiet(python, &["-c", RUNTIME_READY_CHECK])diff --git a/crates/pa-core/src/kernel/manager/execution.rs b/crates/pa-core/src/kernel/manager/execution.rsindex 9edc237a67..3c70f5ce5f 100644--- a/crates/pa-core/src/kernel/manager/execution.rs+++ b/crates/pa-core/src/kernel/manager/execution.rs@@ -307,7 +307,7 @@ fn cell_watchdog_note(execution: &ActiveExecution) -> Option<String> {Some(format!("[watchdog] Cell exceeded the {} python_repl budget (ran {}). Move long shell work to \bash() (it auto-backgrounds past its yield window) and split long python work into smaller \-cells. Intentional long awaits (yield_after, rlm.collect timeouts) can ignore this note.",+cells. Intentional long awaits (rlm.collect timeouts) can ignore this note.",humanize_ms(timeout_ms),humanize_ms(elapsed_ms),))diff --git a/crates/pa-core/src/prompts/system_prompt.rs b/crates/pa-core/src/prompts/system_prompt.rsindex a6824eccd7..9fef5959d8 100644--- a/crates/pa-core/src/prompts/system_prompt.rs+++ b/crates/pa-core/src/prompts/system_prompt.rs@@ -307,7 +307,7 @@ fn session_role_section(options: &BuildSystemPromptOptions, has_ipython: bool) -}if has_ipython {lines.push(- "`await bash(cmd)` waits at most `yield_after` seconds (`bash(cmd, yield_after=...)`, default 10, max 300; `None` uses the default, not an unbounded wait). If the command is still running, it returns a snapshot: `r.running` is True, `r.exit_code` is None, `r.output` is the output so far, and `r.handle` is the live handle. A completed result has `r.running` False and an integer `r.exit_code`. The command keeps running after a snapshot; end the turn and collect the final result on the `[bash-done]` notification."+ "`await bash(cmd)` waits at most 1 second. If the command is still running, it returns a snapshot: `r.running` is True, `r.exit_code` is None, `r.output` is the output so far, and `r.handle` is the live handle. A completed result has `r.running` False and an integer `r.exit_code`. The command keeps running after a snapshot; end the turn and collect the final result on the `[bash-done]` notification.".to_string(),);} else {diff --git a/crates/pa-core/tests/prompt_guards.rs b/crates/pa-core/tests/prompt_guards.rsindex 341db28bfd..8608e8547c 100644--- a/crates/pa-core/tests/prompt_guards.rs+++ b/crates/pa-core/tests/prompt_guards.rs@@ -577,8 +577,7 @@ fn bounded_await_contract_renders_in_daemon_and_daemonless_sessions() {options.daemonless = daemonless;let prompt = system_prompt_breakdown(&options).assembled;assert!(- prompt.contains("yield_after")- && prompt.contains("`r.running` is True")+ prompt.contains("`r.running` is True")&& prompt.contains("`r.exit_code` is None"),"daemonless={daemonless}: the prompt must carry the bounded-await result contract: {prompt}");diff --git a/crates/pa-daemon/tests/autobg_headless_e2e.rs b/crates/pa-daemon/tests/autobg_headless_e2e.rsindex 6333ad4081..27828d8133 100644--- a/crates/pa-daemon/tests/autobg_headless_e2e.rs+++ b/crates/pa-daemon/tests/autobg_headless_e2e.rs@@ -5,8 +5,8 @@//! the thing under test.//!//! The mock provider scripts the turn: request 1 calls `python_repl` with a-//! one-shot `await bash('sleep 13; echo ...')`. The await degrades at the-//! 10s default: the tool result carries the still-running handle, and the+//! one-shot `await bash('sleep 5; echo ...')`. The await degrades at the+//! 1s window: the tool result carries the still-running handle, and the//! turn settles while the command keeps running. Its `[bash-done ...]`//! notice then wakes the idle session. Everything is asserted by transcript//! event ORDER, not wall-clock caps.@@ -144,7 +144,7 @@ fn serve(mut stream: TcpStream, next: &AtomicUsize) -> std::io::Result<()> {"type": "function","function": {"name": "python_repl",- "arguments": "{\"code\": \"from rlm import bash\\nres = await bash('sleep 13; echo BOUNDED_AWAIT_E2E_DONE')\\nres\"}"+ "arguments": "{\"code\": \"from rlm import bash\\nres = await bash('sleep 5; echo BOUNDED_AWAIT_E2E_DONE')\\nres\"}"}}]}),@@ -361,7 +361,7 @@ fn a_bounded_bash_await_degrades_and_the_notice_wakes_the_session() {.expect("active session id").to_string();- // THE TURN: the tool call awaits a 13s command with NO override; the+ // THE TURN: the tool call awaits a 5s command; the// default wiring must degrade the await and settle the turn while the// command is still running.let turn = client.request(@@ -421,7 +421,7 @@ fn a_bounded_bash_await_degrades_and_the_notice_wakes_the_session() {});// Teardown: stop the session through the live supervisor so the worker- // (and its kernel + the 13s sleeper) do not leak past the test.+ // (and its kernel + the 5s sleeper) do not leak past the test.client.request("k1",&json!({ "type": "kill", "activeSessionId": active_id }),diff --git a/prime-agent-runtime/src/rlm/bash.py b/prime-agent-runtime/src/rlm/bash.pyindex c0c4ddb790..c978d203e7 100644--- a/prime-agent-runtime/src/rlm/bash.py+++ b/prime-agent-runtime/src/rlm/bash.py@@ -57,14 +57,13 @@ _ASYNCIO_WRAPPER_CALLBACKS = {("asyncio.tasks", "_release_waiter"),}-# Bounded awaits (yield_after): in sessions whose host registers the-# bash.completed handler, an await past its bound degrades to returning the+# Bounded awaits: in sessions whose host registers the bash.completed handler,+# an await still running after _YIELD_AFTER_SECONDS degrades to returning the# live handle instead of blocking (the [bash-done] notice collects it). The# kernel bootstrap flips the flag from the host-handler registry — one source-# of truth; the numbers stay here, never on the Rust side.+# of truth; the window stays here, never on the Rust side._completion_notices_wired = False-_DEFAULT_YIELD_AFTER_SECONDS = 10.0-_MAX_YIELD_AFTER_SECONDS = 300.0+_YIELD_AFTER_SECONDS = 1.0def _set_completion_notices_wired(wired: bool) -> None:@@ -78,15 +77,6 @@ def _set_completion_notices_wired(wired: bool) -> None:_completion_notices_wired = wired-def _effective_yield_after(yield_after: float | None) -> float | None:- """The bound every await of a handle uses; None means unbounded."""- if not _completion_notices_wired:- return None- if yield_after is None:- return _DEFAULT_YIELD_AFTER_SECONDS- return min(yield_after, _MAX_YIELD_AFTER_SECONDS)--# One stderr hint per degrade, budgeted per kernel (nano-rlm's# MAX_LONG_RUN_NOTES shape): the first few degrades teach the contract, later# ones stay quiet.@@ -109,19 +99,19 @@ def _note_degrade(handle: "BashHandle", bound: float) -> None:async def _bounded_wait(- wait: Awaitable[BashResult], yield_after: float | None+ wait: Awaitable[BashResult], bound: float | None) -> BashResult | None:- """Await a command wait, abandoning it after `yield_after` seconds.+ """Await a command wait, abandoning it after `bound` seconds.Returns None only on the degrade: the wait task keeps running (cancellingan owned wait would kill the command — the degrade must not), and itslate result is consumed silently by the done callback."""- if yield_after is None:+ if bound is None:return await waitwait_task = asyncio.ensure_future(wait)try:- done, _pending = await asyncio.wait({wait_task}, timeout=yield_after)+ done, _pending = await asyncio.wait({wait_task}, timeout=bound)except asyncio.CancelledError:# An interrupt inside the window: the wait must observe the cancel# (an owned await runs its kill dance in _wait_owned) before the@@ -379,11 +369,8 @@ class BashHandle:handle; later awaits only wait and cancelling them leaves it running."""- def __init__(self, command: str, yield_after: float | None = None) -> None:+ def __init__(self, command: str) -> None:self.command = command- # The requested bound (None = the session default); every await- # resolves it through _effective_yield_after.- self._yield_after = yield_afterself._activity_id = secrets.token_hex(16)completion_context = _current_cell_completion_context()self._creating_cell_finished = completion_context[0] if completion_context else None@@ -1064,13 +1051,13 @@ class BashHandle:# A handle awaited before any other API use is a one-shot command tied# to the await (kill-on-cancel); touching the handle API first marks it# as a deliberate background handle whose awaits only wait. Both paths- # wait at most the handle's bound, then degrade to this live handle.+ # wait at most the yield window, then degrade to this live handle.try:current_task = asyncio.current_task()except RuntimeError:current_task = Nonecreating_cell_waited = _creating_cell_waits_for(self._creating_cell_task, current_task)- bound = _effective_yield_after(self._yield_after)+ bound = _YIELD_AFTER_SECONDS if _completion_notices_wired else Noneowned = not self._releasedwait = self._wait_owned() if owned else self._wait()self._released = True@@ -1177,10 +1164,8 @@ class PersistentBashHandle(BashHandle):home: str,proc: subprocess.Popen[bytes] | None,running: bool = True,- yield_after: float | None = None,) -> None:self.command = command- self._yield_after = yield_afterself._activity_id = shell_idcompletion_context = _current_cell_completion_context()self._creating_cell_finished = completion_context[0] if completion_context else None@@ -1310,21 +1295,19 @@ class PersistentBashHandle(BashHandle):return f"<BashHandle persistent pid={self._pid} {state} command={self.command!r}>"-def bash(command: str, yield_after: float | None = None, persistent: bool = False) -> BashHandle:+def bash(command: str, persistent: bool = False) -> BashHandle:"""Start a shell command immediately; await the handle for the result.`await bash(cmd)` is a one-shot: cancelling the await (e.g. an interrupt)kills the command's process group. In sessions whose host wires completion- notices (the kernel bootstrap turns the bounded default on), an await that- is still running after `yield_after` seconds instead DEGRADES: it returns a- BashSnapshot (r.running True, r.output the output so far, r.handle the live- handle) while the command keeps running, and its [bash-done] notification- arrives on completion. `yield_after=None` uses the session- default (10 seconds); explicit values must be positive and are clamped to- 300. In sessions without completion notices every await stays unbounded and- `yield_after` has no effect. `h = bash(cmd)` used as a background- handle (any .pid/.running/.output()/.tail()/.poll()/.kill() access before- the first await) survives cancellation; awaiting it only waits. Leak+ notices (the kernel bootstrap turns the bound on), an await that is still+ running after 1 second instead DEGRADES: it returns a BashSnapshot+ (r.running True, r.output the output so far, r.handle the live handle)+ while the command keeps running, and its [bash-done] notification arrives+ on completion. In sessions without completion notices every await stays+ unbounded. `h = bash(cmd)` used as a background handle (any+ .pid/.running/.output()/.tail()/.poll()/.kill() access before the first+ await) survives cancellation; awaiting it only waits. Leakcontainment is per-platform: process groups plus the orphan journal onPOSIX; a kill-on-close job object on Windows entered while the child isstill suspended, so no descendant can escape it and kill()/crash cleanup@@ -1338,23 +1321,21 @@ def bash(command: str, yield_after: float | None = None, persistent: bool = Falsshell survives kernel, worker, and daemon restarts and its session'sdelete or archive (a deleted session's shells keep running as orphans);only its own exit or an explicit kill() ends it. Its output and exit- status live in files under the agent dir, and awaits never own it: an- await bounded by yield_after degrades as for any handle and the shell runs- on. After a restart, get the handles back with `from rlm import- persistent_shells; persistent_shells()`; a shell that finished while no+ status live in files under the agent dir, and awaits never own it: a+ bounded await degrades as for any handle and the shell runs on. After a+ restart, get the handles back with `from rlm import persistent_shells;+ persistent_shells()`; a shell that finished while nokernel ran is listed once, finished. Completion of a re-attached shell ispolled, so its result and completion notice lag by up to a second; itsexit_code is -1 when it was killed before recording a status."""if not isinstance(command, str) or not command:raise TypeError("command must be a non-empty str")- if yield_after is not None and yield_after <= 0:- raise ValueError("yield_after must be a positive number of seconds")if persistent:- handle: BashHandle = _spawn_persistent(command, yield_after)+ handle: BashHandle = _spawn_persistent(command)else:_install_shutdown_hook()- handle = BashHandle(command, yield_after)+ handle = BashHandle(command)from . import replrepl.emit(@@ -1550,7 +1531,7 @@ def _shell_identity(pid: int, start_id: str) -> bool | None:return None if current is None else current == start_id-def _spawn_persistent(command: str, yield_after: float | None) -> PersistentBashHandle:+def _spawn_persistent(command: str) -> PersistentBashHandle:if not _IS_POSIX:raise RuntimeError("bash(persistent=True) is only supported on POSIX")session_id = os.environ.get("RLM_SESSION_ID")@@ -1594,9 +1575,7 @@ def _spawn_persistent(command: str, yield_after: float | None) -> PersistentBashgate.write(b"\n")finally:gate.close()- return PersistentBashHandle(- command, shell_id, proc.pid, start_id, started_at, home, proc, yield_after=yield_after- )+ return PersistentBashHandle(command, shell_id, proc.pid, start_id, started_at, home, proc)def persistent_shells() -> list[BashHandle]:diff --git a/prime-agent-runtime/test/test_bash.py b/prime-agent-runtime/test/test_bash.pyindex 3535b332a6..d8c16b6875 100644--- a/prime-agent-runtime/test/test_bash.py+++ b/prime-agent-runtime/test/test_bash.py@@ -1380,8 +1380,8 @@ class BashTest(unittest.IsolatedAsyncioTestCase):class BoundedAwaitTest(unittest.IsolatedAsyncioTestCase):- """The yield_after contract: with completion notices wired (the kernel- bootstrap call) an await degrades to the live handle past its bound;+ """The yield-window contract: with completion notices wired (the kernel+ bootstrap call) an await degrades to the live handle past the window;without them every await stays unbounded (nothing wakes a collector)."""def _wire_notices(self) -> None:@@ -1390,18 +1390,10 @@ class BoundedAwaitTest(unittest.IsolatedAsyncioTestCase):bash_module._degrade_hints_written = 0self.addCleanup(setattr, bash_module, "_degrade_hints_written", 0)- async def test_wired_default_and_maximum_bounds(self):- self._wire_notices()- self.assertEqual(bash_module._effective_yield_after(None), 10.0)- self.assertEqual(bash_module._effective_yield_after(500), 300.0)- self.assertEqual(bash_module._effective_yield_after(0.25), 0.25)- bash_module._set_completion_notices_wired(False)- self.assertIsNone(bash_module._effective_yield_after(None))- self.assertIsNone(bash_module._effective_yield_after(0.25))-+ @mock.patch.object(bash_module, "_YIELD_AFTER_SECONDS", 0.3)async def test_bounded_await_degrades_to_a_snapshot(self):self._wire_notices()- handle = bash("sleep 0.5", yield_after=0.3)+ handle = bash("sleep 0.5")returned = await handleself.assertIsInstance(returned, bash_module.BashSnapshot)self.assertIs(returned.handle, handle)@@ -1415,25 +1407,22 @@ class BoundedAwaitTest(unittest.IsolatedAsyncioTestCase):async def test_bounded_await_returns_the_result_within_the_window(self):self._wire_notices()- result = await bash("printf quick", yield_after=5)+ result = await bash("printf quick")self.assertEqual(result.exit_code, 0)self.assertIn("quick", result.output)self.assertIs(result.running, False)- with self.assertRaises(ValueError):- bash("echo no", yield_after=0)- with self.assertRaises(ValueError):- bash("echo no", yield_after=-1)+ @mock.patch.object(bash_module, "_YIELD_AFTER_SECONDS", 0.2)async def test_daemonless_await_ignores_the_bound(self):# No completion notices wired: no wake-up exists to collect a- # degraded command, so the await stays unbounded and yield_after- # has no effect.- result = await bash("sleep 1", yield_after=0.2)+ # degraded command, so the await stays unbounded.+ result = await bash("sleep 0.5")self.assertEqual(result.exit_code, 0)+ @mock.patch.object(bash_module, "_YIELD_AFTER_SECONDS", 0.3)async def test_cancelling_a_later_await_of_a_degraded_handle_only_waits(self):self._wire_notices()- handle = bash("sleep 1.5", yield_after=0.3)+ handle = bash("sleep 1.5")snapshot = await handleself.assertIsInstance(snapshot, bash_module.BashSnapshot)@@ -1451,13 +1440,14 @@ class BoundedAwaitTest(unittest.IsolatedAsyncioTestCase):result = await asyncio.wait_for(handle._wait(), 10)self.assertEqual(result.exit_code, 0)+ @mock.patch.object(bash_module, "_YIELD_AFTER_SECONDS", 0.2)async def test_degrade_hints_are_budgeted_to_the_first_three(self):self._wire_notices()handles = []hints = io.StringIO()with mock.patch.object(sys, "stderr", hints):for _ in range(5):- handle = bash("sleep 3", yield_after=0.2)+ handle = bash("sleep 3")handles.append(handle)self.assertIsInstance(await handle, bash_module.BashSnapshot)for handle in handles:@@ -1594,7 +1584,7 @@ class PersistentBashTest(unittest.IsolatedAsyncioTestCase):# the bound resolves at await time.bash_module._set_completion_notices_wired(True)self.addCleanup(bash_module._set_completion_notices_wired, False)- with mock.patch.object(bash_module, "_DEFAULT_YIELD_AFTER_SECONDS", 0.2):+ with mock.patch.object(bash_module, "_YIELD_AFTER_SECONDS", 0.2):self.assertIsInstance(await held, bash_module.BashSnapshot)held.kill()diff --git a/prime-agent-runtime/test/test_repl.py b/prime-agent-runtime/test/test_repl.pyindex e76e38ecfb..60415acaad 100644--- a/prime-agent-runtime/test/test_repl.py+++ b/prime-agent-runtime/test/test_repl.py@@ -525,7 +525,7 @@ class ReplTest(unittest.TestCase):"import rlm","rlm._set_completion_notices_wired(True)","from rlm import bash",- f"r = await bash('sleep 1.5 && touch {marker}', yield_after=3)",+ f"r = await bash('sleep 1.5 && touch {marker}')",])self.repl.send({"type": "execute", "id": "ibash-bounded", "code": code})@@ -1225,7 +1225,7 @@ class ReplTest(unittest.TestCase):"import rlm","rlm._set_completion_notices_wired(True)","from rlm import bash",- "handle = bash('sleep 0.6; printf degraded', yield_after=0.3)",+ "handle = bash('sleep 1.5; printf degraded')","await handle","handle.pid",]@@ -1238,14 +1238,14 @@ class ReplTest(unittest.TestCase):{"type": "bash.completed","pid": pid,- "command": "sleep 0.6; printf degraded",+ "command": "sleep 1.5; printf degraded","exitCode": 0,},)reply_ok(self.repl, request)def test_degraded_await_of_a_persistent_shell_keeps_it_running_to_its_notice(self):- # yield_after and persistent= compose: the persistent handle's await+ # The yield window and persistent= compose: the persistent handle's await# degrades like any handle's, and the shell (never owned by an await)# runs on to its [bash-done] notice.temp = tempfile.TemporaryDirectory()@@ -1260,7 +1260,7 @@ class ReplTest(unittest.TestCase):"import rlm","rlm._set_completion_notices_wired(True)","from rlm import bash",- "handle = bash('sleep 0.6; printf persisted', persistent=True, yield_after=0.3)",+ "handle = bash('sleep 1.5; printf persisted', persistent=True)","snapshot = await handle","(snapshot.running, snapshot.handle is handle, handle.pid)",]@@ -1274,7 +1274,7 @@ class ReplTest(unittest.TestCase):{"type": "bash.completed","pid": int(pid),- "command": "sleep 0.6; printf persisted",+ "command": "sleep 1.5; printf persisted","exitCode": 0,},)