RTECO-1017 - Detect agent + CI invocation context, enrich metrics wit…#1555
Open
RTECO-1017 - Detect agent + CI invocation context, enrich metrics wit…#1555
Conversation
…h agent/is_agent/is_interactive
bhanurp
requested changes
May 5, 2026
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.
…h agent/is_agent/is_interactive
Summary
Adds detection of CLI invocation context — agent (Claude, Cursor, Gemini, Goose, Copilot, Windsurf, etc.), CI provider, and stdin TTY — and enriches the existing
jfcli_commands_countmetric with the new dimensions.Motivation
differentiate human / CI / agent invocations of
jf. Backend currently can't tell whether a command came from a developer's desktop, a CI runner, or an AI agent. Without this, we can't measure agent-driven usage or separate human vs automated traffic.Changes
common/commands/execution_context.go— single source of truth for invocation context.DetectExecutionContext()returns agent name, CI system, TTY presence, andpropagated trace ID.
common/commands/execution_context_test.go— unit tests covering each agent env var, CI providers, trace ID gating, and no-env fallback.utils/metrics/metrics.go—MetricsDatagainsIsAgent,Agent,IsInteractivefields (additive,omitempty).common/commands/metrics_collector.go—CollectMetricspopulates the new fields viaDetectExecutionContext.Detection
Agent identity is matched against an env-var table (first match wins, then generic
AGENTfallback):CLAUDECODE,CLAUDE_CODE_ENTRYPOINTGEMINI_CLIGOOSE_TERMINALCURSOR_AGENT,CURSOR_TRACEIDCOPILOT_CLIKILO_IPC_SOCKET_PATH,KILO_SERVER_PASSWORDROO_CODE_IPC_SOCKET_PATHREPLIT_AGENTWINDSURF_SESSION_IDAIDER_MODELCODEX_HOMECI detection reuses the existing
detectCISystem()provider list (Jenkins, Travis, CircleCI, GitHub Actions, GitLab, Buildkite, Bamboo, Azure DevOps, TeamCity, Drone, Bitbucket,AWS CodeBuild, plus generic fallbacks).
TraceIDis gated on agent identity — only Cursor'sCURSOR_TRACEIDis honored, and only when the detected agent iscursor. Prevents stale leakage from outer shells.