Skip to content

feat(acp): per-turn stage latency instrumentation (#2386) - #2460

Open
brocoppler wants to merge 1 commit into
block:mainfrom
brocoppler:feat/acp-turn-stage-timing
Open

feat(acp): per-turn stage latency instrumentation (#2386)#2460
brocoppler wants to merge 1 commit into
block:mainfrom
brocoppler:feat/acp-turn-stage-timing

Conversation

@brocoppler

Copy link
Copy Markdown

What this solves

First slice of #2386: stage-level timing for the mention-to-reply path, keyed by the existing turn_id. Answers "which stage was slow" for stages 1–5 of the issue's boundary list.

Stages measured

  • relayLagSecs — relay accept → harness receipt (wall clock, 1s resolution, from event created_at)
  • admissionMs — receipt → queue admission (gates: owner-command, author, rule match, follow policy)
  • queueWaitMs — admission → turn dispatch (oldest batch event)
  • sessionSetupMs + sessionReused — dispatch → ACP session resolved; warm/cold split per the issue's benchmark axes
  • firstOutputMs — prompt write → first agent_message_chunk
  • turnTotalMs — dispatch → turn completion

All monotonic-clock except relay lag; all optional; no message content in any telemetry.

Carriers

  1. kind:44200 AgentTurnMetricPayload — new optional camelCase fields (skip_serializing_if, backward-compatible; consumers already MUST ignore unknown fields). NIP-AM.md updated.
  2. turn_completed observer frame — carries the same timings instead of {}.
  3. One tracing::info! summary line per turn (pool::metrics, keyed by turn_id, outcome + *_ms fields) for log-based analysis.

Out of scope, per the issue's own split

Testing

cargo test -p buzz-acp and -p buzz-core green (new tests: queue field threading through flush/requeue, timing finalization at turn exit, first-output mark/drain, payload serde round-trip incl. omission); clippy -D warnings clean across both crates; fmt clean; workspace check green.

🤖 Generated with Claude Code

Measure each turn's pipeline stages: relay-accept lag (wall clock, 1s),
admission (receipt -> queue), queue wait (receipt -> dispatch), session
setup, first model output, and turn total, threaded from the relay loop
through QueuedEvent/BatchEvent into run_prompt_task. Emitted on three
carriers keyed by turn_id: optional kind:44200 payload fields, the
turn_completed observer frame, and one pool::metrics info summary line.
Reply-publish/relay-OK stages are out-of-band today (block#2459 tracks that
observability).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Broc Oppler <brocoppler@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant