test(agent): add regression test for invalid exec config fallback
This commit is contained in:
parent
d7a378cb28
commit
81dc3a1d81
1 changed files with 34 additions and 0 deletions
|
|
@ -246,3 +246,37 @@ func TestNewAgentInstance_AllowsMediaTempDirForReadListAndExec(t *testing.T) {
|
||||||
t.Fatalf("exec output missing media content: %s", execResult.ForLLM)
|
t.Fatalf("exec output missing media content: %s", execResult.ForLLM)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewAgentInstance_InvalidExecConfigDoesNotExit(t *testing.T) {
|
||||||
|
workspace := t.TempDir()
|
||||||
|
|
||||||
|
cfg := &config.Config{
|
||||||
|
Agents: config.AgentsConfig{
|
||||||
|
Defaults: config.AgentDefaults{
|
||||||
|
Workspace: workspace,
|
||||||
|
ModelName: "test-model",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Tools: config.ToolsConfig{
|
||||||
|
ReadFile: config.ReadFileToolConfig{Enabled: true},
|
||||||
|
Exec: config.ExecConfig{
|
||||||
|
ToolConfig: config.ToolConfig{Enabled: true},
|
||||||
|
EnableDenyPatterns: true,
|
||||||
|
CustomDenyPatterns: []string{"[invalid-regex"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
agent := NewAgentInstance(nil, &cfg.Agents.Defaults, cfg, &mockProvider{})
|
||||||
|
if agent == nil {
|
||||||
|
t.Fatal("expected agent instance, got nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := agent.Tools.Get("exec"); ok {
|
||||||
|
t.Fatal("exec tool should not be registered when exec config is invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := agent.Tools.Get("read_file"); !ok {
|
||||||
|
t.Fatal("read_file tool should still be registered")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue