t8y2/dbx · error

agent did not become ready: %v

Error message

agent did not become ready: %v

What it means

startAgent launches the agent and waits for its first stdout line as a readiness signal. If the bufio scanner fails (Scan returns false), the process is killed and this error wraps the scanner's Err, meaning stdout closed/errored before a readiness line was produced.

Source

Thrown at agents/drivers/rabbitmq/bench/agent_compare.go:324

	stdin, err := process.command.StdinPipe()
	if err != nil {
		return nil, 0, err
	}
	stdout, err := process.command.StdoutPipe()
	if err != nil {
		return nil, 0, err
	}
	process.command.Stderr = os.Stderr
	process.stdin = stdin
	process.reader = bufio.NewScanner(stdout)
	process.reader.Buffer(make([]byte, 64*1024), 512*1024*1024)
	start := time.Now()
	if err := process.command.Start(); err != nil {
		return nil, 0, err
	}
	if !process.reader.Scan() {
		process.kill()
		return nil, 0, fmt.Errorf("agent did not become ready: %v", process.reader.Err())
	}
	if !strings.Contains(process.reader.Text(), `"ready":true`) {
		process.kill()
		return nil, 0, fmt.Errorf("agent did not become ready: %s", process.reader.Text())
	}
	return process, time.Since(start), nil
}

func (process *agentProcess) call(method string, params map[string]any) (json.RawMessage, error) {
	process.nextID++
	request := map[string]any{
		"jsonrpc": "2.0",
		"id":      process.nextID,
		"method":  method,
		"params":  params,
	}
	payload, err := json.Marshal(request)
	if err != nil {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Read the wrapped reader.Err() and run the agent manually to see its startup output
  2. Confirm the agent prints {"ready":true,...} to stdout as its first line
  3. Fix missing/invalid startup configuration (env vars, config file) that crashes the agent
  4. Rebuild the agent binary for the current OS/arch

Example fix

// agent main: ensure readiness is written to stdout first
fmt.Println(`{"ready":true}`)
// before any heavy work that can fail
// after
if err := initBroker(); err != nil { fmt.Fprintln(os.Stderr, err); os.Exit(1) }
fmt.Println(`{"ready":true}`)
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec.Command(agent.Command, "--selfcheck").CombinedOutput()
if err != nil {
    return fmt.Errorf("agent %q fails selfcheck: %v: %s", agent.Command, err, out)
}

Try / catch

process, _, err := startAgent(agent.Command)
if err != nil && strings.Contains(err.Error(), "agent did not become ready") {
    log.Fatalf("agent startup failed, check stderr/config: %v", err)
}

Prevention

When it happens

Trigger: The agent process exits immediately (bad flags, missing config, unhandled panic) or its stdout closes before printing the ready line, so reader.Scan() returns false and reader.Err() is non-nil (or io.EOF with no line).

Common situations: Agent binary built for wrong platform; agent panics at boot due to missing RabbitMQ DSN env var; agent writes its ready line to stderr instead of stdout.

Related errors


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