AgentClient.start() crashes with 'RuntimeError: Event loop is closed' on the second call in the same process.
httpx.AsyncClient is cached as an instance variable. Each call to start() goes through asyncio.run() which creates and closes a new event loop. The cached client's transport is bound to the old closed loop, so the next call fails when httpx tries to use it.
Repro: call runtime.client.start(agent, prompt) twice in the same process — second call blows up. Confirmed by test_suite24 test_start_returns_handle_then_joins.
Fix is to check the current loop id in _get_client() and recreate the client if the loop has changed.
AgentClient.start() crashes with 'RuntimeError: Event loop is closed' on the second call in the same process.
httpx.AsyncClient is cached as an instance variable. Each call to start() goes through asyncio.run() which creates and closes a new event loop. The cached client's transport is bound to the old closed loop, so the next call fails when httpx tries to use it.
Repro: call runtime.client.start(agent, prompt) twice in the same process — second call blows up. Confirmed by test_suite24 test_start_returns_handle_then_joins.
Fix is to check the current loop id in _get_client() and recreate the client if the loop has changed.