t8y2/dbx · error

response id %d does not match request id %d

Error message

response id %d does not match request id %d

What it means

The harness correlates responses to requests by incrementing nextID; if the JSON-RPC response's id field does not equal the id just sent, call returns this mismatch error. It indicates responses are being interleaved, duplicated, or shifted.

Source

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

		"method":  method,
		"params":  params,
	}
	payload, err := json.Marshal(request)
	if err != nil {
		return nil, err
	}
	if _, err := process.stdin.Write(append(payload, '\n')); err != nil {
		return nil, err
	}
	if !process.reader.Scan() {
		return nil, fmt.Errorf("agent response unavailable: %v", process.reader.Err())
	}
	var response agentResponse
	if err := json.Unmarshal(process.reader.Bytes(), &response); err != nil {
		return nil, err
	}
	if response.ID != process.nextID {
		return nil, fmt.Errorf("response id %d does not match request id %d", response.ID, process.nextID)
	}
	if response.Error != nil {
		return nil, errors.New(response.Error.Message)
	}
	return response.Result, nil
}

func (process *agentProcess) close() error {
	_, callError := process.call("shutdown", map[string]any{})
	_ = process.stdin.Close()
	waitError := process.command.Wait()
	if callError != nil {
		return callError
	}
	return waitError
}

func (process *agentProcess) kill() {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Ensure the agent writes only JSON-RPC response lines to stdout (logs to stderr)
  2. Check each agent response echoes the request's id field unchanged
  3. Verify requests are strictly sequential on the single stdin pipe
  4. Look for notification/broadcast messages the agent emits outside request/response pairs

Example fix

// agent: wrong
go func() { fmt.Println(`{"event":"tick"}`) }() // pollutes stdout
// after
// emit only responses; log to stderr
fmt.Fprintf(os.Stderr, "tick\n")
Defensive patterns

Strategy: validation

Validate before calling

// client-side: preflight that the agent echoes ids
callCtx := process
resp, err := process.call("connect", testParams)
_ = callCtx
if err == nil && resp == nil {
    return errors.New("agent returned empty result on handshake")
}

Try / catch

res, err := process.call(method, params)
if err != nil && strings.Contains(err.Error(), "does not match request id") {
    log.Fatalf("protocol desync: %v", err)
}

Prevention

When it happens

Trigger: The agent emits extra stdout lines (logs, notifications) so the harness reads a line out of order, or the agent echoes a stale/zero id in its response.

Common situations: Agent logging to stdout between responses desynchronizing line framing; a concurrent call pattern the single-threaded harness doesn't expect; agent bug echoing request id 0.

Related errors


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