added auto-continue mechanics, updated default ctx to 262144 tokens
This commit is contained in:
+46
-3
@@ -1124,6 +1124,49 @@ func TestALToolLoop(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestALReasoningOnlyAutoContinue(t *testing.T) {
|
||||
// First response is reasoning-only (no content, no tool calls); the agent
|
||||
// must auto-append a "continue" user message and keep looping until a real
|
||||
// answer arrives.
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Messages []Message `json:"messages"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
t.Errorf("decode request: %v", err)
|
||||
}
|
||||
for _, m := range req.Messages {
|
||||
if m.Role == "user" && m.Content != nil && strings.TrimSpace(*m.Content) == "continue" {
|
||||
w.Write([]byte(`{"choices":[{"message":{"role":"assistant","content":"final answer"}}]}`))
|
||||
return
|
||||
}
|
||||
}
|
||||
w.Write([]byte(`{"choices":[{"message":{"role":"assistant","content":null,"reasoning_content":"thinking hard"}}]}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
cfg := defCfg
|
||||
cfg.Endpoint = srv.URL
|
||||
cfg.Stream = false
|
||||
cfg.APIKey = "-"
|
||||
msgs, _, err := AL(context.Background(), &cfg, []Message{{Role: "system", Content: strp("sys")}, {Role: "user", Content: strp("start")}}, "sys", 0)
|
||||
if err != nil {
|
||||
t.Fatalf("AL: %v", err)
|
||||
}
|
||||
if got := last(msgs); got != "final answer" {
|
||||
t.Errorf("last = %q, want %q", got, "final answer")
|
||||
}
|
||||
var continues int
|
||||
for _, m := range msgs {
|
||||
if m.Role == "user" && m.Content != nil && strings.TrimSpace(*m.Content) == "continue" {
|
||||
continues++
|
||||
}
|
||||
}
|
||||
if continues != 1 {
|
||||
t.Errorf("expected exactly 1 auto continue message, got %d", continues)
|
||||
}
|
||||
}
|
||||
|
||||
func TestALRunSubagent(t *testing.T) {
|
||||
var n int
|
||||
var mu sync.Mutex
|
||||
@@ -1842,12 +1885,12 @@ func TestFetchContextWindowFallbackConfig(t *testing.T) {
|
||||
t.Errorf("expected fallback to raw context_window 65536, got %d", cw)
|
||||
}
|
||||
|
||||
// Case 2: Config does not specify context_window -> default 200000
|
||||
// Case 2: Config does not specify context_window -> default 262144
|
||||
cfg2 := defCfg
|
||||
cfg2.Endpoint = srv.URL
|
||||
cfg2.Raw = map[string]string{}
|
||||
if cw := fetchContextWindow(&cfg2); cw != 200000 {
|
||||
t.Errorf("expected default 200000, got %d", cw)
|
||||
if cw := fetchContextWindow(&cfg2); cw != 262144 {
|
||||
t.Errorf("expected default 262144, got %d", cw)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user