Skip to content

Add Client → Agent → Model identity for telemetry and User-Agent - #1602

Open
sverdlov93 wants to merge 9 commits into
masterfrom
feature/agent-identity-detection
Open

Add Client → Agent → Model identity for telemetry and User-Agent#1602
sverdlov93 wants to merge 9 commits into
masterfrom
feature/agent-identity-detection

Conversation

@sverdlov93

@sverdlov93 sverdlov93 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds a three-axis AI invocation identity — Client → Agent → Model — to ExecutionContext, Call-Home / Visibility telemetry, and (via jfrog-cli) the outbound User-Agent. Human sessions stay byte-identical: client and model are recorded only when an agent is detected.

Details

  • ExecutionContext: Client (JSON client, sanitized TERM_PROGRAM), Agent, Model (JSON model, sanitized JFROG_CLI_AI_MODEL).
  • Agent detection: session markers only (presence or exact-value match). First match wins. AI_AGENT / AGENT canonicalize through a single lookup map; unrecognized non-empty values → unknown.
  • sanitizeToken: lowercase + [a-z0-9._-], max 64 chars, before anything reaches metrics/wire.
  • Telemetry: commandsCountLabels JSON fields client / model.

Supported identity

Axis JSON / metrics User-Agent Source
Agent agent ai-agent/<name> Detector table / AI_AGENT / AGENT
Client client ai-client/<app> Sanitized TERM_PROGRAM (any host; not an allowlist)
Model model ai-model/<slug> Sanitized JFROG_CLI_AI_MODEL

Agents (wire name → session signals)

Wire name Session signals
claude CLAUDE_CODE_CHILD_SESSION
gemini GEMINI_CLI
goose GOOSE_TERMINAL
cursor CURSOR_AGENT, CURSOR_EXTENSION_HOST_ROLE=agent-exec
copilot COPILOT_CLI, COPILOT_AGENT_SESSION_ID
kilocode KILOCODE_FEATURE, KILO_PID
roo_code ROO_ACTIVE, ROO_CLI_RUNTIME
codex CODEX_CI, CODEX_THREAD_ID, CODEX_SANDBOX
windsurf WINDSURF_CASCADE_TERMINAL
aider AI_AGENT / AGENT only
cline CLINE_ACTIVE
opencode OPENCODE, OPENCODE_CLIENT
amp AMP_CURRENT_THREAD_ID
augment AUGMENT_AGENT
qwen QWEN_CODE
antigravity ANTIGRAVITY_AGENT
crush CRUSH
iflow IFLOW_CLI
trae TRAE_AI_SHELL_ID
amazon_q AI_AGENT / AGENT only
unknown AI_AGENT / AGENT unrecognized value

Aliases: claude-codeclaude, gemini-cligemini, cursor-clicursor, github-copilot/copilot-clicopilot, roo-coderoo_code, amazon-q/amazon-q-cliamazon_q, qwen-codeqwen.

Source of truth in-repo: comment table above agentEnvDetectors in common/commands/execution_context.go.

Flow

flowchart LR
  env[Env signals] --> detect[DetectExecutionContext]
  detect -->|IsAgent| axes["Client + Agent + Model"]
  detect -->|human| bare[empty axes]
  axes --> metrics[CollectMetrics / Visibility]
  axes --> ua[CLI User-Agent]
Loading

Notes

  • Publish ordering: land this before the jfrog-cli PR; bump go.mod to a published pseudo-version (never commit replace).
  • Companions: jfrog-cli User-Agent suffix; jfrog-skills detect_harness + Coralogix coalescing (ARCHITECTURE.md Agent identity table).
  • Model is omitted from CLI telemetry when no agent is detected, even if JFROG_CLI_AI_MODEL is set — skills still carry model= on the wire.

Review follow-up

Tightened detectors to strong session markers only: dropped CURSOR_TRACE_ID, Copilot config envs (COPILOT_MODEL / COPILOT_ALLOW_ALL), and Claude IDE-terminal leaks (CLAUDECODE / CLAUDE_CODE / CLAUDE_CODE_ENTRYPOINT) that misclassify humans. CURSOR_TRACE_ID remains for correlation after a strong cursor hit.

Expand agent detection (aliases, AI_AGENT, broader env table) and record
ai_client/ai_model for agent sessions so CLI User-Agent and visibility
metrics can attribute harness, client app, and model consistently.
@sverdlov93 sverdlov93 added the new feature Automatically generated release notes label Aug 6, 2026
Copy ai_client/ai_model through reportUsageToVisibilitySystem (they were
collected then dropped), cap sanitized token length, and document that
detection/metrics are best-effort: no errors, no logs, never fail a command.
Field/metrics name is Client; wire User-Agent token stays ai-client/ beside
ai-agent/ and ai-model/. Stack: Client → Agent → Model.
Wire token stays ai-model/; env remains JFROG_CLI_AI_MODEL.
Drop IDE/IPC/config false positives, add verified Cursor/Kilo/Roo/Windsurf/Copilot markers, and collapse alias lookup into a single map.
@sverdlov93 sverdlov93 changed the title Add AI client and model identity to execution context and telemetry Add Client → Agent → Model identity for telemetry and User-Agent Aug 6, 2026
Drop CURSOR_TRACE_ID, Copilot config envs, and Claude IDE-terminal
leaks that misclassify humans; keep TRACE_ID for correlation after a
strong cursor hit.
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Automatically generated release notes safe-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant