From 8c8cf95744b5fd29b355dc2dde00a5be7d880b3f Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Thu, 23 Jul 2026 19:57:55 +0200 Subject: [PATCH 1/2] Add Pi coding agent to the known-agents table Pi (https://pi.dev/, npm @earendil-works/pi-coding-agent) sets PI_CODING_AGENT in the environment of every subprocess its bash/exec tool spawns, but does not set the generic AGENT/AI_AGENT var, so it needs an explicit matcher. Without it, CLI usage driven by Pi is attributed to unknown instead of "pi". Co-authored-by: Isaac --- useragent/agent.go | 1 + useragent/agent_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/useragent/agent.go b/useragent/agent.go index da84ac01a..8cdd41d8e 100644 --- a/useragent/agent.go +++ b/useragent/agent.go @@ -47,6 +47,7 @@ func listKnownAgents() []knownAgent { {envVar: "KIRO", product: "kiro"}, // https://kiro.dev/ (Amazon) {envVar: "OPENCLAW_SHELL", product: "openclaw"}, // https://github.com/anthropics/openclaw {envVar: "OPENCODE", product: "opencode"}, // https://github.com/opencode-ai/opencode + {envVar: "PI_CODING_AGENT", product: "pi"}, // https://pi.dev/ (npm @earendil-works/pi-coding-agent) {envVar: "VSCODE_AGENT", product: "vscode-agent"}, // Set by VS Code 1.121+ for agent-initiated terminal commands (https://code.visualstudio.com/updates/v1_121) {envVar: "WINDSURF_AGENT", product: "windsurf"}, // https://codeium.com/windsurf (Codeium) } diff --git a/useragent/agent_test.go b/useragent/agent_test.go index 096d08e3b..9a5774d10 100644 --- a/useragent/agent_test.go +++ b/useragent/agent_test.go @@ -129,6 +129,11 @@ func TestLookupAgentProvider(t *testing.T) { envs: map[string]string{"WINDSURF_AGENT": "1"}, expect: "windsurf", }, + { + name: "pi", + envs: map[string]string{"PI_CODING_AGENT": "true"}, + expect: "pi", + }, // AGENT fallback behavior. { name: "AGENT=cursor falls back to cursor", From 0dce7a6b94297e81389891599318529b27dc6a6f Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Thu, 23 Jul 2026 20:13:24 +0200 Subject: [PATCH 2/2] Add NEXT_CHANGELOG.md entry for Pi agent detection Satisfies the check-next-changelog CI gate, which requires either a NEXT_CHANGELOG.md change or NO_CHANGELOG=true in the PR body. Co-authored-by: Isaac --- NEXT_CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index e935017c9..a6c84fa01 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -6,6 +6,8 @@ ### New Features and Improvements +* Add the Pi coding agent (`PI_CODING_AGENT`) to AI agent detection in the User-Agent header, so CLI usage driven by Pi is attributed to `pi`. + ### Bug Fixes ### Documentation