Commit Graph
62 Commits
Author SHA1 Message Date
github-actions[bot] 64c6d9b1f2 chore: refresh models.dev snapshot (+129 -67 ~322) 2026-09-07 06:23:31 +00:00
Arnaud Héritier 99e92384e0 feat(modelsdev): add EmbeddedSnapshot and Fetch helpers
EmbeddedSnapshot exposes the build-time snapshot.json catalog as a
read-only singleton, and Fetch hits the live models.dev API directly,
surfacing a network failure instead of silently degrading to a cache
or the embedded snapshot.

Together with the existing NewDatabaseStore these let callers build a
Store that is either provably hermetic or provably live, instead of
Store's usual best-effort network-then-cache-then-snapshot fallback.

Groundwork for #4134.
2026-09-03 14:49:49 +00:00
github-actions[bot] b97924c00b chore: refresh models.dev snapshot (+79 -75 ~196) 2026-09-02 21:40:35 +00:00
dgageot c5740774ad chore: refresh embedded models.dev snapshot 2026-08-31 13:05:08 +02:00
Arnaud Héritier 8b08b30b19 fix: replace removed deepseek-chat with deepseek-v4-pro
models.dev removed deepseek-chat and deepseek-reasoner from the deepseek
provider. Update all references to use deepseek-v4-pro (the current
flagship model) and refresh the embedded snapshot to match the live
catalog.

Fixes: TestParseExamples/../../examples/deepseek.yaml
2026-08-25 12:47:56 +00:00
dgageot 6d8e7bd825 chore: refresh embedded models.dev snapshot 2026-08-24 09:48:19 +00:00
dgageot 80b7669f37 chore: refresh embedded models.dev snapshot 2026-08-17 10:43:05 +02:00
Arnaud Héritier 95f3d1aba9 fix: update gopher examples to gemini-3.1-pro-preview
gemini-3-pro-preview was removed from the live models.dev catalog,
causing TestParseExamples to fail on both Linux and Windows CI runners
with: 'model "gemini-3-pro-preview" not found in provider "google"'.

Switch the reviewer agent in examples/gopher.{yaml,hcl} to
gemini-3.1-pro-preview, its direct successor in the catalog.

Also regenerate pkg/modelsdev/snapshot.json so the baked-in fallback
snapshot stays in sync with the current live catalog.
2026-08-10 14:59:42 +00:00
dgageot f0336d4103 chore: refresh embedded models.dev snapshot 2026-08-04 11:35:45 +02:00
dgageot 6f16cd7fd8 chore: refresh embedded models.dev snapshot 2026-07-27 10:04:20 +02:00
Arnaud Héritier 0d3a5c6fcf chore: refresh models.dev snapshot to 2026-07-24
Runs go generate ./pkg/modelsdev/... to pull the latest catalog from
models.dev. The only change to the anthropic provider is the addition of
claude-opus-5 (family claude-opus, 1M context, 128k output, $5/$25
pricing, text+image+pdf input). Five new niche providers are also added
as part of the wholesale refresh.

Adds TestEmbeddedSnapshotIncludesClaudeOpus5 to guard against a future
stale snapshot silently dropping the new model, mirroring the existing
GPT-5.6 regression test.
2026-07-24 19:41:40 +00:00
David Gageot e933dea557 refactor: move Desktop proxy transport to leaf package pkg/desktop/transport
pkg/modelsdev, pkg/gateway and pkg/httpclient only needed
remote.NewTransport, but importing pkg/remote drags the whole OCI
registry stack (go-containerregistry, docker/cli, credential helpers)
into every consumer of pkg/model/provider, pkg/session and pkg/agent.

Move the transport (and its proxy fallback logic) to
pkg/desktop/transport, which only depends on pkg/desktop and
pkg/memoize. remote.NewTransport is kept as a deprecated forwarder so
existing integrations keep compiling and behaving identically.

pkg/model/provider now pulls 24 external modules instead of 31.
2026-07-21 22:32:10 +02:00
dgageot 55d09e905b chore: refresh embedded models.dev snapshot
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-07-20 09:55:51 +02:00
Arnaud Héritier 99a3c80532 feat: optimize GPT-5.6 defaults and reasoning
Make GPT-5.6 easier and more efficient to use by updating provider
defaults, model-specific reasoning levels, built-in agents, examples,
and the embedded models.dev catalog.

References:
- https://developers.openai.com/api/docs/guides/latest-model
- https://developers.openai.com/api/docs/guides/reasoning
- https://developers.openai.com/api/docs/models/gpt-5.6
- https://developers.openai.com/api/docs/models/gpt-5.6-sol
- https://developers.openai.com/api/docs/models/gpt-5.6-terra
- https://developers.openai.com/api/docs/models/gpt-5.6-luna
- https://developers.openai.com/codex/models
- https://models.dev/models/openai/gpt-5.6-sol
- https://models.dev/models/openai/gpt-5.6-terra
- https://models.dev/models/openai/gpt-5.6-luna
2026-07-10 11:38:14 +02:00
David Gageot a0738d9d4f fix: make model picker refresh async and non-blocking
Prevent picker stacking on ctrl+r, preserve the search query across
refreshes, and avoid holding the store mutex during network I/O.
Coalesce refreshes with a dedicated refreshMu, improve error handling
for in-memory and not-modified edge cases, and add covering tests.

Assisted-By: Claude (Anthropic)
2026-07-09 20:46:49 +02:00
David Gageot bf7f65ddba feat: add Ctrl+R force-refresh to the model picker
Pressing Ctrl+R in the model picker bypasses the models.dev cache TTL,
re-fetches the catalog, and reopens the picker with updated choices.

Assisted-By: docker/docker-agent
2026-07-09 20:32:52 +02:00
David Gageot ddbdb726fc fix: guard nil fetch funcs and fix misplaced godoc in store and catalog 2026-06-30 16:13:43 +02:00
David Gageot 4914d81fca refactor: replace package-level globals with dependency injection for parallel-safe tests 2026-06-30 14:44:24 +02:00
David Gageot febcdb9e5e fix: adapt context call sites after rebase on main
Restore the context.Context parameter on app.New (the rebase auto-merge
silently dropped it while keeping the ctx-using body) and thread the
caller's context through all call sites, including tests.

Annotate the build-time root context in the new
pkg/modelsdev/internal/gen snapshot generator (landed from main) for the
ContextConnectivity cop: it is a standalone main with no parent context.
2026-06-29 10:24:18 +02:00
David Gageot 2d157247ba feat(modelsdev): embed models.dev catalog snapshot as binary fallback
Adds a build-time snapshot of the models.dev catalog baked into the
binary via go:embed, used as last-resort fallback when the cache and
live fetch are both unavailable. A generator (pkg/modelsdev/internal/gen)
refreshes the snapshot; task update-models and a weekly GitHub Actions
workflow keep it current.

The fallback snapshot is not memoized on transient fetch failure, so the
Store retries the fetch once the network recovers. Context windows for
Fable and Opus 4.6-4.8 now come from the embedded snapshot (always
available, even offline); the Anthropic client falls back to the flat
200k floor only when no catalogue entry exists. A warning is logged when
the embedded snapshot fails to parse so a bad build artifact is
discoverable.

The snapshot freshness check is opt-in: TestSnapshotDateParses always
runs (time-independent) while TestSnapshotDateIsFresh is skipped unless
CHECK_MODELS_SNAPSHOT_FRESHNESS is set. A 'task check-models-fresh'
target provides the CI backstop.

Assisted-By: Claude
2026-06-27 16:00:08 +02:00
Sayt-0 7acef6c28a fix(modelsdev): skip models.dev fetch for custom providers (#3165)
Resolving a model for a user-defined custom provider (a name that is not a
built-in or alias, e.g. mistral_gateway) loaded the full models.dev catalog,
which performs a blocking 30s GET to https://models.dev/api.json. In
internet-restricted environments this hung the request loop (loop.go) and
session compaction on every turn, making a self-contained custom-provider
config (base_url + token_key) unusable.

modelsdev.Store gains WithKnownProvider: a provider the predicate rejects is
resolved from the cache only and never triggers an outbound fetch (a missing
cache yields an empty catalog, so the lookup returns a clean "provider not
found"). The cache-only snapshot is memoized separately from the authoritative
catalog, keeping the per-turn hot path cheap (no repeated catalog re-parse)
without ever satisfying a fetch-eligible lookup for a known provider.

The runtime's default store (lazyModelStore) and RuntimeConfig.ModelsDevStore()
are wired with provider.IsKnownProvider, so only catalog providers (built-ins
and aliases) can reach the network; custom providers resolve locally and the
agent stays usable air-gapped.
2026-06-19 11:18:14 +02:00
David Gageot 6d7fd025b2 refactor: derive ModelsDevAPIURL from APIHost to prevent drift 2026-06-09 19:54:54 +02:00
David Gageot 397bc99032 Allow models.dev in sandbox proxy for catalog metadata resolution 2026-06-09 19:52:55 +02:00
David Gageot 9386e47f3a refactor: introduce modelsdev.ID for provider-qualified model identity 2026-05-12 12:17:32 +02:00
Djordje Lukic 0139bfa954 feat(modelsdev): add WithCache option to override cache file path
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2026-05-11 16:53:20 +02:00
David Gageot 2b403c830c refactor: centralize modelsdev.Store creation via RuntimeConfig
Rebase PR #2746 on top of origin/main, resolving conflicts with PR #2738.

Key changes:
- Add RuntimeConfig.ModelsDevStore() lazy accessor with sync.Once caching
- Add options.WithModelsDevStore to thread the store through provider options
- Merge modelcaps.Load and LoadFromStore into a single Load(store, modelID)
- Remove per-client modelsStore fields from all provider clients (anthropic,
  openai, gemini, bedrock, dmr) — they now get the store via ModelOptions
- Convert modelsdev.NewStore from sync.OnceValues singleton to a plain
  function since RuntimeConfig handles the caching
- Wire RuntimeConfig.ModelsDevStore through teamloader, cmd/root/models,
  and rag/strategy/embedding
- Update detectCachingSupport (bedrock) to accept store parameter
- Rename oaistream ConvertMessagesFromStore/ConvertMultiContentFromStore
  to ConvertMessages/ConvertMultiContent
- Keep c.ID() (qualified provider/model) from PR #2738 at all call sites
2026-05-11 16:21:48 +02:00
David Gageot 54c71e08d5 ci: enable gosec for file-permission rules (G301/G302/G306)
Scope gosec to G301 (dir perms), G302 (chmod perms), and G306 (WriteFile
perms) so future regressions of the project's 0o700/0o600 convention
for on-disk private state are caught in CI.

Real fix uncovered by the new check:

- pkg/modelsdev/store.go: tighten cache directory to 0o700 and cache
  file to 0o600 to match every sibling cache (pkg/cache, pkg/content,
  pkg/history, pkg/userconfig, etc.). This was an outlier.

Legitimate exceptions silenced inline with a one-line reason:

- pkg/snapshot/snapshot.go: 0o755/0o644 mirror what 'git init' itself
  writes for .git and .git/info/exclude.
- pkg/toolinstall/{installer,archive}.go: installed/extracted binaries
  need +x; their parent directories need traversal/exec.
- pkg/app/export/html.go: exported HTML is meant to be world-readable.
- pkg/gateway/catalog.go: MCP catalog is shared with other docker MCP
  gateway processes.
- pkg/server/listen.go: unix-socket access is gated by the socket file's
  own permissions, not by the parent directory.
- pkg/tools/builtin/lsp/lsp.go: file pre-exists; os.WriteFile only
  applies the mode argument on creation.
- cmd/root/pull.go, cmd/root/root.go: pulled agent yaml and the empty
  first-run marker file are intended to be readable.

Test files are excluded from gosec (test fixtures legitimately use
0o755 and chmod for permission-failure scenarios).

Pre-existing //nolint:gosec directives targeting G203/G204 are removed
in this commit because they are flagged as 'unused' under the narrow
scope; they will be re-added when gosec is broadened in a follow-up.
2026-05-09 15:36:17 +02:00
David Gageot 3451ce9017 refactor: centralize model-specific behavior in pkg/modelinfo
Move all the scattered name-pattern checks (Responses API selection,
o-series defaults, adaptive thinking for Opus 4.6+, Gemini 3 thinking
levels, Bedrock-Claude detection) into a single capability-named
package, and wire it through the existing provider clients.
2026-05-07 10:04:52 +02:00
Tomas Dabašinskas 5f0a5796cd refactor(logging): pass context to all slog calls for correlation
Replace all slog.Debug/Info/Warn/Error calls with their *Context variants (slog.DebugContext, slog.InfoContext, etc.) throughout the codebase. This enables log correlation and tracing by threading context through all logging statements.

Key changes:
- Update all logging calls in runtime, agent, provider, and tool packages
- Pass context.TODO() in cases where no request context exists (e.g., config validation, debug commands)
- Update agent.Model() signature to accept context parameter for log correlation
- Maintain existing log levels and messages; only add context parameter

This change improves observability by allowing logs to be correlated with traces and requests, making debugging distributed operations easier.
2026-05-06 16:42:35 +03:00
Guillaume Tardif 32ebaf59ef Use Desktop proxy for all HTTP downloads
Updates fetch, openapi, api tools, gateway catalog, skills cache, and models.dev store to use remote.NewTransport for Desktop proxy support when downloading external content.

Assisted-By: docker-agent
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
2026-03-23 10:32:20 +01:00
David Gageot 73c7ebdd12 Simplify modelsdev store: remove dead fields, unexport GetProvider, inline helpers
Assisted-By: docker-agent
2026-03-19 19:16:39 +01:00
David Gageot faea562de9 Simplify NewStore by using sync.OnceValues directly
Assisted-By: docker-agent
2026-03-19 19:11:16 +01:00
David Gageot 311a7e1159 Remove unused fields from modelsdev Provider and Model types
Assisted-By: docker-agent
2026-03-19 19:10:08 +01:00
David Gageot 4f347d87f4 Remove unused ModelSupportsReasoning function
Assisted-By: docker-agent
2026-03-19 19:03:35 +01:00
David Gageot 644522e9c8 modelsdev: singleton Store with ETag-based conditional refresh
Make modelsdev.Store a process-wide singleton via sync.OnceValues so the
models.dev database is loaded at most once and shared across all callers
(teamloader, runtime, bedrock, embedding, config tests).

Key changes:
- NewStore() returns the same *Store instance for the entire process
- Add ETag support: store the ETag from models.dev responses and send
  If-None-Match on refresh; a 304 Not Modified skips the download
- Switch from json.Decoder to ReadFile/ReadAll + json.Unmarshal to
  avoid the decoder's intermediate buffering overhead
- Hoist store creation out of per-model loops in teamloader to make
  the singleton intent explicit and handle errors gracefully
- Persist ETag in the cache file for reuse across process restarts

This eliminates ~50-60MB of redundant heap allocations per run (the 3MB
JSON was being parsed into ~66MB of Go objects up to 6 times).

Assisted-By: docker-agent
2026-03-16 21:44:36 +01:00
Djordje Lukic 753dffeafa Thread context.Context through modelsdev store API
Replace the lazy-loaded closure-based Store with a simple struct
that holds a cache file path and loads the database on first
GetDatabase call. Pass caller-provided context to the HTTP request
in fetchFromAPI instead of using context.Background().

NewStore() remains context-free (no I/O). All Store methods
(GetDatabase, GetProvider, GetModel, ResolveModelAlias) and
ModelSupportsReasoning accept context for the network call.
Updated all callsites, using context.Background() only in TUI
callbacks where no caller context is available.

Assisted-By: cagent
2026-02-16 11:31:20 +01:00
David Gageot 25f263f58c Fix Model selection
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-16 10:19:45 +01:00
David Gageot 6efaee319b Faster fetch
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-13 17:58:50 +01:00
David Gageot e3eb7133c9 Don't pass unused context
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-13 17:56:13 +01:00
David Gageot f9ec911486 Remove unused code
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-13 17:47:24 +01:00
David Gageot eadb6c2609 Simpler Models.dev Store
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-13 17:45:00 +01:00
David Gageot 793b120373 Make it easier to mock model providers
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-13 17:32:22 +01:00
David Gageot fca607177b Remove fake models.dev
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-13 16:14:48 +01:00
David Gageot 893e65bc97 Bump Go to 1.26.0
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-02-12 07:03:07 +01:00
krissetto 434ea92b2f Disable /think in the TUI when using non-reasoning models
Signed-off-by: krissetto <chrisjpetito@gmail.com>
2026-01-19 00:02:16 +01:00
Christopher Petito 61a295fd81 Enable selection and autocompletion of models in /model dialog
Only models from providers that the user has api keys/credentials for will show up

Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2026-01-16 20:52:08 +01:00
Christopher Petito 7b2f50aaeb Check for known region/inference profile prefixes on bedrock models
This is more reliable and requires less maintenance compared to checking for a valid provider prefix intstead

Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2026-01-12 18:00:33 +01:00
Christopher Petito c2240b15d3 Fix token usage and cost tracking in amazon-bedrock provider
Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2026-01-12 11:07:19 +01:00
David Gageot 21e2e4d5aa Be better at printing the pinned model names
Signed-off-by: David Gageot <david.gageot@docker.com>
2026-01-07 11:47:18 +01:00
David Gageot 762aff88c8 Misc optimizations to make cagent run start faster
Signed-off-by: David Gageot <david.gageot@docker.com>
2025-12-30 14:09:59 +01:00