Repository navigation
feat(modelsdev): add an offline switch for the models.dev catalog download - #4768
3431481073 wants to merge 2 commits into
Conversation
|
👋 Some commits in this PR are not signed and verified by GitHub. Please sign your commits with a GPG or SSH key registered in your GitHub account, then force-push. Commits that are not verified: See GitHub\x27s guide on signing commits for setup instructions. I\x27ve added |
8269e6d to
e22d269
Compare
|
Signed the commit with an SSH signing key and folded in the lint fix ( The new |
aheritier
left a comment
There was a problem hiding this comment.
Reviewed the diff and tests against #4714 and the background in #3165. See inline comment.
CI: verified green for e22d269. The previously missing ci / gate is now present and successful, with all seven dependencies successful; docs and CodeQL also passed. The Linux CI log confirms the modelsdev tests passed. Local tests were not run because this checkout is at a different commit and Go is unavailable.
Issue context: complete accessible descriptions and comments retrieved for #4714 and #3165, along with all PR comments, reviews, and threads. No Jira references found. The PR is not draft and has no merge conflicts; GitHub reports review required.
| fetch = fetchFromAPI | ||
| } | ||
|
|
||
| offline := offlineFromEnv() |
There was a problem hiding this comment.
[blocking] Forward the opt-out variables into sandbox runs (confidence: high).
The failing case is DOCKER_AGENT_MODELS_DEV=off docker-agent run --sandbox agent.yaml with a normal built-in-provider config and a cold guest cache; DOCKER_AGENT_OFFLINE=1 has the same problem. This constructor reads the guest process environment, but cmd/root/sandbox.go:253-259 forwards only gathered credentials and the gateway setting. pkg/sandbox/sandbox.go:329-337 gathers model/evaluator/tool credentials, not either new variable. BuildExecCmd puts the host environment on the sandbox CLI process, but only its explicit -e arguments populate the guest environment. Consequently the guest constructs an online Store and can download the catalog despite the opt-out; allowSandboxHosts also still permits models.dev.
Forward both variables explicitly through the sandbox exec environment and add a regression test covering each switch across this boundary.
Add DOCKER_AGENT_MODELS_DEV=off and DOCKER_AGENT_OFFLINE=1 to make catalog lookups resolve from the on-disk cache or the embedded build-time snapshot without contacting models.dev. The default behaviour is unchanged. Refs docker#4714 Signed-off-by: xby <3431481073@qq.com>
The guest builds its own catalog Store from its process environment, and only explicit -e values cross the sandbox boundary. Forward DOCKER_AGENT_MODELS_DEV and DOCKER_AGENT_OFFLINE like the gateway, and stop allowlisting models.dev in the sandbox proxy when the catalog is offline. Adds regression tests for both switches at the sandbox boundary, an empty guest cache falling back to the embedded snapshot, and the egress allowlist. Refs docker#4714 Signed-off-by: xby <3431481073@qq.com>
e22d269 to
c942f23
Compare
|
Addressed the sandbox forwarding in
Could you take another look? |
|
Both commits are SSH-signed and GitHub-verified. CI is action_required for the fork workflow; could you approve the runs when convenient? |
aheritier
left a comment
There was a problem hiding this comment.
Reviewed all seven changed files against #4714 and the background in #3165, including cache/embedded fallback, refresh rejection, environment parsing, and sandbox forwarding. See inline comment.
CI: verified green for c942f23, including gate, lint, Linux/Windows tests, docs, and CodeQL. The Linux test log confirms cmd/root and pkg/modelsdev passed. Local tests were not run because the checkout is at a different commit.
Issue context: complete accessible descriptions and comments retrieved for #4714 and #3165, along with all PR comments, reviews, and thread state. No Jira references found. The PR is not draft and has no merge conflicts; GitHub reports changes requested.
Prior threads: #4432766721 — partially addressed for local sandboxes; the same forwarding defect remains on the cloud path. The thread is unresolved and outdated, so the inline comment cites it at a current changed line.
| // The guest builds its own catalog Store from its process environment, and | ||
| // only explicit -e values cross the sandbox boundary. Forward the offline | ||
| // switches explicitly for the same reason as the gateway. | ||
| offlineFlags, offlineVars := offlineSandboxEnv(os.Getenv) |
There was a problem hiding this comment.
[blocking] Forward the offline switches through the cloud sandbox path too (confidence: high).
The local sandbox case from #4432766721 is fixed, but DOCKER_AGENT_MODELS_DEV=off docker-agent run --cloud --exec --model openai/gpt-5.6 default "hello" still loses the switch; DOCKER_AGENT_OFFLINE=1 has the same problem. runInSandbox returns into runInCloudSandbox at lines 122–123, before reaching this forwarding block. In cmd/root/sandbox_cloud.go:119–120, the cloud exec environment contains only SANDBOX_VM_ID and tracing values. pkg/sandbox/sandbox.go:263–289 forwards only the explicit exec environment flags into the guest, not the host CLI's entire environment. Consequently the guest's NewStore sees neither switch and, with a cold cache, attempts the catalog download instead of directly using the embedded snapshot. If cloud policy permits models.dev, the download succeeds despite the opt-out; otherwise it still makes the prohibited attempt.
Apply the forwarding helper to the cloud exec path as well, and add a regression test for each switch through that path. This would complete the earlier finding rather than leaving one supported sandbox mode outside the documented guarantee.
Summary
docker-agent rundownloads the models.dev catalog on first use and caches it for 24 hours. Unlike telemetry, self-update, and tool auto-install, this outbound call had no opt-out, which is a problem for air-gapped installs, strict egress policies, and sandboxed runtimes that allocate a fresh HOME per session.This adds two opt-out environment variables:
DOCKER_AGENT_MODELS_DEV=off(alsofalse,0,no)DOCKER_AGENT_OFFLINE=1(alsotrue,yes,on)When either is set,
Store.getDatabasebehaves asallowFetch=false: lookups resolve from the on-disk cache (including a stale one) and otherwise from the snapshot embedded at build time, with no request to models.dev. Default behavior is unchanged. A forced model-picker refresh is rejected in offline mode rather than silently going to the network.Fixes #4714
Changes
WithOffline(bool)store option and readDOCKER_AGENT_MODELS_DEV/DOCKER_AGENT_OFFLINEinNewStore; an explicit option overrides the environment.allowFetch=falseingetDatabasewhen offline, reusing the existing cache-or-embedded fallback.Refreshagainst network access in offline mode.Testing
go test ./pkg/modelsdev/... -count=1 -vgo vet ./pkg/modelsdev/... ./pkg/config/... ./pkg/runtime/...go test ./pkg/config/... ./pkg/runtime/... -count=1task testandtask lintwere not run becausetaskandgolangci-lintare not installed in this environment; targeted tests andgo vetpass.Notes
modelsdev.Fetchremains an explicit live-fetch API (used by an examples test, not bydocker-agent run) and is intentionally unaffected by the Store-level switch.