Ollama native adapter #41

Member

Task: 51289131-5abf-48c3-b553-7e3809c09076 Ollama native adapter.

What changed: internal/ai/llm/ollama implements Provider for POST {base}/api/chat (stream false, schema in format, temperature in options) and GET {base}/api/tags. No auth header. Unreachable host names the base. Model-not-found names the model. Redirects are not followed.

Done-condition: httptest contract tests cover success, schema output, model missing, and unreachable host. Developer reports gofmt, go vet, go test -race, and CGO_ENABLED=0 go build passed.

Base: feature/5dd6e253-cc9b-41f3-9091-bb834f7a373a-llm-provider-layer at 15886f2c55.

Task: 51289131-5abf-48c3-b553-7e3809c09076 Ollama native adapter. What changed: internal/ai/llm/ollama implements Provider for POST {base}/api/chat (stream false, schema in format, temperature in options) and GET {base}/api/tags. No auth header. Unreachable host names the base. Model-not-found names the model. Redirects are not followed. Done-condition: httptest contract tests cover success, schema output, model missing, and unreachable host. Developer reports gofmt, go vet, go test -race, and CGO_ENABLED=0 go build passed. Base: feature/5dd6e253-cc9b-41f3-9091-bb834f7a373a-llm-provider-layer at 15886f2c55e27f391744bfad1c5eba742cebb3da.
dev_agent added 1 commit 2026-10-04 08:34:03 -04:00
Ollama native adapter
CI / ci (push) Successful in 1m31s
Independent review Codex gpt-6-sol high: CHANGES_REQUIRED (1 medium)
CI / ci (pull_request) Successful in 1m28s
d5fe7548c5
internal/ai/llm/ollama implements llm.Provider over plain net/http:
POST {base}/api/chat with "stream": false, the request schema in
"format", and options.temperature / options.num_predict only when the
request sets them; GET {base}/api/tags for ListModels and Verify. No
Authorization header is sent and redirects are not followed.

Usage comes from prompt_eval_count/eval_count. A schema reply that is
not a JSON object is ErrBadOutput. HTTP 404 on /api/chat is an
ErrProvider naming the configured model, without quoting the body.
Refused connections and timeouts match ErrTimeout and say
"Ollama not reachable at {base}"; a cancelled context stays
context.Canceled. The base URL is required, absolute http or https
(LAN hosts allowed), and may not carry userinfo, a query or a fragment.

Contract tests replay sanitized fixtures adapted from Ollama's public
API docs against httptest servers: success, schema output, model
missing and unreachable host.

Maestro task: 51289131-5abf-48c3-b553-7e3809c09076

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: CHANGES_REQUIRED
Reviewed SHA: d5fe7548c5c2f3cc799e4fde23da363f0bdbf6b9

{
  "verdict": "CHANGES_REQUIRED",
  "reviewed_sha": "d5fe7548c5c2f3cc799e4fde23da363f0bdbf6b9",
  "summary": "The requested endpoints, payload fields, usage mapping, no-auth behavior, redirect handling, and contract tests are present. gofmt, go vet, and go test -race -count=1 ./... passed. One error path misdiagnoses a generic 404.",
  "findings": [
    {
      "id": "F1",
      "severity": "medium",
      "location": "internal/ai/llm/ollama/ollama.go:140",
      "failure_case": "If a configured proxy returns 404 because /api/chat is unavailable, Generate reports that the configured model was not found.",
      "evidence": "The code treats every HTTP 404 from Generate as a missing model and discards the response body without checking Ollama's error message.",
      "suggested_correction": "Check the 404 error payload before labeling it model-not-found; otherwise return the original ProviderError. Add a test for a 404 unrelated to the model."
    }
  ]
}

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

## Independent review — Codex `gpt-6-sol`, reasoning high Verdict: **CHANGES_REQUIRED** Reviewed SHA: `d5fe7548c5c2f3cc799e4fde23da363f0bdbf6b9` ```json { "verdict": "CHANGES_REQUIRED", "reviewed_sha": "d5fe7548c5c2f3cc799e4fde23da363f0bdbf6b9", "summary": "The requested endpoints, payload fields, usage mapping, no-auth behavior, redirect handling, and contract tests are present. gofmt, go vet, and go test -race -count=1 ./... passed. One error path misdiagnoses a generic 404.", "findings": [ { "id": "F1", "severity": "medium", "location": "internal/ai/llm/ollama/ollama.go:140", "failure_case": "If a configured proxy returns 404 because /api/chat is unavailable, Generate reports that the configured model was not found.", "evidence": "The code treats every HTTP 404 from Generate as a missing model and discards the response body without checking Ollama's error message.", "suggested_correction": "Check the 404 error payload before labeling it model-not-found; otherwise return the original ProviderError. Add a test for a 404 unrelated to the model." } ] } ``` --- Posted unaltered by `review_agent`. This is transport, not a second review.
dev_agent added 1 commit 2026-10-04 08:37:47 -04:00
Ollama: only treat a 404 as model-not-found when the body says so
Independent review Codex gpt-6-sol high: APPROVED (0 findings)
CI / ci (push) Successful in 1m31s
CI / ci (pull_request) Successful in 1m29s
1d4c0bd0e1
A 404 from a proxy without /api/chat, or any other 404 error, was
reported as the configured model being missing. Generate now checks the
{"error": ...} payload for Ollama's model-not-found message naming the
configured model (double- or single-quoted); any other 404 stays a
ProviderError with its redacted body excerpt.

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: 1d4c0bd0e10b59c58af0155dcd2d4e21c43c8b16

{
  "verdict": "APPROVED",
  "reviewed_sha": "1d4c0bd0e10b59c58af0155dcd2d4e21c43c8b16",
  "summary": "The adapter meets the specified API, error, URL, and redirect requirements. Contract tests cover the requested cases. gofmt -l ., 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: `1d4c0bd0e10b59c58af0155dcd2d4e21c43c8b16` ```json { "verdict": "APPROVED", "reviewed_sha": "1d4c0bd0e10b59c58af0155dcd2d4e21c43c8b16", "summary": "The adapter meets the specified API, error, URL, and redirect requirements. Contract tests cover the requested cases. gofmt -l ., 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 32ab0c0b6d into feature/5dd6e253-cc9b-41f3-9091-bb834f7a373a-llm-provider-layer 2026-10-04 08:47:05 -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#41