diff --git a/internal/server/work_checkpoint_eval_test.go b/internal/server/work_checkpoint_eval_test.go index dd5bf75..7ee1e4f 100644 --- a/internal/server/work_checkpoint_eval_test.go +++ b/internal/server/work_checkpoint_eval_test.go @@ -108,6 +108,9 @@ func evalMechanismStream(ctx context.Context, model string, msgs []agentllm.Mess content := "已收到材料,正在后台整理;请结合阶段发现继续工作。" var calls []agentllm.ToolCall if checkpoint { + if toolReplies == 0 && strings.Contains(sourceText, "[fixture:queue-hold]") { + time.Sleep(8 * time.Second) + } count := toolReplies matches := mechanismCheckpointSources(sourceText) matches = filterCheckpointSources(matches) @@ -280,7 +283,44 @@ func TestServeWorkCheckpointEval(t *testing.T) { if e = os.WriteFile(manifest, raw, 0600); e != nil { t.Fatal(e) } - httpServer := &http.Server{Handler: server.Handler()} + baseHandler := server.Handler() + var handler http.Handler = baseHandler + if mode == "mechanism" { + handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/__fixture/material-start-failure" { + baseHandler.ServeHTTP(w, r) + return + } + if r.Method != http.MethodPost { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + var request struct { + Enabled bool `json:"enabled"` + } + if err := json.NewDecoder(r.Body).Decode(&request); err != nil { + http.Error(w, "invalid fixture request", http.StatusBadRequest) + return + } + db, err := sql.Open("sqlite", filepath.Join(dir, "agent-system.db")) + if err != nil { + http.Error(w, "fixture storage unavailable", http.StatusInternalServerError) + return + } + defer db.Close() + statement := `DROP TRIGGER IF EXISTS fixture_fail_material_claim` + if request.Enabled { + statement = `CREATE TRIGGER IF NOT EXISTS fixture_fail_material_claim BEFORE INSERT ON conversation_executions + WHEN NEW.conversation_id LIKE 'task:%' BEGIN SELECT RAISE(FAIL, 'fixture material claim failure'); END` + } + if _, err := db.Exec(statement); err != nil { + http.Error(w, "fixture storage fault unavailable", http.StatusInternalServerError) + return + } + w.WriteHeader(http.StatusNoContent) + }) + } + httpServer := &http.Server{Handler: handler} done := make(chan error, 1) go func() { done <- httpServer.Serve(listener) }() stop := make(chan os.Signal, 1)