mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-15 03:57:30 +08:00
fix: enforce subagent prompt files and refine webui
This commit is contained in:
@@ -464,9 +464,6 @@ func (al *AgentLoop) buildSubagentTaskInput(task *tools.SubagentTask) string {
|
||||
return fmt.Sprintf("Role Profile Policy (%s):\n%s\n\nTask:\n%s", promptFile, promptText, taskText)
|
||||
}
|
||||
}
|
||||
if prompt := strings.TrimSpace(task.SystemPrompt); prompt != "" {
|
||||
return fmt.Sprintf("Role Profile Prompt:\n%s\n\nTask:\n%s", prompt, taskText)
|
||||
}
|
||||
return taskText
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,6 @@ func (al *AgentLoop) HandleSubagentRuntime(ctx context.Context, action string, a
|
||||
"display_name": subcfg.DisplayName,
|
||||
"role": subcfg.Role,
|
||||
"description": subcfg.Description,
|
||||
"system_prompt": subcfg.SystemPrompt,
|
||||
"system_prompt_file": subcfg.SystemPromptFile,
|
||||
"prompt_file_found": promptFileFound,
|
||||
"memory_namespace": subcfg.MemoryNamespace,
|
||||
@@ -167,7 +166,6 @@ func (al *AgentLoop) HandleSubagentRuntime(ctx context.Context, action string, a
|
||||
"display_name": profile.Name,
|
||||
"role": profile.Role,
|
||||
"description": "Node-registered remote main agent branch",
|
||||
"system_prompt": profile.SystemPrompt,
|
||||
"system_prompt_file": profile.SystemPromptFile,
|
||||
"prompt_file_found": false,
|
||||
"memory_namespace": profile.MemoryNamespace,
|
||||
|
||||
@@ -78,7 +78,6 @@ func TestHandleSubagentRuntimeUpsertConfigSubagent(t *testing.T) {
|
||||
"role": "testing",
|
||||
"notify_main_policy": "internal_only",
|
||||
"display_name": "Review Agent",
|
||||
"system_prompt": "review changes",
|
||||
"system_prompt_file": "agents/reviewer/AGENT.md",
|
||||
"routing_keywords": []interface{}{"review", "regression"},
|
||||
"tool_allowlist": []interface{}{"shell", "sessions"},
|
||||
@@ -129,7 +128,6 @@ func TestHandleSubagentRuntimeRegistryAndToggleEnabled(t *testing.T) {
|
||||
Type: "worker",
|
||||
Role: "testing",
|
||||
DisplayName: "Test Agent",
|
||||
SystemPrompt: "run tests",
|
||||
SystemPromptFile: "agents/tester/AGENT.md",
|
||||
MemoryNamespace: "tester",
|
||||
Tools: config.SubagentToolsConfig{
|
||||
|
||||
@@ -20,7 +20,6 @@ func TestBuildSubagentTaskInputPrefersPromptFile(t *testing.T) {
|
||||
loop := &AgentLoop{workspace: workspace}
|
||||
input := loop.buildSubagentTaskInput(&tools.SubagentTask{
|
||||
Task: "implement login flow",
|
||||
SystemPrompt: "inline-fallback",
|
||||
SystemPromptFile: "agents/coder/AGENT.md",
|
||||
})
|
||||
if !strings.Contains(input, "coder-file-policy") {
|
||||
@@ -31,13 +30,15 @@ func TestBuildSubagentTaskInputPrefersPromptFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildSubagentTaskInputFallsBackToInlinePrompt(t *testing.T) {
|
||||
func TestBuildSubagentTaskInputWithoutPromptFileUsesTaskOnly(t *testing.T) {
|
||||
loop := &AgentLoop{workspace: t.TempDir()}
|
||||
input := loop.buildSubagentTaskInput(&tools.SubagentTask{
|
||||
Task: "run regression",
|
||||
SystemPrompt: "test inline prompt",
|
||||
Task: "run regression",
|
||||
})
|
||||
if !strings.Contains(input, "test inline prompt") {
|
||||
t.Fatalf("expected inline prompt in task input, got: %s", input)
|
||||
if strings.Contains(input, "test inline prompt") {
|
||||
t.Fatalf("did not expect inline prompt fallback, got: %s", input)
|
||||
}
|
||||
if !strings.Contains(input, "run regression") {
|
||||
t.Fatalf("expected task input to contain task, got: %s", input)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user