Use resolved targets for client routing

This commit is contained in:
2026-11-05 19:52:48 +00:00
parent de46935a0e
commit 448e64dc40
15 changed files with 157 additions and 396 deletions

View File

@@ -16,14 +16,13 @@ Generation sends an HTTP `POST` with `Content-Type: application/json`.
Before the client is called, the engine resolves framework, backend, profile,
and request values into one execution target. Endpoint configuration is trimmed
and must be an absolute HTTP or HTTPS URL with a host and without user
information, a query, or a fragment. A non-empty endpoint from the target
overrides the client's configured base URL. The final selected endpoint is
validated again before transport.
information, a query, or a fragment. The target's endpoint is validated again
before transport.
The completion URL is composed through parsed URL path operations. Nested base
paths are retained, repeated trailing slashes are normalized, and the result
has exactly one appended `/chat/completions` suffix. Generation fails before
sending when neither source supplies a valid endpoint.
sending when the target does not supply a valid endpoint.
The target's backend ID is routing metadata for prepared values, results, and
injected clients. The built-in client does not derive the URL from that ID and
@@ -89,8 +88,7 @@ transport for HTTP-only diagnostics.
## Request Body
The request body always contains `model` and `messages`. The execution
target's model takes precedence over the client's configured model, and one
must be available.
target's model must be available.
Each ordinary message contains its `role` and string `content`. A
cache-controlled message instead uses a text content block containing `type`,

View File

@@ -26,10 +26,9 @@ client uses its endpoint, credential metadata, generation fields, and extra
parameters. `BackendID` remains routing metadata
for the generation boundary and is not mapped into the provider payload.
Construction trims and validates a nonempty configured base URL and clones any
supplied `http.Client` so Promptkit can apply its timeout default without
mutating the caller's client. An empty configured base remains valid because a
resolved request target may supply the endpoint. Generation preparation then:
Construction clones any supplied `http.Client` so Promptkit can apply its
timeout default without mutating the caller's client. Generation preparation
then:
1. validates shared execution-setting invariants and the final selected base
endpoint;
@@ -106,14 +105,13 @@ public ownership and redaction semantics belong to the
## Failure Categories
The package preserves distinct error identities for invalid client
configuration, invalid generation requests, request execution failures,
non-success provider statuses, and malformed successful responses. Provider
response bodies are never exposed in raw form through non-success errors.
The package preserves distinct error identities for invalid generation
requests, request execution failures, non-success provider statuses, and
malformed successful responses. Provider response bodies are never exposed in
raw form through non-success errors.
Invalid nonempty configured endpoints are configuration failures. A missing or
invalid final selected endpoint is an invalid generation request and is
rejected before transport.
A missing or invalid final selected endpoint is an invalid generation request
and is rejected before transport.
Authentication resolves a trimmed direct key before a trimmed configured
environment value. Optional missing, empty, or whitespace-only sources do not

View File

@@ -71,6 +71,11 @@ introduce a new ownership subsystem.
## Stage 1: Remove Client-Level Routing Fallbacks
**Completed:** Client routing now uses the resolved target; constructor fixtures
and integration guidance were migrated. With Go 1.27.3, `go test ./internal/llm
./internal/generation ./internal/configuration ./internal/usecase ./internal/engine`
passed, including loaded-target coverage.
**Finding:** 1. **Files:** `internal/llm/openai_compatible_client.go`, client
fixtures/tests, `internal/engine/engine.go` caller verification, `docs/internal/llm.md`.