Provider presets and factory #44

Member

Task 4d90a725-5a7c-4bee-bbe4-d036cfb69c5b. Presets for anthropic, openai, openrouter, ollama, and openai_compatible, plus llm.FromSettings. Migration 0004 allows openai and openrouter in ai_settings and ai_runs. Head b6e433cc98.

Task 4d90a725-5a7c-4bee-bbe4-d036cfb69c5b. Presets for anthropic, openai, openrouter, ollama, and openai_compatible, plus llm.FromSettings. Migration 0004 allows openai and openrouter in ai_settings and ai_runs. Head b6e433cc98a395f1b0e89b951ed847c402c8aeac.
dev_agent added 2 commits 2026-10-04 08:54:59 -04:00
internal/ai/llm/presets defines the anthropic, openai, openrouter, ollama
and openai_compatible presets (base URL, adapter, key policy, headers,
structured output modes and model quirks) and FromSettings, which turns
llm.Settings plus the decrypted key into a ready llm.Provider or a typed
configuration error from package llm.

Temperature is omitted for model ids matching ^o1 or ^o3, listed once in
TemperatureRejectingModels.

Maestro task: 4d90a725-5a7c-4bee-bbe4-d036cfb69c5b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Allow openai and openrouter AI providers in the schema
CI / ci (push) Successful in 1m32s
CI / ci (pull_request) Successful in 1m30s
b6e433cc98
0001 limited ai_settings.provider and ai_runs.provider to
openai_compatible, anthropic and ollama, so the openai and openrouter
presets could not be stored. Migration 0004 rebuilds both tables with the
wider CHECK, keeping the three existing values and every row.

ai_runs is referenced by suggestion_batches and week_plans, so it is
rebuilt by copying rows aside and recreating the table under its own name
with foreign keys deferred; the create-then-rename rebuild from 0003 leaves
the dropped table's references counted as violations at commit.

Tests cover upgrading a database with ai_settings, ai_runs and referencing
rows, and storing every preset provider in both tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dev_agent added 1 commit 2026-10-04 08:59:22 -04:00
Fix reasoning-model temperature quirk matching and validation
CI / ci (push) Successful in 1m38s
CI / ci (pull_request) Successful in 1m30s
cb93134f3e
- Omit temperature for OpenRouter's namespaced OpenAI reasoning models
  (openai/o1, openai/o1-mini, openai/o3-mini, openai/o1:online).
- Match o1/o3 only as the bare family name or with a "-" variant, so
  o123 and o3custom keep their temperature.
- Validate the caller's request before clearing temperature, so a
  negative temperature is still a validation error, not a sent request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dev_agent added 1 commit 2026-10-04 09:05:16 -04:00
Redact the API key from preset configuration and validation errors
CI / ci (push) Successful in 1m32s
CI / ci (pull_request) Successful in 1m30s
31322f239e
FromSettings errors and the configured provider's request-validation
errors now pass through a presets redactedError: its text has the key
removed with llm.Redact, it does not unwrap to the unredacted layers,
and Is still matches the llm sentinels. A key that equals a request
value (temperature -0.5) or a setting no longer appears in the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dev_agent added 1 commit 2026-10-04 09:09:23 -04:00
Reject API keys that are not valid header values at construction
Independent review Codex gpt-6-sol high: APPROVED (0 findings)
CI / ci (push) Successful in 1m30s
CI / ci (pull_request) Successful in 1m29s
08be8891da
FromSettings now fails with llm.ErrInvalidKey for a key with a control
character such as CR or LF, for every preset that sends a key, and
openai.New rejects such a key too, so neither defers the failure to the
first request. anthropic.New already rejected it. No error quotes the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
review_agent left a comment
Member

Independent review — Codex gpt-6-sol, reasoning high

Verdict: APPROVED
Reviewed SHA: 08be8891da9ea2201a414ce4b09e9a9c443af2bf

{
  "verdict": "APPROVED",
  "reviewed_sha": "08be8891da9ea2201a414ce4b09e9a9c443af2bf",
  "summary": "Presets, temperature handling, configuration errors, and migration meet the done-condition. Construction now rejects keys containing invalid header characters without exposing the key. gofmt, go vet, and go test -race -count=1 ./... passed.",
  "findings": []
}

Posted unaltered by review_agent. This is transport, not a second review.

## Independent review — Codex `gpt-6-sol`, reasoning high Verdict: **APPROVED** Reviewed SHA: `08be8891da9ea2201a414ce4b09e9a9c443af2bf` ```json { "verdict": "APPROVED", "reviewed_sha": "08be8891da9ea2201a414ce4b09e9a9c443af2bf", "summary": "Presets, temperature handling, configuration errors, and migration meet the done-condition. Construction now rejects keys containing invalid header characters without exposing the key. gofmt, go vet, and go test -race -count=1 ./... passed.", "findings": [] } ``` --- Posted unaltered by `review_agent`. This is transport, not a second review.
approver_agent merged commit 9ace3aba9f into feature/5dd6e253-cc9b-41f3-9091-bb834f7a373a-llm-provider-layer 2026-10-04 09:18:35 -04:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Maniacs_Mansion/MealQuest#44