(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func TestPromptBuilder_ToolsManualConfig(t *testing.T) { |
| 157 | deps := setupPromptTestDeps(t) |
| 158 | |
| 159 | // 注册模板,只包含部分工具 |
| 160 | deps.TemplateRegistry.Register(&types.AgentTemplateDefinition{ |
| 161 | ID: "selective-tools", |
| 162 | SystemPrompt: "You are a selective assistant.", |
| 163 | Tools: []any{"Read", "Write"}, |
| 164 | Runtime: &types.AgentTemplateRuntime{ |
| 165 | ToolsManual: &types.ToolsManualConfig{ |
| 166 | Mode: "listed", |
| 167 | Include: []string{"Read"}, // 只包含 Read 工具 |
| 168 | }, |
| 169 | }, |
| 170 | }) |
| 171 | |
| 172 | config := &types.AgentConfig{ |
| 173 | TemplateID: "selective-tools", |
| 174 | ModelConfig: &types.ModelConfig{ |
| 175 | Provider: "anthropic", |
| 176 | Model: "claude-sonnet-4-5", |
| 177 | APIKey: "test-key", |
| 178 | }, |
| 179 | Sandbox: &types.SandboxConfig{ |
| 180 | Kind: types.SandboxKindMock, |
| 181 | WorkDir: "/tmp/test", |
| 182 | }, |
| 183 | } |
| 184 | |
| 185 | ag, err := Create(context.Background(), config, deps) |
| 186 | if err != nil { |
| 187 | t.Fatalf("Failed to create agent: %v", err) |
| 188 | } |
| 189 | defer func() { _ = ag.Close() }() |
| 190 | |
| 191 | // 获取 System Prompt |
| 192 | systemPrompt := ag.GetSystemPrompt() |
| 193 | |
| 194 | // 验证只包含 Read 工具 |
| 195 | if !strings.Contains(systemPrompt, "`Read`") { |
| 196 | t.Error("System prompt should contain Read tool") |
| 197 | } |
| 198 | |
| 199 | // 验证不包含 Write 工具 |
| 200 | if strings.Contains(systemPrompt, "`Write`") { |
| 201 | t.Error("System prompt should not contain Write tool (excluded by config)") |
| 202 | } |
| 203 | |
| 204 | t.Logf("Selective Tools System Prompt:\n%s", systemPrompt) |
| 205 | } |
| 206 | |
| 207 | // setupPromptTestDeps 创建测试依赖 |
| 208 | func setupPromptTestDeps(t *testing.T) *Dependencies { |
nothing calls this directly
no test coverage detected