{"record":{"id":"e8273a2e3e8859cc","repo":"t8y2/dbx","slug":"timed-out-waiting-for-agent-readiness","errorCode":null,"errorMessage":"timed out waiting for agent readiness","messagePattern":"timed out waiting for agent readiness","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/bench/agent_compare.py","lineNumber":46,"sourceCode":"            candidate.command,\n            stdin=subprocess.PIPE,\n            stdout=subprocess.PIPE,\n            stderr=subprocess.PIPE,\n            text=True,\n            bufsize=1,\n        )\n        self.request_id = 0\n        self.request_lock = threading.Lock()\n        self.write_lock = threading.Lock()\n        self.pending: dict[int, queue.Queue] = {}\n        self.ready = threading.Event()\n        self.saw_ready = False\n        self.exited = threading.Event()\n        self.stderr_lines: list[str] = []\n        threading.Thread(target=self._read_stdout, daemon=True).start()\n        threading.Thread(target=self._drain_stderr, daemon=True).start()\n        if not self.ready.wait(env_float(\"BENCH_READY_TIMEOUT\", 30.0)) or not self.saw_ready:\n            raise TimeoutError(self._failure(\"timed out waiting for agent readiness\"))\n\n    def _read_stdout(self) -> None:\n        assert self.process.stdout is not None\n        for line in self.process.stdout:\n            try:\n                response = json.loads(line)\n            except json.JSONDecodeError:\n                continue\n            if response.get(\"ready\") is True:\n                self.saw_ready = True\n                self.ready.set()\n                continue\n            response_id = response.get(\"id\")\n            if not isinstance(response_id, int):\n                continue\n            with self.request_lock:\n                response_queue = self.pending.get(response_id)\n            if response_queue is not None:","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/bench/agent_compare.py#L28-L64","documentation":"The bench agent driver's __init__ starts the agent subprocess, spawns stdout/stderr reader threads, and waits on a readiness event; if readiness is not signaled within BENCH_READY_TIMEOUT (default 30s) or the ready line was never seen, it raises TimeoutError with the collected failure context.","triggerScenarios":"Agent process fails to print its readiness line within the timeout because it crashed, hung, is slow to load a large model, or the ready protocol changed; process exits early and saw_ready stays False.","commonSituations":"First run downloading weights or warming up exceeds 30s; wrong agent command/args so the process dies; broken ready-line handshake after an agent version update; missing API key causing the agent to exit immediately.","solutions":["Raise the timeout: set BENCH_READY_TIMEOUT to e.g. 120 (env_float, seconds)","Inspect the captured stderr/failure output in the TimeoutError to find why the agent never became ready","Verify the agent command/args and that its ready-line format still matches what _read_stdout expects"],"exampleFix":"// before\nagent = ArgoAgent(cmd, args)  # times out after 30s on cold start\n// after\nimport os\nos.environ[\"BENCH_READY_TIMEOUT\"] = \"180\"\nagent = ArgoAgent(cmd, args)","handlingStrategy":"try-catch","validationCode":"timeout_s = float(os.environ.get('BENCH_READY_TIMEOUT', '30'))\nif expected_warmup_seconds > timeout_s:\n    os.environ['BENCH_READY_TIMEOUT'] = str(expected_warmup_seconds + 60)","typeGuard":null,"tryCatchPattern":"try:\n    agent = ArgoAgent(cmd, args)\nexcept TimeoutError as e:\n    print(e)  # includes collected stderr/failure context\n    print('agent failed to become ready; check command, args, and BENCH_READY_TIMEOUT')\n    raise SystemExit(1)","preventionTips":["Increase BENCH_READY_TIMEOUT for cold starts / model loads","Validate the agent command and API keys before launching","Confirm the agent's ready-line protocol matches the driver","Capture and review stderr on failure"],"tags":["timeout","subprocess","benchmark","readiness"],"backgroundTag":"process-startup-timeout","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}