From df486b99393cf9e69550b2f4406938977a5f7b2b Mon Sep 17 00:00:00 2001 From: xiaoen <2768753269@qq.com> Date: Wed, 15 Apr 2026 22:23:17 +0800 Subject: [PATCH] fix(tools): normalize agent_id before self-check and delegation Apply routing.NormalizeAgentID to the raw agent_id input before any logic runs. This prevents case/whitespace variants like "ALPHA" or " alpha " from bypassing the self-delegation guard while still resolving to the same agent in the registry. The normalized value is used consistently for self-check, allowlist, SpawnSubTurn, and result attribution. Ref: #2148 --- pkg/tools/delegate.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/tools/delegate.go b/pkg/tools/delegate.go index 8831ffeb3..dcde27718 100644 --- a/pkg/tools/delegate.go +++ b/pkg/tools/delegate.go @@ -4,6 +4,8 @@ import ( "context" "fmt" "strings" + + "github.com/sipeed/picoclaw/pkg/routing" ) // DelegateTool delegates a task to a specific named agent and waits for @@ -61,10 +63,11 @@ func (t *DelegateTool) Parameters() map[string]any { } func (t *DelegateTool) Execute(ctx context.Context, args map[string]any) *ToolResult { - agentID, _ := args["agent_id"].(string) - if strings.TrimSpace(agentID) == "" { + rawAgentID, _ := args["agent_id"].(string) + if strings.TrimSpace(rawAgentID) == "" { return ErrorResult("agent_id is required and must be a non-empty string") } + agentID := routing.NormalizeAgentID(rawAgentID) task, _ := args["task"].(string) if strings.TrimSpace(task) == "" {