Problem
opencode (the open-source AI coding agent) sets two environment variables unconditionally at startup for every session:
process.env.AGENT = "1"
process.env.OPENCODE = "1"
Source (opencode, pinned to commit 3f39a329c3d52ed66405c4bc6293b9ed08fe9ab6):
https://github.com/anomalyco/opencode/blob/3f39a329c3d52ed66405c4bc6293b9ed08fe9ab6/packages/opencode/src/index.ts#L75-L76
Because AGENT is set to the literal "1", the generic fallback in GetAIAgent() catches it and records the agent name verbatim as "1". As a result, opencode-driven CLI runs surface in the User-Agent header, the ai_agent telemetry field, and the Jaeger ai_agent trace tag as:
slack-cli/<version> (os: darwin) AI-Agent (name: 1)
So the run is detectable as an AI agent but mislabeled as 1 instead of opencode, which is noisy for agent attribution / dashboards.
Note on sourcing: opencode's published docs (opencode.ai/docs) do not document these env vars; the authoritative source is the repo source code linked above.
Proposed change
Add a dedicated OPENCODE case to GetAIAgent() in internal/useragent/useragent.go, matching the existing hardcoded agents (claude-code, codex, gemini-cli, cline, cursor). It must be placed before the generic AGENT fallback so opencode wins over the bare AGENT=1:
case os.Getenv("CURSOR_AGENT") == "1":
return &AIAgent{Name: "cursor"}
case os.Getenv("OPENCODE") == "1":
return &AIAgent{Name: "opencode"}
case os.Getenv("AGENT") != "":
return &AIAgent{Name: os.Getenv("AGENT")}
The GetAIAgent doc-comment priority list should also be updated to include OPENCODE (e.g. ... > CURSOR_AGENT > OPENCODE > AGENT).
Offer
Happy to send a PR with this change plus a table-driven test case in useragent_test.go, pending maintainer feedback per CONTRIBUTING.md.
Problem
opencode (the open-source AI coding agent) sets two environment variables unconditionally at startup for every session:
process.env.AGENT = "1"process.env.OPENCODE = "1"Source (opencode, pinned to commit
3f39a329c3d52ed66405c4bc6293b9ed08fe9ab6):https://github.com/anomalyco/opencode/blob/3f39a329c3d52ed66405c4bc6293b9ed08fe9ab6/packages/opencode/src/index.ts#L75-L76
Because
AGENTis set to the literal"1", the generic fallback inGetAIAgent()catches it and records the agent name verbatim as"1". As a result, opencode-driven CLI runs surface in the User-Agent header, theai_agenttelemetry field, and the Jaegerai_agenttrace tag as:So the run is detectable as an AI agent but mislabeled as
1instead ofopencode, which is noisy for agent attribution / dashboards.Note on sourcing: opencode's published docs (opencode.ai/docs) do not document these env vars; the authoritative source is the repo source code linked above.
Proposed change
Add a dedicated
OPENCODEcase toGetAIAgent()ininternal/useragent/useragent.go, matching the existing hardcoded agents (claude-code,codex,gemini-cli,cline,cursor). It must be placed before the genericAGENTfallback soopencodewins over the bareAGENT=1:The
GetAIAgentdoc-comment priority list should also be updated to includeOPENCODE(e.g.... > CURSOR_AGENT > OPENCODE > AGENT).Offer
Happy to send a PR with this change plus a table-driven test case in
useragent_test.go, pending maintainer feedback per CONTRIBUTING.md.