Repository navigation
feat(agentic-server): GET /v1/models lists served models by id and name; /healthz reports liveness only - #2013
pyramation wants to merge 2 commits into
Conversation
…me; /healthz reports liveness only
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR introduces a models listing surface for the agentic server: upstream
Reviewed commit: 19c3565 |
…x strip; follow a paged listing
There was a problem hiding this comment.
Adds an OpenAI-compatible /v1/models listing endpoint to the agentic gateway, with provider-scoped model discovery, a model-list hint on unknown-model 404s, and updated tests/README.
Key findings
- 🟡 Slash ids matching a provider name are advertised bare but routed split — models.ts:55
| const routed = resolveProvider(options, id); | ||
| const bare = providers.length === 1 || providerName(routed) === providerName(provider); | ||
| const served = bare ? id : `${providerName(provider)}/${id}`; | ||
| if (seen.has(served)) return []; | ||
| seen.add(served); | ||
| return [{ id: served, name }]; | ||
| }); |
There was a problem hiding this comment.
🟡 bug · medium
Slash ids matching a provider name are advertised bare but routed split
A model id that itself contains / and whose first segment matches a provider name is advertised bare, yet a request with that id is split and relayed without its first segment. In listServedModels, resolveProvider(options, 'hosted/thing') resolves back to the same hosted provider, so bare is true and the listing shows hosted/thing (agentic/agentic-server/src/models.ts:55-56). But upstreamModel strips the prefix equal to providerName and relays only thing (agentic/agentic-server/src/transforms.ts:31-35), so the advertised id selects a nonexistent model on the upstream. Callers picking models from /v1/models fail on their first call with every run configured with such an id.
📋 Prompt for AI Agents
In agentic/agentic-server/src/models.ts around lines 54-61, fix the bare/prefix decision in listServedModels: if the upstream id contains '/' and its first segment matches a registered provider name or type (the same test resolveProvider's split at src/providers.ts:46-52 uses), advertise the prefixed form ${providerName(provider)}/${id} instead of the bare id, because upstreamModel (src/transforms.ts:29-36) will strip the matching prefix on the request path and relay the wrong model. Add a test where a provider named 'hosted' serves id 'hosted/thing' asserting the listing shows 'hosted/hosted/thing' and a chat request with that id reaches the upstream with model 'hosted/thing'.
There was a problem hiding this comment.
Devin Review found 2 findings. Devin automatically fixed all 2 findings.
Fixed by Devin (2)
- Listed model IDs lose upstream namespaces — An id is listed bare only if upstreamModel leaves it unchanged; otherwise it gets the provider prefix. Test added.
- Model discovery drops later Anthropic pages — The listing now follows has_more/last_id with after_id until the last page. Test added.
Summary
Gateway half of constructive-planning#2528: nothing listed the models a run can use, so a wrong
CODE_TASK_MODELwas only discovered when the run's first model call failed.GET /v1/modelsreturns{ object: 'list', data: [{ id, name }] }and nothing else. It requiresX-Database-Id, the same identity a chat/embedding call carries (400 without it)./v1/modelsforopenai/anthropic,/api/tagsforollama) with the gateway's key; caller headers are not forwarded.idis what to send asmodel: the bare upstream id whenresolveProviderwould route it to the provider that serves it, otherwisename/id.nameis the upstreamdisplay_name, else the id.owned_by, sizes) is returned. One caveat: aname/prefix is the registry name the operator chose, which defaults to the dialect; it appears only where a model cannot be addressed without it.502 { error: { message: 'the model list is unavailable' } }; the reason goes to the log only.404(how every dialect answers a model it does not serve) now ends withGET /v1/models lists the models this gateway serves.GET /healthznow returns{ status: 'ok' }only. It previously returned the first provider's type and base URL, and it is unauthenticated: in constructive-db a tenant workload reaches it through the node gateway's model lane, which forwards any path. This is a response-shape change for anything readingprovider/providerUrlfrom/healthz.GET /v1/providersis unchanged (operator endpoint). The constructive-db PR closes the lane to it instead.Tests:
__tests__/models.test.ts(written first, 6 failing before the change): identity required, id/name shape across three dialects including the prefixed case, no provider internals in the body, 502 without the upstream reason, the unknown-model hint, and/healthz.Not verified: against real OpenAI/Anthropic/Ollama listings (mock upstreams only).
Link to Devin session: https://app.devin.ai/sessions/cff8c5d8274c475db01e55ac47e7b519
Open in Devin Desktop: https://app.devin.ai/desktop/session/cff8c5d8274c475db01e55ac47e7b519?variant=devin
Requested by: @pyramation
🟢 Devin fixed all 2 findings · Follow Devin's work