Skip to content

fix(dmr): honor the models gateway when creating the client - #3875

Merged
Sayt-0 merged 1 commit into
docker:mainfrom
aboullaite:fix/dmr-honor-models-gateway
Aug 3, 2026
Merged

fix(dmr): honor the models gateway when creating the client#3875
Sayt-0 merged 1 commit into
docker:mainfrom
aboullaite:fix/dmr-honor-models-gateway

Conversation

@aboullaite

Copy link
Copy Markdown

Fixes the --models-gateway part of #3871.

Every other provider (openai, anthropic, gemini) routes through the configured models gateway, but the DMR provider ignored it: NewClient always probed for a local Model Runner via docker model status and failed with ErrNotInstalled in environments where the gateway is the only reachable path. The concrete case from the issue is a Docker Sandbox, where docker agent run --sandbox --models-gateway ... has already allowlisted the gateway in the sandbox proxy, yet the agent inside the sandbox refuses to start.

What changed

When a gateway is configured, NewClient now dials it directly as the OpenAI compatible endpoint (<gateway>/v1/), skipping endpoint discovery, auto pull and backend configuration, which all assume a local installation. The gateway branch follows the same if/else shape the sibling providers use and shares the existing construction tail. Gateway requests carry the standard request contract (X-Cagent-Forward set to the default DMR host URL, provider and model identity headers, gateway query parameters). DMR requires no auth, so the gateway is dialed with an empty API key, matching the direct path. dmrmodels.defaultHostURL is now exported as it doubles as the forward target.

One consideration deliberately left out: threading environment.Provider through to call VerifyDockerGatewayAuth/GatewayAuthToken. Those helpers no op for gateways outside the trusted Docker domains, and DMR is a local, credential free provider, so there is no real configuration today where they would fire. Happy to add the plumbing if you want parity with the other providers.

Validation

  1. go test ./pkg/model/provider/dmr/... passes, including a request contract test that sends a real SDK backed operation (CreateBatchEmbedding) through an httptest gateway and asserts the path, query parameters and X-Cagent-* headers, plus a broken docker CLI shim test proving no local discovery happens when a gateway is set.
  2. golangci-lint run pkg/model/provider/dmr/... reports 0 issues; go build ./... is clean.
  3. End to end: built for linux/arm64 and ran inside a Docker Sandbox microVM with --model dmr/ai/gemma4 --models-gateway http://host.docker.internal:12434/engines. The client connects through the sandbox proxy to the host's Model Runner and completes the task. The same invocation on the current release fails with "docker model runner is not available".

The self update 404 and the host CLI's inspect exec timeout from #3871 are not addressable from this repo (release pipeline and sbx side respectively), so this PR covers only the gateway half.

@aboullaite
aboullaite requested a review from a team as a code owner July 31, 2026 08:45
@Sayt-0 Sayt-0 self-assigned this Jul 31, 2026
@aheritier aheritier added area/models LLM model integrations and model providers area/providers/docker-model-runner Docker Model Runner (DMR) local inference kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 31, 2026

@Sayt-0 Sayt-0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good. Thank you !

@Sayt-0

Sayt-0 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Can you sign your commits ?

@aboullaite
aboullaite force-pushed the fix/dmr-honor-models-gateway branch from 7117402 to 717e657 Compare July 31, 2026 15:32
@aboullaite

aboullaite commented Jul 31, 2026

Copy link
Copy Markdown
Author

Can you sign your commits ?

Yes sorry for that. Done ✅

@aboullaite
aboullaite requested a review from Sayt-0 July 31, 2026 16:22
@aheritier
aheritier requested a review from docker-agent August 1, 2026 20:50
@aheritier

Copy link
Copy Markdown
Collaborator

/review

@Sayt-0

Sayt-0 commented Aug 3, 2026

Copy link
Copy Markdown
Member

hello @aboullaite It looks like they still haven't been signed.

Every other provider routes through --models-gateway when one is set, but
the DMR provider ignored it: NewClient always probed for a local Model
Runner via docker model status and failed with ErrNotInstalled in
environments where the gateway is the only reachable path, e.g. inside a
Docker Sandbox where the host CLI has already allowlisted the gateway in
the sandbox proxy.

When a gateway is configured, dial it directly as the OpenAI-compatible
endpoint and skip local endpoint discovery, auto-pull and backend
configuration, which all assume a local installation.

Fixes docker#3871

Signed-off-by: Mohammed Aboullaite <mohammed@aboullaite.me>
@aboullaite
aboullaite force-pushed the fix/dmr-honor-models-gateway branch from 717e657 to f222358 Compare August 3, 2026 09:47
@aboullaite

Copy link
Copy Markdown
Author

Pretty sure its fixed now @Sayt-0. At least that's what the UI says

@Sayt-0
Sayt-0 merged commit 7c5b33b into docker:main Aug 3, 2026
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/models LLM model integrations and model providers area/providers/docker-model-runner Docker Model Runner (DMR) local inference kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants