From 5fbaf4f211fcb1f6869c6902205a1dbba6b8871b Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 16 Mar 2026 11:24:59 +0000 Subject: [PATCH] fix(brain): use hostname-based agent_id instead of hardcoded cladius Charon gets agent_id 'charon', Cladius gets 'cladius'. Override with AGENT_NAME env var. Co-Authored-By: Virgil --- pkg/brain/direct.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/brain/direct.go b/pkg/brain/direct.go index ec15517..93ba672 100644 --- a/pkg/brain/direct.go +++ b/pkg/brain/direct.go @@ -16,6 +16,19 @@ import ( "github.com/modelcontextprotocol/go-sdk/mcp" ) +// agentName returns the identity of this agent from env or hostname. +func agentName() string { + if name := os.Getenv("AGENT_NAME"); name != "" { + return name + } + hostname, _ := os.Hostname() + h := strings.ToLower(hostname) + if strings.Contains(h, "snider") || strings.Contains(h, "studio") || strings.Contains(h, "mac") { + return "cladius" + } + return "charon" +} + // DirectSubsystem implements mcp.Subsystem for OpenBrain via direct HTTP calls. // Unlike Subsystem (which uses the IDE WebSocket bridge), this calls the // Laravel API directly — suitable for standalone core-mcp usage. @@ -123,7 +136,7 @@ func (s *DirectSubsystem) remember(ctx context.Context, _ *mcp.CallToolRequest, "type": input.Type, "tags": input.Tags, "project": input.Project, - "agent_id": "cladius", + "agent_id": agentName(), }) if err != nil { return nil, RememberOutput{}, err @@ -141,7 +154,7 @@ func (s *DirectSubsystem) recall(ctx context.Context, _ *mcp.CallToolRequest, in body := map[string]any{ "query": input.Query, "top_k": input.TopK, - "agent_id": "cladius", + "agent_id": agentName(), } if input.Filter.Project != "" { body["project"] = input.Filter.Project