Preserve smoke observer failures independently of readiness
This commit is contained in:
@@ -34,16 +34,13 @@ func RunSmokeChecksObserved(ctx context.Context, engine *promptkit.Engine, targe
|
||||
return nil, err
|
||||
}
|
||||
var observations []SmokeObservation
|
||||
total := 2*len(targets.Access) + len(targets.Profiles)
|
||||
run := func(kind promptkit.SmokeTestKind, profile, backend string, bindings []BindingScope) error {
|
||||
report, err := engine.SmokeTest(ctx, promptkit.SmokeTestRequest{Kind: kind, ProfileID: profile, Execution: execution, TransientRetries: retries})
|
||||
observation := SmokeObservation{Kind: kind, ProfileID: profile, BackendID: backend, Bindings: bindings, Report: report}
|
||||
observation.Applicable, observation.Err = evaluateSmoke(kind, report, err)
|
||||
observations = append(observations, observation)
|
||||
if observe != nil {
|
||||
if observeErr := observe(observation); observeErr != nil && observation.Err == nil && len(observations) < total {
|
||||
return observeErr
|
||||
}
|
||||
return errors.Join(observation.Err, observe(observation))
|
||||
}
|
||||
return observation.Err
|
||||
}
|
||||
|
||||
@@ -111,3 +111,28 @@ func TestSmokeCaptureFailureStopsBeforeFurtherChecks(t *testing.T) {
|
||||
t.Fatalf("observations=%+v err=%v", observations, err)
|
||||
}
|
||||
}
|
||||
|
||||
type smokeResultClient struct{ err error }
|
||||
|
||||
func (client smokeResultClient) Generate(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
|
||||
return &promptkit.GenerateResponse{Content: `{"status":"ok"}`}, client.err
|
||||
}
|
||||
|
||||
func TestSmokeRetainsTerminalObserverAndDiagnosticErrors(t *testing.T) {
|
||||
providerErr := errors.New("provider failed")
|
||||
observerErr := errors.New("observer failed")
|
||||
for _, cause := range []error{nil, providerErr} {
|
||||
input := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("smoke", map[string]any{"profiles": []any{map[string]any{"id": "profile", "endpoint": "http://example.invalid/v1", "model": "fixture"}}})}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &input}}, promptkit.WithBundledOpenRouter(false), promptkit.WithLLMClient(smokeResultClient{cause}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
observations, err := RunSmokeChecksObserved(context.Background(), engine, Targets{Profiles: []ProfileTarget{{ID: "profile"}}}, nil, nil, func(SmokeObservation) error { return observerErr })
|
||||
if len(observations) != 1 || !errors.Is(err, observerErr) || cause != nil && !errors.Is(err, observations[0].Err) {
|
||||
t.Fatalf("observations=%+v error=%v", observations, err)
|
||||
}
|
||||
if (observations[0].Err != nil) != (cause != nil) {
|
||||
t.Fatalf("recording failure changed native verdict: %+v", observations[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user