from __future__ import annotations from runtime.executor import Executor, ExecutorConfig from runtime.planner import PlannedStep def test_executor_retries_until_transient_tool_succeeds() -> None: calls = {"count": 0} def flaky_tool() -> dict[str, bool]: calls["count"] += 1 if calls["count"] < 3: raise RuntimeError("transient") return {"ok": True} executor = Executor( tools={"flaky": flaky_tool}, config=ExecutorConfig(max_retries=3, backoff_seconds=0), ) result = executor.execute(PlannedStep(action="flaky", description="retry")) assert result.success is True assert result.attempts == 3 assert result.result == {"ok": True}