MCPcopy Create free account
hub / github.com/astercloud/aster / TestPromptBuilder_ToolsManualConfig

Function TestPromptBuilder_ToolsManualConfig

pkg/agent/prompt_builder_test.go:156–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func 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 创建测试依赖
208func setupPromptTestDeps(t *testing.T) *Dependencies {

Callers

nothing calls this directly

Calls 6

setupPromptTestDepsFunction · 0.85
CreateFunction · 0.85
RegisterMethod · 0.65
CloseMethod · 0.65
GetSystemPromptMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected