added test

This commit is contained in:
Luxferre
2026-08-11 14:37:03 +03:00
parent c74cdd8f33
commit 398754dabb
+21 -1
View File
@@ -1161,9 +1161,23 @@ func TestALRunSubagent(t *testing.T) {
}
func TestALSubagentDepthLimit(t *testing.T) {
// depth >= MAX_DEPTH must not spawn an HTTP request at all
// depth >= MAX_DEPTH must not spawn a child request; the LLM gets the
// depth-limit tool result and is expected to acknowledge and finish.
var n int
var mu sync.Mutex
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mu.Lock()
n++
cur := n
mu.Unlock()
switch cur {
case 1:
w.Write([]byte(`{"choices":[{"message":{"role":"assistant","content":null,"tool_calls":[{"id":"c1","type":"function","function":{"name":"run_subagent","arguments":"{\"prompt\":\"deep\"}"}}]}}]}`))
case 2:
w.Write([]byte(`{"choices":[{"message":{"role":"assistant","content":"done"}}]}`))
default:
t.Errorf("unexpected request #%d (child must not be spawned)", cur)
}
}))
defer srv.Close()
@@ -1175,6 +1189,12 @@ func TestALSubagentDepthLimit(t *testing.T) {
if err != nil {
t.Fatalf("AL: %v", err)
}
if n != 2 {
t.Errorf("expected exactly 2 LLM requests, got %d", n)
}
if got := last(msgs); got != "done" {
t.Errorf("last = %q, want done", got)
}
found := false
for _, m := range msgs {
if m.Role == "tool" && m.Content != nil && strings.Contains(*m.Content, "depth limit") {