fix(exec): return early when session command exits
This commit is contained in:
@@ -5,6 +5,7 @@ import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
from nanobot.agent.tools.exec_session import (
|
||||
ExecSessionManager,
|
||||
@@ -76,6 +77,23 @@ def test_exec_returns_completed_session_output_when_yield_time_ms_is_used(tmp_pa
|
||||
assert "session_id:" not in result
|
||||
|
||||
|
||||
def test_exec_session_yield_returns_when_process_finishes_early(tmp_path):
|
||||
async def run() -> tuple[str, float]:
|
||||
manager = ExecSessionManager()
|
||||
tool = ExecTool(working_dir=str(tmp_path), timeout=5, session_manager=manager)
|
||||
command = _python_command("import time; time.sleep(0.1); print('done')")
|
||||
started = time.monotonic()
|
||||
result = await tool.execute(command=command, yield_time_ms=1200)
|
||||
return result, time.monotonic() - started
|
||||
|
||||
result, elapsed = asyncio.run(run())
|
||||
|
||||
assert "done" in result
|
||||
assert "Exit code: 0" in result
|
||||
assert "session_id:" not in result
|
||||
assert elapsed < 1.0
|
||||
|
||||
|
||||
def test_exec_session_accepts_max_output_tokens_alias(tmp_path):
|
||||
async def run() -> str:
|
||||
manager = ExecSessionManager()
|
||||
|
||||
Reference in New Issue
Block a user