Compare commits
1 Commits
main
...
codex/fix-
| Author | SHA1 | Date |
|---|---|---|
|
|
9147dcdb4e |
|
|
@ -114,6 +114,58 @@ func piTestAgent(cfg *config.Config, handler mcp.ToolHandler) *agent.Agent {
|
||||||
return agent.NewAgent(&cfg.OpenAI, &cfg.Agent, srv, nil, zap.NewNop(), 8)
|
return agent.NewAgent(&cfg.OpenAI, &cfg.Agent, srv, nil, zap.NewNop(), 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPiSingleChatAcceptsParameterlessTaskListSchema(t *testing.T) {
|
||||||
|
cfg := piTestConfig(t)
|
||||||
|
cfg.SkillsDir = t.TempDir()
|
||||||
|
cfg.MultiAgent.Runtime.PlantaskEnable = true
|
||||||
|
cfg.MultiAgent.Skills = config.AgentSkillsConfig{FilesystemTools: new(bool)}
|
||||||
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var body struct {
|
||||||
|
Tools []struct {
|
||||||
|
Function struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Parameters map[string]any `json:"parameters"`
|
||||||
|
} `json:"function"`
|
||||||
|
} `json:"tools"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, tool := range body.Tools {
|
||||||
|
if tool.Function.Name != "TaskList" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if required, exists := tool.Function.Parameters["required"]; exists {
|
||||||
|
if names, ok := required.([]any); !ok || len(names) != 0 {
|
||||||
|
http.Error(w, "Invalid schema for function 'TaskList': expected an array of required parameters", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
piReply(w, "", "", nil, "hello")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.Error("TaskList is missing from the request")
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
}))
|
||||||
|
defer server.Close()
|
||||||
|
cfg.OpenAI.BaseURL = server.URL + "/v1"
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
ag := piTestAgent(cfg, func(context.Context, map[string]any) (*mcp.ToolResult, error) {
|
||||||
|
t.Error("plain chat must not execute the fixture tool")
|
||||||
|
return nil, fmt.Errorf("unexpected tool call")
|
||||||
|
})
|
||||||
|
res, err := RunSingleAgent(ctx, cfg, &cfg.MultiAgent, ag, nil, zap.NewNop(), "schema-fixture", "", "say hello", nil, []string{"echo"}, nil, nil, "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if res.RuntimeStatus != "completed" || res.Response != "hello" {
|
||||||
|
t.Fatalf("expected a chat reply, got %+v", res)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPiSinglePreservesHITLAndExecutionEvidence(t *testing.T) {
|
func TestPiSinglePreservesHITLAndExecutionEvidence(t *testing.T) {
|
||||||
cfg := piTestConfig(t)
|
cfg := piTestConfig(t)
|
||||||
var calls atomic.Int32
|
var calls atomic.Int32
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,12 @@ func runPiSingle(ctx context.Context, cfg *config.Config, ag *agent.Agent, db *d
|
||||||
}
|
}
|
||||||
|
|
||||||
func piToolSchema(properties map[string]any, required ...string) map[string]any {
|
func piToolSchema(properties map[string]any, required ...string) map[string]any {
|
||||||
return map[string]any{"type": "object", "properties": properties, "required": required}
|
schema := map[string]any{"type": "object", "properties": properties}
|
||||||
|
// A nil slice would encode as null, which is not a valid required list.
|
||||||
|
if len(required) > 0 {
|
||||||
|
schema["required"] = required
|
||||||
|
}
|
||||||
|
return schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPiMulti(ctx context.Context, cfg *config.Config, ma *config.MultiAgentConfig, ag *agent.Agent, db *database.DB, logger *zap.Logger,
|
func runPiMulti(ctx context.Context, cfg *config.Config, ma *config.MultiAgentConfig, ag *agent.Agent, db *database.DB, logger *zap.Logger,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue