Tool that exceeds `TOOL_TIMEOUT` yields with `is_error=True` and a `"timed out"` message — distinct from the generic exception path.
(monkeypatch: pytest.MonkeyPatch)
| 1888 | |
| 1889 | @pytest.mark.asyncio() |
| 1890 | async def test_tool_timeout(monkeypatch: pytest.MonkeyPatch) -> None: |
| 1891 | """Tool that exceeds `TOOL_TIMEOUT` yields with `is_error=True` and a |
| 1892 | `"timed out"` message — distinct from the generic exception path.""" |
| 1893 | monkeypatch.setattr(session_runner_mod, "TOOL_TIMEOUT", 0.05) |
| 1894 | |
| 1895 | async def slow(_input: dict[str, Any]) -> str: |
| 1896 | await asyncio.Event().wait() # never resolves |
| 1897 | return "never" |
| 1898 | |
| 1899 | tool = _FakeTool("slow", slow) |
| 1900 | events = FakeAsyncEvents(stream_events=[_tool_use("tu_1", "slow", {}), _terminated()]) |
| 1901 | |
| 1902 | items = [item async for item in _run_with_fakes(events=events, tools=[tool])] |
| 1903 | |
| 1904 | assert len(items) == 1 |
| 1905 | assert items[0].is_error is True |
| 1906 | assert "timed out" in _result_text(items[0]) |
| 1907 | |
| 1908 | |
| 1909 | @pytest.mark.asyncio() |
nothing calls this directly
no test coverage detected