diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index d23819d..a4502fb 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -145,6 +145,8 @@ scaffolding, or conversation and coordination features. ## Stage 4: Refactor the single-run HTTP API +**Status: Complete.** + 1. Keep `POST /v1/runs` as the single route: the operation is still a run and there is no parallel version to distinguish. This is a direct contract replacement at that path, not a promise of old-client diff --git a/examples/http-run.json b/examples/http-run.json index f56bf66..dabaf15 100644 --- a/examples/http-run.json +++ b/examples/http-run.json @@ -14,5 +14,6 @@ "vars": { "session_date": "2026-05-04" }, - "include_raw_output": false + "include_raw_output": false, + "include_execution_report": false } diff --git a/internal/adapter/http/artifact_reader_test.go b/internal/adapter/http/artifact_reader_test.go index 0c9a330..e1bb25b 100644 --- a/internal/adapter/http/artifact_reader_test.go +++ b/internal/adapter/http/artifact_reader_test.go @@ -11,6 +11,36 @@ import ( "go.maximumdirect.net/promptkit" ) +func TestRestrictedArtifactReaderReturnsDetachedBodies(t *testing.T) { + root := t.TempDir() + if err := os.WriteFile(filepath.Join(root, "input.txt"), []byte("original"), 0o644); err != nil { + t.Fatal(err) + } + reader, err := NewRestrictedArtifactReader(root, 0) + if err != nil { + t.Fatal(err) + } + for _, ref := range []promptkit.ArtifactRef{promptkit.Inline("original"), promptkit.File("input.txt")} { + first, err := reader.Read(context.Background(), ref) + if err != nil { + t.Fatal(err) + } + second, err := reader.Read(context.Background(), ref) + if err != nil { + t.Fatal(err) + } + first.Body[0] = 'X' + first.Name = "changed" + if string(second.Body) != "original" || second.Name == "changed" { + t.Fatalf("read results share mutable state: %+v", second) + } + second.Body[1] = 'Y' + if string(first.Body) != "Xriginal" { + t.Fatalf("reader retained a body alias: %q", first.Body) + } + } +} + func TestRestrictedArtifactReaderReadsContainedFiles(t *testing.T) { root := t.TempDir() outside := t.TempDir() diff --git a/internal/adapter/http/dto.go b/internal/adapter/http/dto.go index 167815d..e95078d 100644 --- a/internal/adapter/http/dto.go +++ b/internal/adapter/http/dto.go @@ -8,7 +8,6 @@ import ( type runRequestDTO struct { PromptID string `json:"prompt_id"` - PromptVersion string `json:"prompt_version,omitempty"` ProfileID string `json:"profile_id,omitempty"` SessionID string `json:"session_id,omitempty"` Inputs map[string]inputRefDTO `json:"inputs"` @@ -59,28 +58,21 @@ type artifactDTO struct { type metadataDTO struct { RunID string `json:"run_id"` PromptID string `json:"prompt_id"` - PromptVersion string `json:"prompt_version"` PromptHash string `json:"prompt_hash"` RenderedPromptHash string `json:"rendered_prompt_hash"` SelectedProfileID string `json:"selected_profile_id"` SelectedBackendID string `json:"selected_backend_id,omitempty"` SessionID string `json:"session_id,omitempty"` - ModelName string `json:"model_name"` - Endpoint string `json:"endpoint"` ModelParams modelParamsDTO `json:"model_params"` InputHashes map[string]string `json:"input_hashes"` Usage tokenUsageDTO `json:"usage"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` DurationMS int64 `json:"duration_ms"` - ValidationMode string `json:"validation_mode"` - ValidationStatus string `json:"validation_status"` - RepairAttemptsUsed int `json:"repair_attempts_used"` } type modelParamsDTO struct { Endpoint string `json:"endpoint"` - BackendID string `json:"backend_id,omitempty"` Model string `json:"model"` Temperature float64 `json:"temperature"` MaxTokens int `json:"max_tokens"` diff --git a/internal/adapter/http/handler.go b/internal/adapter/http/handler.go index 80e8846..de0572e 100644 --- a/internal/adapter/http/handler.go +++ b/internal/adapter/http/handler.go @@ -106,38 +106,36 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { model = executionTargetOverrideFromModelOverrideDTO(req.Model) } - runContext := r.Context() + var operationTimeout time.Duration if req.RunTimeoutSeconds != nil && *req.RunTimeoutSeconds > 0 { - var cancel context.CancelFunc - runContext, cancel = context.WithTimeout(runContext, time.Duration(*req.RunTimeoutSeconds)*time.Second) - defer cancel() + operationTimeout = time.Duration(*req.RunTimeoutSeconds) * time.Second } mappedRequest := promptkit.RunRequest{ PromptID: req.PromptID, - PromptVersion: req.PromptVersion, ProfileID: req.ProfileID, SessionID: req.SessionID, Inputs: mappedInputs, Vars: req.Vars, Execution: model, TransientRetries: req.TransientRetries, + OperationTimeout: operationTimeout, } var collector *executionreport.Collector if req.IncludeExecutionReport { collector = executionreport.NewCollector() mappedRequest.Observer = collector.Observe } - res, err := h.runner.Run(runContext, mappedRequest) + res, err := h.runner.Run(r.Context(), mappedRequest) var execution *executionreport.Execution if collector != nil { execution = collector.Snapshot() } if err != nil { - switch runContext.Err() { - case context.DeadlineExceeded: + switch { + case errors.Is(err, promptkit.ErrOperationTimeout), errors.Is(err, context.DeadlineExceeded) && errors.Is(r.Context().Err(), context.DeadlineExceeded): writeRunFailure(w, http.StatusGatewayTimeout, "deadline_exceeded", "run execution deadline exceeded", execution, h.options.MaxResponseBytes) return - case context.Canceled: + case errors.Is(err, context.Canceled) && errors.Is(r.Context().Err(), context.Canceled): writeRunFailure(w, http.StatusRequestTimeout, "request_canceled", "run request canceled", execution, h.options.MaxResponseBytes) return } @@ -159,14 +157,11 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Metadata: metadataDTO{ RunID: res.RunID, PromptID: res.PromptID, - PromptVersion: res.PromptVersion, PromptHash: res.PromptHash, RenderedPromptHash: res.RenderedPromptHash, SelectedProfileID: res.SelectedProfileID, SelectedBackendID: res.SelectedBackendID, SessionID: res.SessionID, - ModelName: res.ModelName, - Endpoint: res.Endpoint, ModelParams: modelParamsDTOFromExecutionTarget(res.EffectiveModelParams), InputHashes: res.InputHashes, Usage: tokenUsageDTO{ @@ -176,12 +171,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { CachedTokens: res.Usage.CachedTokens, CacheWriteTokens: res.Usage.CacheWriteTokens, }, - StartTime: res.StartTime, - EndTime: res.EndTime, - DurationMS: res.Duration.Milliseconds(), - ValidationMode: string(res.Validation.Mode), - ValidationStatus: string(res.Validation.Status), - RepairAttemptsUsed: res.Validation.RepairAttempts, + StartTime: res.StartTime, + EndTime: res.EndTime, + DurationMS: res.Duration.Milliseconds(), }, Execution: execution, } @@ -221,7 +213,6 @@ func executionTargetOverrideFromModelOverrideDTO(dto *modelOverrideRequestDTO) * func modelParamsDTOFromExecutionTarget(target promptkit.ExecutionTarget) modelParamsDTO { return modelParamsDTO{ Endpoint: target.Endpoint, - BackendID: target.BackendID, Model: target.Model, Temperature: target.Temperature, MaxTokens: target.MaxTokens, @@ -255,16 +246,16 @@ func mapRunError(err error) (int, string, string) { return http.StatusBadRequest, "profile_required", "profile_id is required when prompt default_profile is not set" case errors.Is(err, promptkit.ErrAPIKeyEnvMissing): return http.StatusBadRequest, "api_key_env_missing", "api_key_env is set but the environment variable is missing" + case errors.Is(err, ErrFileNotAllowed), errors.Is(err, ErrFileOutsideRoot): + return http.StatusBadRequest, "artifact_not_allowed", "file input artifact is not allowed" + case errors.Is(err, ErrFileTooLarge): + return http.StatusRequestEntityTooLarge, "artifact_too_large", "file input artifact is too large" case errors.Is(err, promptkit.ErrPromptLoad): return http.StatusBadRequest, "prompt_load_failed", "failed to load prompt definition" case errors.Is(err, promptkit.ErrProfileLoad): return http.StatusBadRequest, "profile_load_failed", "failed to load execution profile" case errors.Is(err, promptkit.ErrInvalidRequest): return http.StatusBadRequest, "invalid_request", "invalid run request" - case errors.Is(err, ErrFileNotAllowed), errors.Is(err, ErrFileOutsideRoot): - return http.StatusBadRequest, "artifact_not_allowed", "file input artifact is not allowed" - case errors.Is(err, ErrFileTooLarge): - return http.StatusRequestEntityTooLarge, "artifact_too_large", "file input artifact is too large" case errors.Is(err, promptkit.ErrArtifactLoad): return http.StatusBadRequest, "artifact_read_failed", "failed to read input artifact" case errors.Is(err, promptkit.ErrPromptRender): diff --git a/internal/adapter/http/handler_test.go b/internal/adapter/http/handler_test.go index b567e41..0a1e5ff 100644 --- a/internal/adapter/http/handler_test.go +++ b/internal/adapter/http/handler_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "net/http" "net/http/httptest" @@ -336,11 +337,13 @@ func TestHandlerRunTimeoutValidationAndContextMapping(t *testing.T) { name, body string parent context.Context wantDeadline time.Time + wantTimeout time.Duration }{ {name: "omitted inherits deadline", body: `{"prompt_id":"p"}`, parent: parent, wantDeadline: parentDeadline}, {name: "null inherits deadline", body: `{"prompt_id":"p","run_timeout_seconds":null}`, parent: parent, wantDeadline: parentDeadline}, {name: "zero inherits deadline", body: `{"prompt_id":"p","run_timeout_seconds":0}`, parent: parent, wantDeadline: parentDeadline}, - {name: "positive preserves earlier deadline", body: `{"prompt_id":"p","run_timeout_seconds":10}`, parent: parent, wantDeadline: parentDeadline}, + {name: "positive preserves earlier deadline", body: `{"prompt_id":"p","run_timeout_seconds":10}`, parent: parent, wantDeadline: parentDeadline, wantTimeout: 10 * time.Second}, + {name: "positive adds operation budget", body: `{"prompt_id":"p","run_timeout_seconds":2}`, parent: context.Background(), wantTimeout: 2 * time.Second}, {name: "omitted adds no deadline", body: `{"prompt_id":"p"}`, parent: context.Background()}, {name: "null adds no deadline", body: `{"prompt_id":"p","run_timeout_seconds":null}`, parent: context.Background()}, {name: "zero adds no deadline", body: `{"prompt_id":"p","run_timeout_seconds":0}`, parent: context.Background()}, @@ -353,6 +356,9 @@ func TestHandlerRunTimeoutValidationAndContextMapping(t *testing.T) { if ok != !tc.wantDeadline.IsZero() || (ok && !deadline.Equal(tc.wantDeadline)) { t.Fatalf("execution deadline: got %v (present=%t), want %v", deadline, ok, tc.wantDeadline) } + if req.OperationTimeout != tc.wantTimeout { + t.Fatalf("operation timeout = %v, want %v", req.OperationTimeout, tc.wantTimeout) + } return &promptkit.RunResult{}, nil })) w := httptest.NewRecorder() @@ -382,6 +388,22 @@ func TestHandlerRunTimeoutValidationAndContextMapping(t *testing.T) { h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p","run_timeout_seconds":10}`))) assertHTTPErrorCode(t, w, http.StatusBadGateway, "llm_failed") + expired, cancelExpired := context.WithDeadline(context.Background(), time.Now().Add(-time.Second)) + defer cancelExpired() + h = NewHandler(runnerFunc(func(ctx context.Context, req promptkit.RunRequest) (*promptkit.RunResult, error) { + return nil, fmt.Errorf("run failed: %w", ctx.Err()) + })) + w = httptest.NewRecorder() + h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p"}`)).WithContext(expired)) + assertHTTPErrorCode(t, w, http.StatusGatewayTimeout, "deadline_exceeded") + + h = NewHandler(runnerFunc(func(ctx context.Context, req promptkit.RunRequest) (*promptkit.RunResult, error) { + return nil, errors.Join(promptkit.ErrOperationTimeout, context.Canceled) + })) + w = httptest.NewRecorder() + h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p"}`)).WithContext(canceled)) + assertHTTPErrorCode(t, w, http.StatusGatewayTimeout, "deadline_exceeded") + successContext, cancelSuccess := context.WithCancel(context.Background()) h = NewHandler(runnerFunc(func(ctx context.Context, req promptkit.RunRequest) (*promptkit.RunResult, error) { cancelSuccess() @@ -447,7 +469,6 @@ func TestHandlerPostRunsSuccessWithExplicitProfileID(t *testing.T) { }, Validation: promptkit.ValidationResult{Status: promptkit.ValidationPassed, Mode: promptkit.ValidationBasic, IsValid: true}, PromptID: "prompt-1", - PromptVersion: "1.0.0", PromptHash: "phash", RenderedPromptHash: "rhash", SelectedProfileID: "exec-default", @@ -508,8 +529,10 @@ func TestHandlerPostRunsSuccessWithExplicitProfileID(t *testing.T) { if metadata["prompt_id"] != "prompt-1" { t.Fatalf("unexpected metadata.prompt_id: %#v", metadata["prompt_id"]) } - if metadata["prompt_version"] != "1.0.0" { - t.Fatalf("unexpected metadata.prompt_version: %#v", metadata["prompt_version"]) + for _, field := range []string{"prompt_version", "model_name", "endpoint", "validation_mode", "validation_status", "repair_attempts_used"} { + if _, ok := metadata[field]; ok { + t.Fatalf("redundant metadata field %q: %#v", field, metadata) + } } if metadata["selected_profile_id"] != "exec-default" { t.Fatalf("unexpected metadata.selected_profile_id: %#v", metadata["selected_profile_id"]) @@ -517,9 +540,6 @@ func TestHandlerPostRunsSuccessWithExplicitProfileID(t *testing.T) { if metadata["selected_backend_id"] != "local" { t.Fatalf("unexpected metadata.selected_backend_id: %#v", metadata["selected_backend_id"]) } - if metadata["model_name"] != "m1" || metadata["endpoint"] != "http://llm/v1" { - t.Fatalf("unexpected model metadata: name=%#v endpoint=%#v", metadata["model_name"], metadata["endpoint"]) - } usage := metadata["usage"].(map[string]any) if usage["prompt_tokens"] != float64(1) || usage["completion_tokens"] != float64(2) || usage["total_tokens"] != float64(3) { t.Fatalf("unexpected base usage metadata: %#v", usage) @@ -528,8 +548,8 @@ func TestHandlerPostRunsSuccessWithExplicitProfileID(t *testing.T) { t.Fatalf("unexpected cache usage metadata: %#v", usage) } modelParams := metadata["model_params"].(map[string]any) - if modelParams["backend_id"] != "local" { - t.Fatalf("expected model_params.backend_id=local, got %#v", modelParams["backend_id"]) + if _, ok := modelParams["backend_id"]; ok || modelParams["model"] != "m1" || modelParams["endpoint"] != "http://llm/v1" { + t.Fatalf("unexpected model parameters: %#v", modelParams) } if modelParams["api_key_env"] != envName { t.Fatalf("expected model_params.api_key_env=%q, got %#v", envName, modelParams["api_key_env"]) @@ -561,7 +581,7 @@ func TestHandlerPostRunsSuccessWithExplicitProfileID(t *testing.T) { } } -func TestHandlerAllowsOmittedInputsAndMapsPromptVersion(t *testing.T) { +func TestHandlerAllowsOmittedInputsAndPreservesQualifiedIDs(t *testing.T) { r := &fakeRunner{result: &promptkit.RunResult{ Artifact: promptkit.Artifact{Body: []byte("ok")}, Validation: promptkit.ValidationResult{Status: promptkit.ValidationPassed, Mode: promptkit.ValidationNone, IsValid: true}, @@ -570,8 +590,8 @@ func TestHandlerAllowsOmittedInputsAndMapsPromptVersion(t *testing.T) { h := NewHandler(r) for _, body := range []string{ - `{"prompt_id":"prompt-1","prompt_version":"2"}`, - `{"prompt_id":"prompt-1","prompt_version":"2","inputs":{}}`, + `{"prompt_id":"support/prompt-1","profile_id":"support/profile-1"}`, + `{"prompt_id":"support/prompt-1","profile_id":"support/profile-1","inputs":{}}`, } { req := httptest.NewRequest(http.MethodPost, "/v1/runs", bytes.NewBufferString(body)) w := httptest.NewRecorder() @@ -580,8 +600,8 @@ func TestHandlerAllowsOmittedInputsAndMapsPromptVersion(t *testing.T) { if w.Code != http.StatusOK { t.Fatalf("expected 200, got %d body=%s", w.Code, w.Body.String()) } - if r.last.PromptVersion != "2" { - t.Fatalf("expected prompt version to be mapped, got %q", r.last.PromptVersion) + if r.last.PromptID != "support/prompt-1" || r.last.ProfileID != "support/profile-1" { + t.Fatalf("qualified IDs changed: %+v", r.last) } if r.last.Inputs != nil { t.Fatalf("expected omitted or empty inputs to remain nil, got %#v", r.last.Inputs) @@ -589,6 +609,16 @@ func TestHandlerAllowsOmittedInputsAndMapsPromptVersion(t *testing.T) { } } +func TestHandlerRejectsRemovedPromptVersion(t *testing.T) { + runner := &fakeRunner{result: &promptkit.RunResult{}} + w := httptest.NewRecorder() + NewHandler(runner).ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p","prompt_version":"1"}`))) + assertHTTPErrorCode(t, w, http.StatusBadRequest, "invalid_json") + if runner.last.PromptID != "" { + t.Fatal("runner invoked for removed selector") + } +} + func TestHandlerDelegatesDefinitionInputRequirements(t *testing.T) { tests := []struct { name string @@ -786,7 +816,6 @@ func TestHandlerPostRunsSuccessUsingPromptDefaultProfile(t *testing.T) { r := &fakeRunner{result: &promptkit.RunResult{ Artifact: promptkit.Artifact{Body: []byte("ok")}, PromptID: "prompt-1", - PromptVersion: "1.0.0", SelectedProfileID: "prompt-default", Validation: promptkit.ValidationResult{Status: promptkit.ValidationPassed, Mode: promptkit.ValidationBasic, IsValid: true}, EffectiveModelParams: promptkit.ExecutionTarget{Endpoint: "http://llm/v1", Model: "m1"}, @@ -1191,9 +1220,13 @@ func TestHandlerDeadlineCancelsBuiltInRetryWait(t *testing.T) { })) defer provider.Close() h := newRetryHandler(t, provider.URL+"/v1", intPointer(1), 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}`))) assertHTTPErrorCode(t, w, http.StatusGatewayTimeout, "deadline_exceeded") + if err := <-failures; !errors.Is(err, promptkit.ErrOperationTimeout) { + t.Fatalf("engine did not attribute retry wait to operation timeout: %v", err) + } if atomic.LoadInt32(&hits) != 1 { t.Fatalf("expected one provider call before canceled retry wait, got %d", atomic.LoadInt32(&hits)) } @@ -1221,6 +1254,7 @@ func TestHandlerDeadlineCancelsCapacityWaitAndReleasesAdmission(t *testing.T) { }() queue := 1 h := newRetryHandler(t, provider.URL+"/v1", intPointer(0), 1, &queue) + failures := observeRunnerFailures(h) first := httptest.NewRecorder() done := make(chan struct{}) go func() { @@ -1235,6 +1269,9 @@ func TestHandlerDeadlineCancelsCapacityWaitAndReleasesAdmission(t *testing.T) { waiting := httptest.NewRecorder() h.ServeHTTP(waiting, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p","run_timeout_seconds":1}`))) assertHTTPErrorCode(t, waiting, http.StatusGatewayTimeout, "deadline_exceeded") + if err := <-failures; !errors.Is(err, promptkit.ErrOperationTimeout) { + t.Fatalf("engine did not attribute capacity wait to operation timeout: %v", err) + } if atomic.LoadInt32(&hits) != 1 { t.Fatalf("capacity waiter reached provider: hits=%d", atomic.LoadInt32(&hits)) } @@ -1254,27 +1291,39 @@ func TestHandlerDeadlineCancelsCapacityWaitAndReleasesAdmission(t *testing.T) { } } +func observeRunnerFailures(h *Handler) <-chan error { + failures := make(chan error, 1) + runner := h.runner + h.runner = runnerFunc(func(ctx context.Context, request promptkit.RunRequest) (*promptkit.RunResult, error) { + result, err := runner.Run(ctx, request) + if err != nil { + failures <- err + } + return result, err + }) + return failures +} + func newRetryHandler(t *testing.T, endpoint string, retries *int, concurrency int, queue *int) *Handler { t.Helper() promptDir := t.TempDir() profileDir := t.TempDir() if err := os.WriteFile(filepath.Join(promptDir, "prompt.yaml"), []byte(`prompts: - p: - "1": - default_profile: limited - messages: - - role: user - content: hi - output: - format: text - validation_mode: none + - id: p + default_profile: limited + messages: + - role: user + content: hi + output: + format: text + validation_mode: none `), 0o644); err != nil { t.Fatal(err) } - if err := os.WriteFile(filepath.Join(profileDir, "profile.yaml"), []byte("profiles:\n limited:\n backend: limited\n model: test\n"), 0o644); err != nil { + if err := os.WriteFile(filepath.Join(profileDir, "profile.yaml"), []byte("profiles:\n - id: limited\n backend: limited\n model: test\n"), 0o644); err != nil { t.Fatal(err) } - backend := promptkit.BackendConfig{Endpoint: &endpoint, ConcurrencyLimit: &concurrency, QueueCapacity: queue} + backend := promptkit.BackendConfig{ID: "limited", Endpoint: &endpoint, ConcurrencyLimit: &concurrency, QueueCapacity: queue} engine := newHandlerEngineFromDirectories(t, promptDir, profileDir, retries, &backend) return NewHandler(engine) } @@ -1627,6 +1676,7 @@ func TestHandlerPublicErrorMapping(t *testing.T) { {name: "file denied", err: ErrFileNotAllowed, status: http.StatusBadRequest, code: "artifact_not_allowed", message: "file input artifact is not allowed"}, {name: "file outside root", err: ErrFileOutsideRoot, status: http.StatusBadRequest, code: "artifact_not_allowed", message: "file input artifact is not allowed"}, {name: "file too large", err: ErrFileTooLarge, status: http.StatusRequestEntityTooLarge, code: "artifact_too_large", message: "file input artifact is too large"}, + {name: "file too large with broad category", err: errors.Join(ErrFileTooLarge, promptkit.ErrInvalidRequest, promptkit.ErrArtifactLoad), status: http.StatusRequestEntityTooLarge, code: "artifact_too_large", message: "file input artifact is too large"}, {name: "artifact", err: wrap(promptkit.ErrArtifactLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "artifact_read_failed", message: "failed to read input artifact", avoidCause: "read failed"}, {name: "prompt render", err: wrap(promptkit.ErrPromptRender, fmt.Errorf("render failed")), status: http.StatusBadRequest, code: "prompt_render_failed", message: "failed to render prompt", avoidCause: "render failed"}, {name: "capacity", err: &promptkit.CapacityError{BackendID: "private-backend"}, status: http.StatusServiceUnavailable, code: "capacity_exceeded", message: "model backend capacity is exhausted", avoidCause: "private-backend"}, @@ -1829,7 +1879,7 @@ func newHandlerEngineFromDirectories(t *testing.T, promptDir, profileDir string, } underlays := []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}} if backend != nil { - underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{Source: promptkit.BackendSource("test backend", map[string]promptkit.BackendConfig{"limited": *backend})}}}) + underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{Source: promptkit.BackendSource("test backend", []promptkit.BackendConfig{*backend})}}}) } engine, err := promptkit.NewEngine(promptkit.Config{