t8y2/dbx · error · TimeoutError

timed out waiting for agent readiness

Error message

timed out waiting for agent readiness

What it means

_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').

Source

Thrown at agents/drivers/cassandra-go/bench/agent_compare.py:55

    def _drain_stderr(self) -> None:
        assert self.process.stderr is not None
        for line in self.process.stderr:
            self.stderr_lines.append(line.rstrip())

    def _wait_ready(self) -> None:
        assert self.process.stdout is not None
        deadline = time.monotonic() + env_float("BENCH_READY_TIMEOUT", 30.0)
        while time.monotonic() < deadline:
            line = self.process.stdout.readline()
            if line == "" and self.process.poll() is not None:
                raise RuntimeError(self._failure("agent exited before ready"))
            try:
                if json.loads(line).get("ready") is True:
                    return
            except (json.JSONDecodeError, AttributeError):
                continue
        raise TimeoutError(self._failure("timed out waiting for agent readiness"))

    def call(self, method: str, params: dict | None = None) -> dict:
        self.request_id += 1
        request = {
            "jsonrpc": "2.0",
            "id": self.request_id,
            "method": method,
            "params": params or {},
        }
        assert self.process.stdin is not None
        assert self.process.stdout is not None
        self.process.stdin.write(json.dumps(request, separators=(",", ":")) + "\n")
        self.process.stdin.flush()
        while True:
            line = self.process.stdout.readline()
            if line == "" and self.process.poll() is not None:
                raise RuntimeError(self._failure(f"agent exited during {method}"))
            try:

View on GitHub (pinned to c0390bff16)

Solutions

  1. Increase the timeout: export BENCH_READY_TIMEOUT=60 (or higher)
  2. Ensure the agent's dependency (e.g. Cassandra) is up before running the bench
  3. Check the agent is not blocked or writing non-JSON noise to stdout
  4. Investigate why the agent hangs at startup (strace/logs)

Example fix

// before
BENCH_READY_TIMEOUT=30 python agent_compare.py
// after
BENCH_READY_TIMEOUT=120 python agent_compare.py
Defensive patterns

Strategy: validation

Validate before calling

# preflight: make sure dependencies are reachable before starting the agent
def dependency_ready(host: str, port: int, timeout: float = 5.0) -> bool:
    import socket
    try:
        with socket.create_connection((host, port), timeout=timeout):
            return True
    except OSError:
        return False

assert dependency_ready(os.getenv("CASSANDRA_HOST", "127.0.0.1"), 9042), "Cassandra not up"
# and give slow CI runners headroom:
# BENCH_READY_TIMEOUT=120

Try / catch

try:
    agent = AgentProcess(cmd)
except TimeoutError as exc:
    if "readiness" in str(exc):
        print("agent still alive but not ready; check its logs, or raise BENCH_READY_TIMEOUT")
        agent.kill()
        sys.exit(3)
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/aeb15e8a5733b927. Report an issue: GitHub.