Adopt PromptKit timeout fix and complete verification

This commit is contained in:
2026-11-19 14:39:10 +00:00
parent 78bcf86619
commit c5e54edaa5
20 changed files with 92 additions and 57 deletions

View File

@@ -1227,6 +1227,42 @@ func TestHandlerDeadlineCancelsBuiltInRetryWait(t *testing.T) {
}
}
func TestHandlerDeadlineDuringBuiltInGeneration(t *testing.T) {
started := make(chan struct{}, 1)
release := make(chan struct{})
provider := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
started <- struct{}{}
<-release
}))
defer provider.Close()
defer close(release)
h := newRetryHandler(t, provider.URL+"/v1", intPointer(0), 0, nil)
failures := observeRunnerFailures(h)
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p","run_timeout_seconds":1,"include_execution_report":true}`)))
select {
case <-started:
default:
t.Fatal("provider call did not start")
}
err := <-failures
if !errors.Is(err, promptkit.ErrOperationTimeout) || !errors.Is(err, context.DeadlineExceeded) {
t.Errorf("engine did not attribute in-flight generation to operation timeout: %v (deadline cause: %t)", err, errors.Is(err, context.DeadlineExceeded))
}
var response struct {
Execution *struct {
Failure string `json:"failure"`
} `json:"execution"`
}
if err := json.Unmarshal(w.Body.Bytes(), &response); err != nil {
t.Fatal(err)
}
if response.Execution == nil || response.Execution.Failure != "deadline" {
t.Errorf("terminal report did not classify deadline: %+v", response.Execution)
}
assertHTTPErrorCode(t, w, http.StatusGatewayTimeout, "deadline_exceeded")
}
func TestHandlerDeadlineCancelsCapacityWaitAndReleasesAdmission(t *testing.T) {
started := make(chan struct{}, 1)
release := make(chan struct{})