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:
parent
039f35563e
commit
df486b9939
1 changed files with 5 additions and 2 deletions
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/sipeed/picoclaw/pkg/routing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DelegateTool delegates a task to a specific named agent and waits for
|
// 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 {
|
func (t *DelegateTool) Execute(ctx context.Context, args map[string]any) *ToolResult {
|
||||||
agentID, _ := args["agent_id"].(string)
|
rawAgentID, _ := args["agent_id"].(string)
|
||||||
if strings.TrimSpace(agentID) == "" {
|
if strings.TrimSpace(rawAgentID) == "" {
|
||||||
return ErrorResult("agent_id is required and must be a non-empty string")
|
return ErrorResult("agent_id is required and must be a non-empty string")
|
||||||
}
|
}
|
||||||
|
agentID := routing.NormalizeAgentID(rawAgentID)
|
||||||
|
|
||||||
task, _ := args["task"].(string)
|
task, _ := args["task"].(string)
|
||||||
if strings.TrimSpace(task) == "" {
|
if strings.TrimSpace(task) == "" {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue