RTECO-1017 - Detect agent + CI invocation context, enrich metrics wit…#1555
Open
fluxxBot wants to merge 3 commits into
Open
RTECO-1017 - Detect agent + CI invocation context, enrich metrics wit…#1555fluxxBot wants to merge 3 commits into
fluxxBot wants to merge 3 commits into
Conversation
…h agent/is_agent/is_interactive
bhanurp
requested changes
May 5, 2026
itsmeleela
reviewed
May 12, 2026
itsmeleela
reviewed
May 12, 2026
| {"goose", []string{"GOOSE_TERMINAL"}}, | ||
| {"cursor", []string{"CURSOR_AGENT", "CURSOR_CLI", "CURSOR_TRACE_ID"}}, | ||
| {"copilot", []string{"COPILOT_CLI"}}, | ||
| {"kilocode", []string{"KILO_IPC_SOCKET_PATH", "KILO_SERVER_PASSWORD"}}, |
There was a problem hiding this comment.
Also in description table I see replit, windsurf, and aider entries but here I am not seeing them implemented
Contributor
Author
There was a problem hiding this comment.
yeah needed to drop it, no official documentation regarding any env from them
itsmeleela
reviewed
May 12, 2026
… memoization for execution context to prevent divergence when environment variables change. Introduced resetExecutionContextForTest helper to facilitate isolated tests. Updated relevant test cases to utilize the new helper for consistent state management.
bhanurp
approved these changes
May 13, 2026
4 tasks
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 — AI agent (Claude, Cursor, Gemini, Goose, Copilot, Kilocode, Roo Code, Codex) and interactive-terminal presence — and
enriches the existing
jfcli_commands_countmetric and outboundUser-Agentheader with the new dimensions. Also extends the existing CI provider list withHarness.
Motivation
RTECO-1017: differentiate human / CI / agent invocations of
jf. Backend currently can't tell whether acommand 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— invocation-context detection.ExecutionContextstruct:Agent,IsAgent,IsInteractive,TraceID.DetectExecutionContext()populates the struct from env vars + terminal probe.EnrichUserAgent(base string) string— returns the base User-Agent appended with(agent; ci=<system>)context. Used by jfrog-cli'sSetUserAgentcall.clientlog.IsStdOutTerminal()fromjfrog-client-go/utils/logfor cached + test-overridable TTY detection. No direct dependency ongolang.org/x/term.common/commands/execution_context_test.go— table-driven tests sourced fromagentEnvDetectors(single source of truth), plus trace-ID gating,no-env fallback, and
EnrichUserAgentcombinations.utils/metrics/metrics.go—MetricsDatagainsIsAgent,Agent,IsInteractive(additive,omitempty).common/commands/metrics_collector.go:CollectMetricspopulates the new fields viaDetectExecutionContext.HARNESS_BUILD_ID→harnessto the CI provider list.Agent detection
First match wins. Generic
AGENTenv collapses to the literalunknownto keep label cardinality bounded.CLAUDECODE,CLAUDE_CODE_ENTRYPOINTGEMINI_CLIGOOSE_TERMINALCURSOR_AGENT,CURSOR_CLI,CURSOR_TRACE_IDCOPILOT_CLIKILO_IPC_SOCKET_PATH,KILO_SERVER_PASSWORDROO_CODE_IPC_SOCKET_PATHCODEX_CIDropped from the initial draft (no verified per-invocation subprocess marker): windsurf, aider, replit.
Trace-ID propagation
TraceIDis gated on agent identity — only Cursor'sCURSOR_TRACE_IDis honored, and only when the detected agent iscursor. Prevents stale values leakedfrom an outer shell (e.g. a Cursor env present while the real invoker is Claude Code) from being reused.
User-Agent enrichment
EnrichUserAgent(base)appends(agent),(ci=<system>), or(agent; ci=<system>)to the base. Returns the base unchanged when neither is detected. Thejfrog-cli
main.gochange (separate PR) calls this once at startup.