← Back to PRs

#12999: feat(agents): Add streaming response metrics tracking

by trevorgordon981 open 2026-02-10 01:25 View on GitHub →
channel: slack app: web-ui gateway agents stale
## Summary Adds metrics collection for streaming responses to monitor perceived latency. ## Features - Time-to-first-chunk tracking - Chunk count and size metrics - Perceived latency calculation - Integration with existing streaming infrastructure ## Files - src/agents/streaming-metrics.ts - src/agents/streaming-metrics.test.ts (5 tests) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR introduces several new agent/gateway infrastructure modules (streaming metrics, model routing, parallel spawn, perf tracing, queue/caching/monitoring utilities) and wires in a memory-leak fix for agent event sequence tracking. In the current head commit (`a4fcffb`), the functional change is focused on cleaning up per-run sequence counters (`seqByRun`) by deleting them when a run ends and adding a periodic prune safety-net; tests were added to validate the leak fix and it’s wired into the maintenance timer. There’s also an additional cleanup in `server-chat.ts` for that file’s local per-run sequence map. <h3>Confidence Score: 4/5</h3> - This PR is likely safe to merge after resolving a small but real cleanup/intent mismatch in server-chat sequence tracking. - The leak fix in src/infra/agent-events.ts is straightforward and tested. The additional `agentRunSeq.delete` in server-chat.ts is a separate local map cleanup, but as written it’s easy to conflate with the global seqByRun leak fix; clarifying/removing it avoids confusion and review churn. - src/gateway/server-chat.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs