feat(desktop): opt-in aggregate agent-metrics aggregator + flush#4033
Merged
Conversation
Desktop side of the opt-in metrics telemetry (worker /v1/metrics already live). A metricsAggregator taps the existing tabEventSink event stream — internal/agent is untouched, so the CLI stays zero-egress — and counts enumerated facts only: finish_reason, empty_final, provider error class, cache-hit bucket, tool error class, compaction, and turns. Never message text, keys, prompts, or paths; error classes are derived from a status-code regex, not the message body. Gated on a new desktop.metrics flag (default off, separate from the default-on launch ping) and skipped in dev. Counts persist per turn and flush once at the next launch, mirroring the ping; a failed POST folds back to retry. The settings toggle and first-run disclosure land in a follow-up; until then the flag is set via config.toml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Desktop side of the opt-in agent-metrics telemetry. The worker
/v1/metricsendpoint is already merged (#4030) and deployed live (schema applied, smoke-tested 202/400/405), so once this ships and a user opts in, counts start flowing.How it works
metricsAggregatortaps the existingtabEventSink.Emitevent stream —internal/agentis untouched, so the CLI stays zero-egress (desktop-only, per the telemetry-scope decision).observe(e)counts enumerated facts only:finish_reason,empty_final,provider_error(class),cache_hit(bucket),tool_error(class),compaction,turns. Error classes come from astatus (\d{3})regex + keyword match — never the message body, which can echo request content.Privacy / opt-in
desktop.metricsflag, default off, separate from the default-on launch ping. Dev builds skip it.Test
go test ./(desktop) — aggregator classification, error/cache bucketing, cross-session merge; verified each mappinggo test ./internal/config/...,go build ./...(desktop),go vet ./...— passNot in this PR (follow-up)
Settings toggle + first-run disclosure (the user-facing opt-in switch). Until then the flag is set via
[desktop] metrics = truein config.toml. No new bound App method here, so no bridge.ts AppBindings change.