Skip to content

feat(acp): show where reply time goes after an agent @mention - #6637

Open
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:agent/mention-reply-latency
Open

feat(acp): show where reply time goes after an agent @mention#6637
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:agent/mention-reply-latency

Conversation

@BradGroux

Copy link
Copy Markdown
Contributor

Note: This is a replacement for PR #2408, which was accidentally closed when branches were force-pushed after a commit identity rewrite. The changes are identical, rebased onto the latest main.

Refs #2386.

Why this PR exists

Four simple agent replies in #2386 took 13–31 seconds, but the available event timestamps only showed the beginning and end of each turn. That left no way to tell whether the delay happened in queueing, runtime startup, model work, or reply publication.

This PR adds the first in-process timing slice after Buzz receives the mention.

What changed

  • Record process-local monotonic boundaries for relay receipt, queue admission, ACP session resolution, prompt dispatch, first semantic model or tool output, first reply fan-out, and turn completion.
  • Correlate those boundaries into content-free mention_reply_latency samples.
  • Report rolling warm/cold p50, p95, and max summaries for each stage.
  • Let observer-enabled mention subscriptions receive self-authored kind-9 replies for telemetry while preserving the normal self-dispatch guard.
  • Prefer signed parent/root correlation over whichever turn is currently active, so delayed relay fanout cannot be assigned to a newer turn.
  • Treat unmatched signed thread tags as authoritative negative evidence instead of falling back to the active turn.
  • Use channel fallback only for replies with no signed thread tags, and fail closed when more than one turn is possible.
  • Document a deterministic check and an opt-in warm/cold live benchmark.

What this measures

This slice measures harness_relay_receipt through harness_relay_fanout. It does not claim sender-publish-to-recipient-render timing.

Durations come from one process-local monotonic clock. RFC3339 and Nostr timestamps are correlation metadata only.

The new semantic timing events contain identifiers, path classification, durations, and sample counts. They do not include message content, prompts, model output, credentials, or tool arguments. Existing raw acp_read and acp_write observer events are unchanged and remain outside this new redaction guarantee.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -p buzz-acp --all-targets --all-features -- -D warnings
  • cargo test -p buzz-acp --no-fail-fast with ambient lazy-pool overrides removed: 673 library tests and 9 pool-lifecycle tests passed.
  • just ci passed formatting, workspace strict Clippy, Desktop check, Tauri strict Clippy, web check, mobile format/analyze, Rust suites, 3,885 Desktop tests and build, 2,047 Tauri library tests plus 3 diagnostics, and the web build. The final mobile suite reached 1,021 passed and 1 skipped, then reproduced the unchanged current-main failure ChannelDetailPage keeps follow mode off while a tall newest message stays visible at mobile/test/features/channels/channel_detail_page_test.dart:1053. This branch has no mobile diff.

What remains

#2386 should stay open until the outer sender-publication and recipient-render or relay-acceptance boundaries are measured, hosted warm/cold baselines and explicit budgets exist, and a scheduled or blocking regression job is in place.

@BradGroux

Copy link
Copy Markdown
Contributor Author

This is a replacement for #2408, which was accidentally closed when branches were force-pushed after a commit identity rewrite. Prior review comments and feedback are preserved on the old PR:

#2408

@BradGroux
BradGroux force-pushed the agent/mention-reply-latency branch from f2f8f52 to 4f9ad04 Compare August 25, 2026 19:16
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 36 commits behind). The branch applied cleanly. The mention-to-reply latency tracing feature is not present on current main, so this PR is still needed.

No review comments on this PR. CI will verify the build and test gate.

@BradGroux
BradGroux force-pushed the agent/mention-reply-latency branch from 4f9ad04 to d3d79b9 Compare August 29, 2026 16:15
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is f038cbbb0d4092a72ffd93f17916f84d2b39bb43...839992ab2867b3b3689b4b48d046a6f332bd69d9.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 839992ab2867b3b3689b4b48d046a6f332bd69d9 to authorize a new review.
Any previous review applies only to its recorded range.

@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 62 commits behind at f249710, now at 00e61ea). The branch applies cleanly with all tests passing.

Still-needed assessment: No upstream commits in the 62-commit window address the same issue. This PR remains needed.

Review requests: buzz-oss-team review request is active from the previous pass.

@BradGroux
BradGroux force-pushed the agent/mention-reply-latency branch from d3d79b9 to a350279 Compare September 2, 2026 17:30
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto current block:main (2af9773d6) — 38 new commits since the last rebase pass (Aug 29, 00e61eafa).

Conflict resolved: crates/buzz-acp/src/lib.rs — Upstream PR #6732 (thread-scoped ACP sessions) refactored the normal-listener event path into AuthorizedNormalListenerEventmatch_subscriptionNormalListenerIngress::pushQueuedNormalListenerEvent with mark_seen() and steer_or_interrupt() methods, replacing the old inline queue.push() + accepted boolean + manual reaction/steer code. This PR's observer event_received and event_queued emits were originally interleaved with that old inline code. The resolution moves the observer emits to work with the new struct-based flow: event_received is emitted before ingress.push(), and event_queued is emitted after, gated on queued.accepted. The event_received_at timing variable (captured earlier in the relay handler) is preserved.

Still needed: Upstream #6732 adds per-thread session scoping and #6953 wakes agents from workflow messages — neither addresses mention-to-reply latency tracing. The PR remains relevant.

Verification:

  • Branch is 0 commits behind block:main, mergeable on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits

@BradGroux
BradGroux force-pushed the agent/mention-reply-latency branch 2 times, most recently from 4f9ad04 to 5d04ac6 Compare September 3, 2026 17:35
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase and review — 2026-09-03

Base commit: 752cbfc03 (latest main)
Mergeable: Yes
Conflict resolution: Main refactored the ACP event handling loop (introduced AuthorizedNormalListenerEvent, SessionScope, QueuedNormalListenerEvent with mark_seen/steer_or_interrupt methods). Merged the PR's latency tracing (observer event_received/event_queued emissions) into the refactored code path. Captured event_id_hex, event_created_at, and event_channel_id before ingress.push() moves the event. cargo check -p buzz-acp passes.

Accuracy review: No mention-to-reply latency tracing exists on main.
Continued relevance: Still needed.

@BradGroux
BradGroux force-pushed the agent/mention-reply-latency branch from 5d04ac6 to 5978eae Compare September 3, 2026 17:46
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase and review update — Sep 3, 2026

Rebased onto latest main (88687876f). No conflicts.

Accuracy review: Main does not have a latency collector for mention-to-reply tracing. The buzz-acp crate has observer infrastructure but no latency.rs module, no mention_reply_latency collector, and no event_received/event_queued emission at the inbound admission path. The PR's feature to trace where reply time goes after an agent @mention is still needed.

Mergeable status: Confirmed MERGEABLE on GitHub after force-push.

Refs block#2386

Co-authored-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
@BradGroux
BradGroux force-pushed the agent/mention-reply-latency branch from 5978eae to 839992a Compare September 5, 2026 04:59
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase pass — Sep 5, 2025

Rebased onto current upstream main (f038cbbb0). Main moved 62 commits since the Sep 2 rebase pass (2af9773d6).

Rebase result

Rebased cleanly onto current main. No conflicts.

Still-needed assessment

Checked all 62 new main commits for overlap with this PR's topic. None obsoleted:

Verification

  • PR confirmed MERGEABLE on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits
  • Review requests to buzz-oss-team still active from the Aug 24 recovery pass

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