mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-21 23:47:39 +08:00
fix pipeline tool context origin injection
This commit is contained in:
@@ -1560,7 +1560,7 @@ func withToolContextArgs(toolName string, args map[string]interface{}, channel,
|
|||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
switch toolName {
|
switch toolName {
|
||||||
case "message", "spawn", "remind":
|
case "message", "spawn", "remind", "pipeline_create", "pipeline_dispatch":
|
||||||
default:
|
default:
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|||||||
44
pkg/agent/loop_tool_context_test.go
Normal file
44
pkg/agent/loop_tool_context_test.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package agent
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestWithToolContextArgsPipelineAutoInject(t *testing.T) {
|
||||||
|
args := map[string]interface{}{
|
||||||
|
"objective": "build feature",
|
||||||
|
}
|
||||||
|
got := withToolContextArgs("pipeline_create", args, "telegram", "123")
|
||||||
|
if got["channel"] != "telegram" {
|
||||||
|
t.Fatalf("expected channel auto-injected for pipeline_create, got %v", got["channel"])
|
||||||
|
}
|
||||||
|
if got["chat_id"] != "123" {
|
||||||
|
t.Fatalf("expected chat_id auto-injected for pipeline_create, got %v", got["chat_id"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWithToolContextArgsPipelineRespectsExplicitTarget(t *testing.T) {
|
||||||
|
args := map[string]interface{}{
|
||||||
|
"pipeline_id": "p-1",
|
||||||
|
"channel": "webui",
|
||||||
|
"chat_id": "panel",
|
||||||
|
}
|
||||||
|
got := withToolContextArgs("pipeline_dispatch", args, "telegram", "123")
|
||||||
|
if got["channel"] != "webui" {
|
||||||
|
t.Fatalf("expected explicit channel preserved, got %v", got["channel"])
|
||||||
|
}
|
||||||
|
if got["chat_id"] != "panel" {
|
||||||
|
t.Fatalf("expected explicit chat_id preserved, got %v", got["chat_id"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWithToolContextArgsIgnoresUnrelatedTools(t *testing.T) {
|
||||||
|
args := map[string]interface{}{
|
||||||
|
"path": "README.md",
|
||||||
|
}
|
||||||
|
got := withToolContextArgs("read_file", args, "telegram", "123")
|
||||||
|
if _, ok := got["channel"]; ok {
|
||||||
|
t.Fatalf("did not expect channel for unrelated tool")
|
||||||
|
}
|
||||||
|
if _, ok := got["chat_id"]; ok {
|
||||||
|
t.Fatalf("did not expect chat_id for unrelated tool")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user