Send telemetry on unrecognized commands#1745
Open
keshavc-stripe wants to merge 3 commits into
Open
Conversation
Record unknown CLI commands attempted by AI agents (Claude Code, Cursor, Codex, etc.) to gain insight into hallucinated/attempted commands. Entries are stored locally and sent as a batch every 10 occurrences to avoid per-invocation roundtrips. Only activates when an agent environment variable is detected — manual CLI usage is unaffected. Resolves: DEVAI-1146 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
The goroutine spawned by `go client.SendEvent(...)` was getting killed by os.Exit(1) before the HTTP request could complete. Remove the `go` so the send completes before the process exits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
10dd27d to
b3e767b
Compare
keshavc-stripe
commented
Jul 7, 2026
|
|
||
| case strings.Contains(errString, "unknown command"): | ||
| showSuggestion() | ||
| recordUnknownCommand(updatedCtx, strings.Join(os.Args[1:], " ")) |
Author
There was a problem hiding this comment.
Note that this is synchronous but the timeout is 3 seconds. Making this async doesn't work since the os.Exit(1) kills all subroutines.
Lines 22 to 24 in 7c98c54
Author
matv-stripe
reviewed
Jul 7, 2026
| const ( | ||
| unknownCmdBatchFile = "unknown_commands.json" | ||
| unknownCmdBatchSize = 10 | ||
| unknownCmdEventName = "Unknown Command Attempted" |
Contributor
There was a problem hiding this comment.
is this a valid event? do we have to update anything on the spark side internally? @vcheung-stripe would know
Author
There was a problem hiding this comment.
Hmm showed up on logscale but might be missing some more context for spark stuff
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.
Reviewers
r? @
cc @stripe/developer-products
Summary
https://jira.corp.stripe.com/browse/DEVAI-1146
Testing
https://logscale.corp.stripe.com/main-view/search?live=false&query=%22ARECIBO-EVENT%22%0A%7C%20%22context.p_client_id%22%20%3D%20%22stripe-cli%22%0A%7C%20groupBy(%22context.p_event_name%22)&start=2h&tz=UTC