{"record":{"id":"aeb15e8a5733b927","repo":"t8y2/dbx","slug":"timed-out-waiting-for-agent-readiness-aeb15e","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/cassandra-go/bench/agent_compare.py","lineNumber":55,"sourceCode":"\n    def _drain_stderr(self) -> None:\n        assert self.process.stderr is not None\n        for line in self.process.stderr:\n            self.stderr_lines.append(line.rstrip())\n\n    def _wait_ready(self) -> None:\n        assert self.process.stdout is not None\n        deadline = time.monotonic() + env_float(\"BENCH_READY_TIMEOUT\", 30.0)\n        while time.monotonic() < deadline:\n            line = self.process.stdout.readline()\n            if line == \"\" and self.process.poll() is not None:\n                raise RuntimeError(self._failure(\"agent exited before ready\"))\n            try:\n                if json.loads(line).get(\"ready\") is True:\n                    return\n            except (json.JSONDecodeError, AttributeError):\n                continue\n        raise TimeoutError(self._failure(\"timed out waiting for agent readiness\"))\n\n    def call(self, method: str, params: dict | None = None) -> dict:\n        self.request_id += 1\n        request = {\n            \"jsonrpc\": \"2.0\",\n            \"id\": self.request_id,\n            \"method\": method,\n            \"params\": params or {},\n        }\n        assert self.process.stdin is not None\n        assert self.process.stdout is not None\n        self.process.stdin.write(json.dumps(request, separators=(\",\", \":\")) + \"\\n\")\n        self.process.stdin.flush()\n        while True:\n            line = self.process.stdout.readline()\n            if line == \"\" and self.process.poll() is not None:\n                raise RuntimeError(self._failure(f\"agent exited during {method}\"))\n            try:","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/bench/agent_compare.py#L37-L73","documentation":"_wait_ready waits up to BENCH_READY_TIMEOUT seconds (default 30) for the agent to print its ready line. If the deadline passes while the agent is still alive but not ready, it raises TimeoutError('timed out waiting for agent readiness').","triggerScenarios":"Agent starts but never prints {\"ready\": true} within BENCH_READY_TIMEOUT seconds — slow startup, blocked on a dependency (DB not up), or prints non-JSON output that is skipped.","commonSituations":"Cassandra/dependency still initializing; agent stuck on network wait; underpowered CI machine needing more than 30s; agent logging human-readable text instead of JSON on stdout.","solutions":["Increase the timeout: export BENCH_READY_TIMEOUT=60 (or higher)","Ensure the agent's dependency (e.g. Cassandra) is up before running the bench","Check the agent is not blocked or writing non-JSON noise to stdout","Investigate why the agent hangs at startup (strace/logs)"],"exampleFix":"// before\nBENCH_READY_TIMEOUT=30 python agent_compare.py\n// after\nBENCH_READY_TIMEOUT=120 python agent_compare.py","handlingStrategy":"validation","validationCode":"# preflight: make sure dependencies are reachable before starting the agent\ndef dependency_ready(host: str, port: int, timeout: float = 5.0) -> bool:\n    import socket\n    try:\n        with socket.create_connection((host, port), timeout=timeout):\n            return True\n    except OSError:\n        return False\n\nassert dependency_ready(os.getenv(\"CASSANDRA_HOST\", \"127.0.0.1\"), 9042), \"Cassandra not up\"\n# and give slow CI runners headroom:\n# BENCH_READY_TIMEOUT=120","typeGuard":null,"tryCatchPattern":"try:\n    agent = AgentProcess(cmd)\nexcept TimeoutError as exc:\n    if \"readiness\" in str(exc):\n        print(\"agent still alive but not ready; check its logs, or raise BENCH_READY_TIMEOUT\")\n        agent.kill()\n        sys.exit(3)\n    raise","preventionTips":["Start dependencies (Cassandra etc.) before the bench and wait for them to be reachable","Raise BENCH_READY_TIMEOUT on slow or shared CI runners","Ensure the agent prints pure JSON lines on stdout (no human-readable logging)","Monitor agent startup logs to detect hangs early"],"tags":["python","subprocess","timeout","ipc"],"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"}