mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
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
This commit is contained in:
@@ -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) == "" {
|
||||
|
||||
Reference in New Issue
Block a user