@@ -363,101 +363,6 @@ func TestRunsAPICancelAndEventsStream(t *testing.T) {
363363 }
364364}
365365
366- func TestScheduledRunsAPIListShowAndCancel (t * testing.T ) {
367- t .Parallel ()
368-
369- handler := newTestAPIHandler (t , & sequenceExecutor {
370- steps : []executorStep {
371- {role : assistant .AttemptRoleGate , result : gatePhaseResult ("workflow" , "This request requires full workflow execution." )},
372- {role : assistant .AttemptRoleProjectSelector , result : projectSelectorPhaseResult ("hospital-outreach" , "Hospital Outreach" , "Research and contact hospitals." )},
373- {role : assistant .AttemptRolePlanner , result : plannerPhaseResultWithSchedule ("Research hospitals" , []string {"Hospital shortlist" }, []assistant.ScheduleEntry {
374- {ScheduledFor : "13:00" , Prompt : "Call the first shortlisted hospital." },
375- })},
376- {role : assistant .AttemptRoleContractor , result : contractPhaseResult ("agreed" , []string {"Hospital shortlist" })},
377- {role : assistant .AttemptRoleGenerator , result : generatorPhaseResult ("Prepared hospital shortlist" )},
378- {role : assistant .AttemptRoleEvaluator , result : evaluatorPhaseResult (true , 92 , "The result package is complete." , nil , "" )},
379- {role : assistant .AttemptRoleScheduler , result : schedulerPhaseResult ([]assistant.ScheduleEntry {
380- {ScheduledFor : "2026-04-03T13:00:00Z" , Prompt : "Call the first shortlisted hospital." },
381- })},
382- {role : assistant .AttemptRoleReporter , result : reportPhaseResult ("Delivered final report." , "Hospital outreach scheduled." )},
383- },
384- })
385-
386- createResponse := doJSONRequest (t , handler , http .MethodPost , "/api/v1/runs" , map [string ]any {
387- "user_request_raw" : "Research hospitals and schedule a call later." ,
388- })
389- if createResponse .Code != http .StatusAccepted {
390- t .Fatalf ("POST /runs status = %d, want %d" , createResponse .Code , http .StatusAccepted )
391- }
392-
393- var created createRunResponse
394- if err := json .Unmarshal (createResponse .Body .Bytes (), & created ); err != nil {
395- t .Fatalf ("decode create response: %v" , err )
396- }
397-
398- record := waitForRunStatus (t , handler , created .Run .ID , assistant .RunStatusCompleted )
399- if len (record .ScheduledRuns ) != 1 {
400- t .Fatalf ("len(record.ScheduledRuns) = %d, want 1 auto-created scheduled run" , len (record .ScheduledRuns ))
401- }
402-
403- createScheduledResponse := doJSONRequest (t , handler , http .MethodPost , "/api/v1/runs/" + created .Run .ID + "/scheduled" , map [string ]any {
404- "scheduled_for" : "2026-04-03T13:00:00Z" ,
405- "prompt" : "Call Saint Mary Hospital at +1-555-0100." ,
406- })
407- if createScheduledResponse .Code != http .StatusCreated {
408- t .Fatalf ("POST /runs/:id/scheduled status = %d, want %d" , createScheduledResponse .Code , http .StatusCreated )
409- }
410- var createdScheduled assistant.ScheduledRun
411- if err := json .Unmarshal (createScheduledResponse .Body .Bytes (), & createdScheduled ); err != nil {
412- t .Fatalf ("decode scheduled create response: %v" , err )
413- }
414- scheduledRunID := createdScheduled .ID
415-
416- listResponse := doJSONRequest (t , handler , http .MethodGet , "/api/v1/scheduled?chat_id=" + created .Run .ChatID + "&status=pending" , nil )
417- if listResponse .Code != http .StatusOK {
418- t .Fatalf ("GET /scheduled status = %d, want %d" , listResponse .Code , http .StatusOK )
419- }
420- var listed struct {
421- ScheduledRuns []assistant.ScheduledRun `json:"scheduled_runs"`
422- }
423- if err := json .Unmarshal (listResponse .Body .Bytes (), & listed ); err != nil {
424- t .Fatalf ("decode list response: %v" , err )
425- }
426- if len (listed .ScheduledRuns ) != 2 {
427- t .Fatalf ("listed = %#v, want 2 scheduled runs after manual creation" , listed )
428- }
429-
430- showResponse := doJSONRequest (t , handler , http .MethodGet , "/api/v1/scheduled/" + scheduledRunID , nil )
431- if showResponse .Code != http .StatusOK {
432- t .Fatalf ("GET /scheduled/:id status = %d, want %d" , showResponse .Code , http .StatusOK )
433- }
434-
435- updateResponse := doJSONRequest (t , handler , http .MethodPost , "/api/v1/scheduled/" + scheduledRunID + "/update" , map [string ]any {
436- "scheduled_for" : "2026-04-03T14:00:00Z" ,
437- "prompt" : "Call General Hospital at +1-555-0101." ,
438- })
439- if updateResponse .Code != http .StatusOK {
440- t .Fatalf ("POST /scheduled/:id/update status = %d, want %d" , updateResponse .Code , http .StatusOK )
441- }
442- var updated assistant.ScheduledRun
443- if err := json .Unmarshal (updateResponse .Body .Bytes (), & updated ); err != nil {
444- t .Fatalf ("decode update response: %v" , err )
445- }
446- if updated .UserRequestRaw != "Call General Hospital at +1-555-0101." {
447- t .Fatalf ("updated prompt = %q, want updated scheduled prompt" , updated .UserRequestRaw )
448- }
449-
450- cancelResponse := doJSONRequest (t , handler , http .MethodPost , "/api/v1/scheduled/" + scheduledRunID + "/cancel" , map [string ]any {})
451- if cancelResponse .Code != http .StatusOK {
452- t .Fatalf ("POST /scheduled/:id/cancel status = %d, want %d" , cancelResponse .Code , http .StatusOK )
453- }
454-
455- byParentResponse := doJSONRequest (t , handler , http .MethodGet , "/api/v1/runs/" + created .Run .ID + "/scheduled" , nil )
456- if byParentResponse .Code != http .StatusOK {
457- t .Fatalf ("GET /runs/:id/scheduled status = %d, want %d" , byParentResponse .Code , http .StatusOK )
458- }
459- }
460-
461366func TestProjectsAPIListsWikiAndSupportsIndexAndLint (t * testing.T ) {
462367 t .Parallel ()
463368
0 commit comments