Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(exec): yield long-running commands by default (NAN-328) (#6385)
chengyongru26e1f41a00ec
diff --git a/docs/configuration.md b/docs/configuration.mdindex cc5c22334..f3a133194 100644--- a/docs/configuration.md+++ b/docs/configuration.md@@ -2334,6 +2334,8 @@ The model may explicitly request a different hard runtime up to `maxRuntimeLimitFor existing configurations, `timeout` remains a hard-runtime alias: `"timeout": 60` still stops a command after 60 seconds, and `"timeout": 0` still means no hard deadline. Use either `timeout` or `maxRuntime`, not both.+`exec` waits up to 1 second by default, then returns an active session ID if the command is still running. Use `exec_session` with that ID to read further output, wait, or stop the command; do not launch the command again just because it is still running. `yield_time_ms` changes the initial wait (0–30000 ms), not the command's runtime budget. Omitting it keeps stdin closed; set it explicitly when the command needs interactive input. `exec_session` waits are also bounded by `timeout_ms`, including `until_exit: true`; an expired wait leaves the command running. Direct `!` shell commands still wait for their completed result.+The tool result distinguishes a hard-runtime termination from inactivity. With `idleAction: "report"`, a silent command continues running under its hard-runtime limit. With `idleAction: "terminate"`, inactivity stops the command and the result reports that reason. Both limits apply without polling. Commands are cleaned up when they finish, reach an enforced limit, or their owning session is cancelled or deleted; normal operation does not require manual process management. `yield_time_ms` and an `exec_session` wait timeout only control how long a tool call waits before returning; neither stops the command nor resets its runtime or inactivity clock.Silence is not proof that a command is stuck: builds, downloads, and buffered programs can be quiet while working. Only bytes received through stdout or stderr count as activity; output redirected to files is not observed, and reading logs does not refresh the inactivity clock. Inactivity checks do not detect prompts or supply answers. Choose `"terminate"` only when stopping a quiet command is acceptable, and use a finite hard runtime when total execution time must remain bounded. Shell sessions are not durable jobs and should not be used as a replacement for a scheduler or service manager. A command that detaches a background service and exits is not a managed job; these timing checks do not manage that service afterward.diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.pyindex a456fceda..38a32e0fd 100644--- a/nanobot/agent/loop.py+++ b/nanobot/agent/loop.py@@ -38,6 +38,7 @@ from nanobot.agent.tools.file_state import FileStateStore, bind_file_states, resfrom nanobot.agent.tools.message import capture_message_deliveriesfrom nanobot.agent.tools.registry import ToolRegistryfrom nanobot.agent.tools.runtime_control import AgentRuntimeControl+from nanobot.agent.tools.shell import ExecToolfrom nanobot.agent.turn_delivery import (TurnDelivery,TurnDeliveryFactory,@@ -871,7 +872,7 @@ class AgentLoop:"""Execute one trusted user command with the active workspace policy."""metadata = dict(ctx.msg.metadata or {})tool = self.tools.get("exec")- if tool is None:+ if not isinstance(tool, ExecTool):content = "Shell execution is disabled in this nanobot configuration."else:session = ctx.session or await self.sessions.state.get(ctx.key)@@ -899,7 +900,7 @@ class AgentLoop:try:for turn_scope in ctx.turn_scopes:turn_scope_stack.enter_context(turn_scope)- result = await tool.execute(+ result = await tool.execute_to_completion(command=ctx.args.strip(),working_dir=str(scope.project_path),)diff --git a/nanobot/agent/tools/exec_session.py b/nanobot/agent/tools/exec_session.pyindex 6e4022ece..9d72f4d79 100644--- a/nanobot/agent/tools/exec_session.py+++ b/nanobot/agent/tools/exec_session.py@@ -762,7 +762,7 @@ def format_session_poll(session_id: str, poll: _SessionPoll) -> str:nullable=True,),until_exit=BooleanSchema(- description="Wait for the process to exit.",+ description="Wait for exit within timeout_ms; return the active session if the wait expires.",default=False,),timeout_ms=IntegerSchema(diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.pyindex da2160671..f91bc0cd6 100644--- a/nanobot/agent/tools/shell.py+++ b/nanobot/agent/tools/shell.py@@ -135,7 +135,7 @@ def _exec_parameters(config: ExecToolConfig) -> dict[str, Any]:nullable=True,),yield_time_ms=IntegerSchema(- description="Return after this many milliseconds if still running; omit to wait for exit.",+ description="Return after this many milliseconds if still running (default 1000, max 30000); execution continues.",minimum=0,maximum=MAX_YIELD_MS,nullable=True,@@ -317,11 +317,23 @@ class ExecTool(Tool):return preparedreturn await self._execute_session(prepared, yield_time_ms, max_output_chars)+ async def execute_to_completion(self, command: str, working_dir: str) -> str:+ """Return the complete result for a trusted user shell command, without an agent observer."""+ try:+ prepared = self._prepare_command(command, working_dir)+ except ValueError as exc:+ return ToolResult.error(f"Error: {exc}")+ if isinstance(prepared, str):+ return prepared+ return await self._execute_session(prepared, None, None, until_exit=True)+async def _execute_session(self,prepared: _PreparedCommand,yield_time_ms: int | None,max_output_chars: int | None,+ *,+ until_exit: bool = False,) -> str:try:session_id, poll = await self._session_manager.start(@@ -331,11 +343,10 @@ class ExecTool(Tool):timeout=prepared.timeout,shell_program=prepared.shell_program,login=prepared.login,- yield_time_ms=(- 0 if yield_time_ms is None- else clamp_session_int(yield_time_ms, DEFAULT_YIELD_MS, 0, MAX_YIELD_MS)+ yield_time_ms=0 if until_exit else clamp_session_int(+ yield_time_ms, DEFAULT_YIELD_MS, 0, MAX_YIELD_MS,),- until_exit=yield_time_ms is None,+ until_exit=until_exit,stdin=(asyncio.subprocess.DEVNULL if yield_time_ms is None else asyncio.subprocess.PIPE),idle_timeout=self._exec_config.idle_timeout,idle_action=self._exec_config.idle_action,@@ -348,7 +359,7 @@ class ExecTool(Tool):),)result = format_session_poll(session_id, poll)- if not poll.done and yield_time_ms is not None:+ if not poll.done:result += "\nInitial wait ended; session remains active."return ToolResult.error(result) if poll.failed else resultexcept Exception as exc:diff --git a/tests/command/test_user_shell_command.py b/tests/command/test_user_shell_command.pyindex 6dc95829f..b928a207b 100644--- a/tests/command/test_user_shell_command.py+++ b/tests/command/test_user_shell_command.py@@ -6,6 +6,7 @@ import pytestfrom nanobot.agent.loop import AgentLoopfrom nanobot.agent.tools.context import current_request_context+from nanobot.agent.tools.shell import ExecToolfrom nanobot.bus.events import INBOUND_META_USER_SHELL, InboundMessage, OutboundMessagefrom nanobot.command.builtin import cmd_user_shellfrom nanobot.command.router import CommandContext@@ -58,8 +59,8 @@ async def test_user_shell_uses_exec_tool_with_workspace_scope(assert request.workspace == tmp_pathreturn f"{tmp_path}\n\nExit code: 0"- tool = MagicMock()- tool.execute = AsyncMock(side_effect=execute)+ tool = MagicMock(spec=ExecTool)+ tool.execute_to_completion = AsyncMock(side_effect=execute)session = Session(key="websocket:chat", policy=SessionPolicy(log_content=log_content))scope = SimpleNamespace(project_path=tmp_path)loop = MagicMock()@@ -72,7 +73,7 @@ async def test_user_shell_uses_exec_tool_with_workspace_scope(response = await AgentLoop.execute_user_shell_command(loop, ctx)- tool.execute.assert_awaited_once_with(command="pwd", working_dir=str(tmp_path))+ tool.execute_to_completion.assert_awaited_once_with(command="pwd", working_dir=str(tmp_path))assert response.content.endswith("Exit code: 0")assert response.metadata["render_as"] == "text"assert current_request_context() is Nonediff --git a/tests/tools/test_exec_env.py b/tests/tools/test_exec_env.pyindex f623faad8..5521a36af 100644--- a/tests/tools/test_exec_env.py+++ b/tests/tools/test_exec_env.py@@ -62,7 +62,7 @@ async def test_exec_child_receives_filtered_env(monkeypatch, allowed_env_keys, easync def test_exec_has_working_path():"""Basic commands should be available via the login shell's PATH."""tool = ExecTool()- result = await tool.execute(command="echo hello")+ result = await tool.execute(command="echo hello", yield_time_ms=10000)assert "hello" in resultdiff --git a/tests/tools/test_exec_platform.py b/tests/tools/test_exec_platform.pyindex abced9710..c1e37e1a9 100644--- a/tests/tools/test_exec_platform.py+++ b/tests/tools/test_exec_platform.py@@ -7,6 +7,7 @@ platform-specific binaries (all subprocess calls are mocked).import asyncioimport os+import reimport shutilimport sysfrom unittest.mock import AsyncMock, MagicMock, patch@@ -876,10 +877,24 @@ class TestResolveShellWindows:)class TestWindowsRealExec:+ async def _execute(self, command, shell=None, **kwargs):+ manager = ExecSessionManager()+ try:+ initial = await ExecTool(session_manager=manager, **kwargs).execute(command=command, shell=shell)+ match = re.search(r"session_id:\s*([0-9a-f]+)", initial)+ if match is None:+ return initial+ final = await ExecSessionTool(manager=manager).execute(+ session_id=match.group(1), until_exit=True,+ )+ return initial + "\n" + final+ finally:+ await manager.close_all()+@pytest.mark.skipif(shutil.which("pwsh") is None, reason="requires PowerShell 7")@pytest.mark.asyncioasync def test_single_line_and_separator_uses_pwsh(self):- result = await ExecTool(timeout=10).execute(command="echo before && echo after")+ result = await self._execute(command="echo before && echo after", timeout=10)assert "before" in resultassert "after" in result@@ -887,7 +902,7 @@ class TestWindowsRealExec:@pytest.mark.asyncioasync def test_explicit_cmd_preserves_embedded_quotes(self):- result = await ExecTool(timeout=10).execute(command='echo "a & b"', shell="cmd")+ result = await self._execute(command='echo "a & b"', shell="cmd", timeout=10)assert '"a & b"' in resultassert r'\"a & b\"' not in result@@ -895,13 +910,14 @@ class TestWindowsRealExec:@pytest.mark.asyncioasync def test_default_powershell_preserves_native_exit_code(self):- result = await ExecTool(timeout=10).execute(command="cmd /c exit 7")+ result = await self._execute(command="cmd /c exit 7", timeout=10)assert "Exit code: 7" in result@pytest.mark.asyncioasync def test_windows_powershell_output_and_redirection_are_utf8(self, tmp_path):- result = await ExecTool(working_dir=str(tmp_path), timeout=180).execute(+ result = await self._execute(+ working_dir=str(tmp_path), timeout=180,command=("Write-Output 'file café λ 你好' > marker.txt; ""Write-Output 'café λ 你好'; "@@ -922,7 +938,8 @@ class TestWindowsRealExec:@pytest.mark.asyncioasync def test_windows_powershell_native_pipeline_input_is_utf8(self):python = sys.executable.replace("'", "''")- result = await ExecTool(timeout=180).execute(+ result = await self._execute(+ timeout=180,command=(f"[string][char]0x4F1A | & '{python}' "'-c "import sys; print(sys.stdin.buffer.read().hex())"'diff --git a/tests/tools/test_exec_security.py b/tests/tools/test_exec_security.pyindex 25e3c6c2e..0300d07a1 100644--- a/tests/tools/test_exec_security.py+++ b/tests/tools/test_exec_security.py@@ -124,7 +124,7 @@ async def test_exec_full_access_skips_command_guard(tmp_path, command):restrict_to_workspace=False,deny_patterns=[r"echo\s+blocked"],)- result = await tool.execute(command=command)+ result = await tool.execute(command=command, yield_time_ms=10000)assert "Exit code: 0" in resultassert "Command blocked" not in result@@ -136,7 +136,7 @@ async def test_exec_full_workspace_scope_skips_command_guard(tmp_path):token = bind_workspace_scope(scope)try:result = await tool.execute(- command="echo http://169.254.169.254/latest/meta-data/",+ command="echo http://169.254.169.254/latest/meta-data/", yield_time_ms=10000,)finally:reset_workspace_scope(token)@@ -148,7 +148,7 @@ async def test_exec_full_workspace_scope_skips_command_guard(tmp_path):@pytest.mark.asyncioasync def test_exec_allows_normal_commands():tool = ExecTool(timeout=5)- result = await tool.execute(command="echo hello")+ result = await tool.execute(command="echo hello", yield_time_ms=10000)assert "hello" in resultassert "Error" not in result.split("\n")[0]@@ -283,7 +283,7 @@ async def test_exec_allows_working_dir_within_workspace(tmp_path):subdir = workspace / "project"subdir.mkdir(parents=True)tool = ExecTool(working_dir=str(workspace), restrict_to_workspace=True, timeout=5)- result = await tool.execute(command="echo ok", working_dir=str(subdir))+ result = await tool.execute(command="echo ok", working_dir=str(subdir), yield_time_ms=10000)assert "ok" in resultassert "outside the configured workspace" not in result@@ -294,7 +294,7 @@ async def test_exec_allows_working_dir_equal_to_workspace(tmp_path):workspace = tmp_path / "workspace"workspace.mkdir()tool = ExecTool(working_dir=str(workspace), restrict_to_workspace=True, timeout=5)- result = await tool.execute(command="echo ok", working_dir=str(workspace))+ result = await tool.execute(command="echo ok", working_dir=str(workspace), yield_time_ms=10000)assert "ok" in resultassert "outside the configured workspace" not in result@@ -307,7 +307,7 @@ async def test_exec_ignores_workspace_check_when_not_restricted(tmp_path):other = tmp_path / "other"other.mkdir()tool = ExecTool(working_dir=str(workspace), restrict_to_workspace=False, timeout=5)- result = await tool.execute(command="echo ok", working_dir=str(other))+ result = await tool.execute(command="echo ok", working_dir=str(other), yield_time_ms=10000)assert "ok" in resultassert "outside the configured workspace" not in resultdiff --git a/tests/tools/test_exec_session_tools.py b/tests/tools/test_exec_session_tools.pyindex 0aa1b7800..4025451f7 100644--- a/tests/tools/test_exec_session_tools.py+++ b/tests/tools/test_exec_session_tools.py@@ -100,21 +100,89 @@ async def _poll_if_running(return initial, initialfinal = await tool.execute(session_id=_session_id(initial),- input="",+ until_exit=True,timeout_ms=timeout_ms,)return f"{initial}\n{final}", final-def test_exec_keeps_one_shot_behavior_without_yield_time_ms(tmp_path):[email protected]("diagnostic", [False, True], ids=["silent", "error-output"])+def test_exec_default_observation_returns_live_session(tmp_path, diagnostic):+ async def run() -> None:+ manager = ExecSessionManager()+ tool = ExecTool(working_dir=str(tmp_path), timeout=20, session_manager=manager)+ observer = ExecSessionTool(manager=manager)+ release = tmp_path / "release"+ command = _python_command(+ "import sys,time\n"+ "from pathlib import Path\n"+ "assert sys.stdin.read() == ''\n"+ + ("print('locator failed', file=sys.stderr, flush=True)\n" if diagnostic else "")+ + "print('ready with stdin EOF', flush=True)\n"+ "while not Path('release').exists(): time.sleep(0.01)\n"+ "print('released', flush=True)\n"+ "sys.exit(7)"+ )+ try:+ initial = await asyncio.wait_for(tool.execute(command=command), timeout=5)+ sid = _session_id(initial)+ assert "Initial wait ended; session remains active." in initial+ assert "Elapsed:" in initial+ assert "Runtime remaining:" in initial+ combined = initial+ expected = ["ready with stdin EOF"]+ if diagnostic:+ expected.append("locator failed")+ for marker in expected:+ if marker not in combined:+ combined += await observer.execute(session_id=sid, wait_for=marker)+ assert "ready with stdin EOF" in combined+ if diagnostic:+ assert "locator failed" in combined+ assert "released" not in combined+ release.touch()+ final = await observer.execute(session_id=sid, until_exit=True, timeout_ms=5000)+ assert "released" in final+ assert "Exit code: 7" in final+ finally:+ release.touch()+ await manager.close_all()++ asyncio.run(run())+++def test_exec_short_command_returns_output_and_exit_code(tmp_path):async def run() -> str:- tool = ExecTool(working_dir=str(tmp_path), timeout=5)- return await tool.execute(command="echo hello")+ manager = ExecSessionManager()+ tool = ExecTool(working_dir=str(tmp_path), timeout=5, session_manager=manager)+ try:+ initial = await tool.execute(command="echo hello")+ combined, _ = await _poll_if_running(initial, ExecSessionTool(manager=manager), timeout_ms=5000)+ return combined+ finally:+ await manager.close_all()result = asyncio.run(run())assert "hello" in resultassert "Exit code: 0" in result+++def test_trusted_user_shell_waits_for_complete_result(tmp_path):+ async def run() -> str:+ manager = ExecSessionManager()+ tool = ExecTool(working_dir=str(tmp_path), timeout=10, session_manager=manager)+ try:+ return await tool.execute_to_completion(+ command=_python_command("import time,sys; time.sleep(1.2); print('user result'); sys.exit(7)"),+ working_dir=str(tmp_path),+ )+ finally:+ await manager.close_all()++ result = asyncio.run(run())+ assert "user result" in result+ assert "Exit code: 7" in resultassert "session_id:" not in result@@ -123,7 +191,7 @@ def test_exec_accepts_command_aliases(tmp_path):tool = ExecTool(working_dir="/")return await tool.execute(cmd=_python_command("import os; print(os.getcwd())"),- workdir=str(tmp_path),+ workdir=str(tmp_path), yield_time_ms=10000,)result = asyncio.run(run())@@ -342,7 +410,7 @@ def test_exec_one_shot_accepts_max_output_tokens_alias(tmp_path):async def run() -> str:tool = ExecTool(working_dir=str(tmp_path), timeout=5)command = _python_command("print('A' * 2000)")- return await tool.execute(command=command, max_output_tokens=1000)+ return await tool.execute(command=command, max_output_tokens=1000, yield_time_ms=10000)result = asyncio.run(run())diff --git a/tests/tools/test_rg_tool.py b/tests/tools/test_rg_tool.pyindex c2755c92d..b1794414c 100644--- a/tests/tools/test_rg_tool.py+++ b/tests/tools/test_rg_tool.py@@ -181,6 +181,7 @@ async def test_direct_process_preserves_arguments_and_output_limit(tmp_path):async def test_direct_process_timeout(tmp_path):result = await ExecTool(working_dir=str(tmp_path)).execute(command=[sys.executable, "-c", "import time; time.sleep(20)"], timeout=1,+ yield_time_ms=5000,)assert "Reason: max_runtime" in resultassert "Exit code:" in resultdiff --git a/tests/tools/test_shell_execution_budgets.py b/tests/tools/test_shell_execution_budgets.pyindex 33d2aa353..f9ccd72e0 100644--- a/tests/tools/test_shell_execution_budgets.py+++ b/tests/tools/test_shell_execution_budgets.py@@ -167,9 +167,12 @@ async def test_trusted_default_runtime_can_exceed_model_request_limit():max_runtime=12, max_runtime_limit=1, idle_timeout=0, session_manager=manager,)try:- result = await tool.execute(command=_python(+ initial = await tool.execute(command=_python("import time; time.sleep(1.2); print('trusted default completed')"))+ result = await ExecSessionTool(manager=manager).execute(+ session_id=_session_id(initial), until_exit=True, timeout_ms=5000,+ )assert not is_tool_error_result(result), resultassert "trusted default completed" in result@@ -469,7 +472,9 @@ async def test_execution_stop_stops_pipe_inheriting_child_after_root_exits(initial_exec_task = Nonetry:with request_context(owner):- initial_exec_task = asyncio.create_task(tool.execute(command=_python(parent_code)))+ initial_exec_task = asyncio.create_task(tool.execute(+ command=_python(parent_code), yield_time_ms=10000,+ ))await asyncio.wait_for(spawn_returned.wait(), timeout=5)parent_pid = int(await _file_text(parent_pidfile))child_pid = int(await _file_text(child_pidfile))@@ -509,7 +514,7 @@ async def test_execution_stop_stops_pipe_inheriting_child_after_root_exits(await asyncio.gather(initial_exec_task, return_exceptions=True)-async def test_inline_work_reports_silence_then_hits_same_fixed_hard_budget(tmp_path):+async def test_default_yield_reports_silence_then_hits_same_fixed_hard_budget(tmp_path):pidfile = tmp_path / "process.pid"gate = tmp_path / "emit-output"ticks = tmp_path / "ticks"@@ -540,13 +545,17 @@ async def test_inline_work_reports_silence_then_hits_same_fixed_hard_budget(tmp_assert len(_listed_ids(listing)) == 1, listingassert "| running |" in listingassert (await manager.list())[0].idle_s >= 1- assert not inline_task.done()+ initial = await asyncio.wait_for(inline_task, timeout=2)+ sid = _session_id(initial)+ assert _listed_ids(listing) == [sid]assert _pid_running(pid)gate.write_text("emit")assert int(await _file_text(ticks)) >= 1+ final = await ExecSessionTool(manager=manager).execute(+ session_id=sid, until_exit=True, timeout_ms=6000,+ )await _pid_stopped(pid)- final = await asyncio.wait_for(inline_task, timeout=3)assert is_tool_error_result(final), finalassert "inline-progress:" in final@@ -588,7 +597,7 @@ async def test_owner_close_stops_inline_tree_and_preserves_other_owner_work(tmp_try:with request_context(owner_a):inline_task = asyncio.create_task(tool.execute(- command=_python(_waiting_tree(parent_pidfile, child_pidfile)),+ command=_python(_waiting_tree(parent_pidfile, child_pidfile)), yield_time_ms=10000,))parent_pid = int(await _file_text(parent_pidfile))child_pid = int(await _file_text(child_pidfile))diff --git a/tests/tools/test_shell_reap.py b/tests/tools/test_shell_reap.pyindex ba477def9..a7fa4fedf 100644--- a/tests/tools/test_shell_reap.py+++ b/tests/tools/test_shell_reap.py@@ -171,7 +171,9 @@ async def test_execute_timeout_kills_and_reaps():):try:result = await asyncio.wait_for(- ExecTool(timeout=1, session_manager=manager).execute(command="sleep 99", timeout=1),+ ExecTool(timeout=1, session_manager=manager).execute(+ command="sleep 99", timeout=1, yield_time_ms=5000,+ ),timeout=5,)finally:@@ -193,16 +195,16 @@ async def test_execute_cancellation_kills_process_tree():process = _MockProcess(pid=1005, returncode=None)manager = ExecSessionManager()waiting = asyncio.Event()- wait_exit = _ExecSession.wait_exit+ poll = _ExecSession.poll- async def inline_wait(session: _ExecSession) -> None:+ async def initial_poll(session: _ExecSession, *args, **kwargs):waiting.set()- await wait_exit(session)+ return await poll(session, *args, **kwargs)with (patch.object(ExecTool, "_spawn", return_value=process) as spawn,patch.object(ExecTool, "_kill_process_tree", side_effect=ExecTool._kill_process) as kill_tree,- patch.object(_ExecSession, "wait_exit", new=inline_wait),+ patch.object(_ExecSession, "poll", new=initial_poll),patch("nanobot.agent.tools.shell._reap_pid") as reap,):execution = asyncio.create_task(@@ -375,6 +377,7 @@ async def test_execute_timeout_kills_background_process_tree(tmp_path):result = await ExecTool(working_dir=str(tmp_path), timeout=1).execute(command=command,timeout=1,+ yield_time_ms=5000,)assert "timed out" in result.lower()@@ -555,7 +558,7 @@ async def test_real_timeout_leaves_no_zombie(tmp_path):import ostool = ExecTool(working_dir=str(tmp_path), timeout=1)- result = await tool.execute(command="sleep 30", timeout=1)+ result = await tool.execute(command="sleep 30", timeout=1, yield_time_ms=5000)assert "timed out" in result.lower()await asyncio.sleep(0.05)diff --git a/tests/tools/test_tool_descriptions.py b/tests/tools/test_tool_descriptions.pyindex 1cbecf139..c105b688b 100644--- a/tests/tools/test_tool_descriptions.py+++ b/tests/tools/test_tool_descriptions.py@@ -65,7 +65,8 @@ def test_exec_tool_descriptions_are_concise() -> None:assert ListExecSessionsTool().description == "List active exec sessions."exec_parameters = ExecTool().parameters["properties"]- assert "omit to wait for exit" in exec_parameters["yield_time_ms"]["description"]+ assert "default 1000" in exec_parameters["yield_time_ms"]["description"]+ assert "execution continues" in exec_parameters["yield_time_ms"]["description"]runtime_description = exec_parameters["max_runtime"]["description"].lower()assert "hard" in runtime_descriptionassert "seconds" in runtime_description@@ -83,7 +84,7 @@ def test_exec_tool_descriptions_are_concise() -> None:"until_exit","timeout_ms",}- assert session_parameters["until_exit"]["description"] == "Wait for the process to exit."+ assert "within timeout_ms" in session_parameters["until_exit"]["description"]assert "wait_for" in session_parameters["timeout_ms"]["description"]assert "until_exit" in session_parameters["timeout_ms"]["description"]diff --git a/tests/tools/test_tool_validation.py b/tests/tools/test_tool_validation.pyindex 041f72c2c..18102c553 100644--- a/tests/tools/test_tool_validation.py+++ b/tests/tools/test_tool_validation.py@@ -457,7 +457,7 @@ async def test_exec_allows_resolved_home_inside_workspace(tmp_path, monkeypatch)(tmp_path / "file.txt").write_text("allowed home content", encoding="utf-8")result = await ExecTool(working_dir=str(tmp_path), restrict_to_workspace=True,- ).execute(command="cat ~/file.txt", login=False)+ ).execute(command="cat ~/file.txt", login=False, yield_time_ms=10000)assert "allowed home content" in resultassert "Exit code: 0" in result@@ -939,10 +939,10 @@ def test_cast_params_single_value_not_auto_wrapped_to_array() -> None:# --- ExecTool enhancement tests ----async def test_exec_always_returns_exit_code() -> None:- """Exit code should appear in output even on success (exit 0)."""+async def test_completed_exec_returns_exit_code() -> None:+ """Completed output includes the exit code even on success (exit 0)."""tool = ExecTool()- result = await tool.execute(command="echo hello")+ result = await tool.execute(command="echo hello", yield_time_ms=10000)assert "Exit code: 0" in resultassert "hello" in result@@ -964,7 +964,7 @@ async def test_exec_head_tail_truncation(tmp_path) -> None:command = subprocess.list2cmdline([sys.executable, str(script_file)])else:command = f"{shlex.quote(sys.executable)} {shlex.quote(str(script_file))}"- result = await tool.execute(command=command)+ result = await tool.execute(command=command, yield_time_ms=10000)assert "chars truncated" in result# Head portion should start with Asassert result.startswith("A")@@ -979,6 +979,7 @@ async def test_exec_timeout_parameter(runtime_parameter) -> None:started_at = time.monotonic()result = await tool.execute(command=[sys.executable, "-c", "import time; time.sleep(10)"],+ yield_time_ms=5000,**{runtime_parameter: 1},)