Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

feat(observe): recognize Prime Agent as its own harness

Justin5b8d75ddeba1
diff --git a/pkg/asymptoteobserve/harness.go b/pkg/asymptoteobserve/harness.go
index 00c50ae7..b591afd0 100644
--- a/pkg/asymptoteobserve/harness.go
+++ b/pkg/asymptoteobserve/harness.go
@@ -101,6 +101,25 @@ func NormalizeHarnessName(name string) string {
lower == "qwencode" || lower == "qwen_cli" || lower == "qwen-cli" || lower == "qwen cli" ||
lower == "qwen_coder" || lower == "qwen-coder" || lower == "qwen coder":
return "qwen_code"
+ // Prime Agent (Prime Intellect) ships the same extension API as Pi, which is why Beacon
+ // observes it the same way -- but it is a separate product, and recording its sessions as
+ // pi_cli would merge two runtimes' activity under one name in every query that groups by
+ // harness.name. The canonical spelling is prime_agent because that is the product's name and
+ // the command it installs; it follows claude_code and qwen_code, not codex_cli.
+ //
+ // Equality against a closed set, like Pi, Cline and Qwen Code above rather than the Contains
+ // rules further up. "prime" is an ordinary English word that appears in model ids, file paths
+ // and vendor names, so a substring rule would report any event whose harness attribute merely
+ // contained it as a Prime Agent session. The set is closed rather than a prefix rule for the
+ // same reason.
+ //
+ // Both the hook spelling and the runtime's own are pinned here: the hook path installs with
+ // --platform prime, while the runtime calls itself prime-agent, and without this one session
+ // would be recorded under two names.
+ case lower == "prime" || lower == "prime_agent" || lower == "prime-agent" || lower == "prime agent" ||
+ lower == "primeagent" || lower == "prime_cli" || lower == "prime-cli" || lower == "prime cli" ||
+ lower == "prime_intellect" || lower == "prime-intellect" || lower == "prime intellect":
+ return "prime_agent"
case name != "":
// An unrecognized runtime keeps its own name rather than being coerced or dropped. A new
// harness should show up in the log as itself, not as "unknown".
diff --git a/pkg/asymptoteobserve/harness_test.go b/pkg/asymptoteobserve/harness_test.go
index 97e394f1..d1cda3e2 100644
--- a/pkg/asymptoteobserve/harness_test.go
+++ b/pkg/asymptoteobserve/harness_test.go
@@ -19,6 +19,7 @@ func TestHookPlatformsConvergeOnCanonicalNames(t *testing.T) {
"pi": "pi_cli",
"cline": "cline",
"qwen": "qwen_code",
+ "prime": "prime_agent",
} {
t.Run(platform, func(t *testing.T) {
if got := NormalizeHarnessName(platform); got != want {
@@ -37,7 +38,7 @@ func TestCanonicalNamesAreStableUnderRenormalization(t *testing.T) {
for _, canonical := range []string{
"claude_code", "codex_cli", "gemini_cli", "antigravity_cli", "vscode_copilot",
"copilot_cli", "claude_web", "chatgpt_web", "claude_cowork", "claude_agent_sdk",
- "openclaw_gateway", "pi_cli", "cline", "qwen_code",
+ "openclaw_gateway", "pi_cli", "cline", "qwen_code", "prime_agent",
} {
t.Run(canonical, func(t *testing.T) {
if got := NormalizeHarnessName(canonical); got != canonical {
@@ -214,3 +215,51 @@ func TestEmptyNameStaysEmpty(t *testing.T) {
}
}
}
+
+// Prime Agent reaches Beacon under more than one spelling for the same reason Qwen Code does: the
+// hook path installs with --platform prime, while an OTLP resource attribute carries whatever the
+// runtime calls itself, which is prime-agent.
+func TestPrimeAgentSpellingsConvergeOnPrimeAgent(t *testing.T) {
+ for _, in := range []string{
+ "prime", "Prime", "PRIME", " prime ", "prime_agent", "prime-agent", "Prime Agent",
+ "primeagent", "prime_cli", "prime-cli", "prime cli", "prime-intellect", "Prime Intellect",
+ } {
+ t.Run(in, func(t *testing.T) {
+ if got := NormalizeHarnessName(in); got != "prime_agent" {
+ t.Errorf("NormalizeHarnessName(%q) = %q, want %q", in, got, "prime_agent")
+ }
+ })
+ }
+}
+
+// Prime Agent is a Pi distribution -- it ships Pi's extension API under a rebranded config
+// directory -- which is exactly why this needs a test. The two runtimes are observed through the
+// same mechanism, so the temptation is to file them under one name; doing that would merge two
+// products' sessions in every query that groups by harness.name, and would make "which runtime is
+// running here" unanswerable from the log.
+func TestPrimeAgentIsNotAttributedToPi(t *testing.T) {
+ for _, in := range []string{"prime", "prime-agent", "prime_agent", "Prime Agent"} {
+ if got := NormalizeHarnessName(in); got == "pi_cli" {
+ t.Errorf("NormalizeHarnessName(%q) = %q; Prime Agent must not be recorded as Pi", in, got)
+ }
+ }
+ for _, in := range []string{"pi", "pi.dev", "pi-agent"} {
+ if got := NormalizeHarnessName(in); got != "pi_cli" {
+ t.Errorf("NormalizeHarnessName(%q) = %q; adding Prime Agent must not move Pi", in, got)
+ }
+ }
+}
+
+// The reason the Prime case is an equality match rather than a Contains rule. "prime" is an
+// ordinary word: it turns up in model ids, vendor names, and directory paths that have nothing to
+// do with this runtime, and a substring rule would file every one of them under prime_agent.
+func TestPrimeSubstringsAreNotTreatedAsTheHarness(t *testing.T) {
+ for _, name := range []string{
+ "prime-numbers", "amazon_prime", "primer", "optimus-prime-cli", "claude_code_primed",
+ } {
+ if got := NormalizeHarnessName(name); got == "prime_agent" {
+ t.Errorf("NormalizeHarnessName(%q) = %q; a name that merely contains \"prime\" must not be "+
+ "reported as the Prime Agent harness", name, got)
+ }
+ }
+}
diff --git a/pkg/asymptoteobserve/provenance.go b/pkg/asymptoteobserve/provenance.go
index 81da922a..60f0348d 100644
--- a/pkg/asymptoteobserve/provenance.go
+++ b/pkg/asymptoteobserve/provenance.go
@@ -96,7 +96,7 @@ func CollectionMethodForPlatform(platform string) string {
switch strings.ToLower(strings.TrimSpace(platform)) {
case "":
return ""
- case "opencode", "cline", "pi":
+ case "opencode", "cline", "pi", "prime":
return CollectionMethodPlugin
default:
return CollectionMethodHook
diff --git a/pkg/asymptoteobserve/provenance_test.go b/pkg/asymptoteobserve/provenance_test.go
index ccaefa71..5b3a6060 100644
--- a/pkg/asymptoteobserve/provenance_test.go
+++ b/pkg/asymptoteobserve/provenance_test.go
@@ -113,6 +113,7 @@ func TestCollectionMethodForPlatform(t *testing.T) {
"opencode": CollectionMethodPlugin,
"cline": CollectionMethodPlugin,
"pi": CollectionMethodPlugin,
+ "prime": CollectionMethodPlugin,
// Unset stays unset rather than defaulting to a method, so an event with no platform does
// not claim one.
"": "",