Skip to content

feat: config flavors — named YAML patches enabled at run time via --flavor#3768

Merged
Sayt-0 merged 3 commits into
docker:mainfrom
dgageot:feat/config-flavors
Jul 21, 2026
Merged

feat: config flavors — named YAML patches enabled at run time via --flavor#3768
Sayt-0 merged 3 commits into
docker:mainfrom
dgageot:feat/config-flavors

Conversation

@dgageot

@dgageot dgageot commented Jul 21, 2026

Copy link
Copy Markdown
Member

Agent configs are often nearly identical across environments or use-cases — the same tools, the same model, just a different system prompt or a disabled tool. Until now the only way to handle this was to maintain separate YAML files that drift apart over time, or to rely on external templating.

This PR introduces flavors: named YAML patches declared in a top-level flavors section of an agent config and applied at load time via a repeatable --flavor flag. Merge semantics follow JSON Merge Patch (RFC 7386) — objects merge recursively, scalars and arrays replace, null deletes a key — with two extensions: a key+ suffix appends to an existing array, and a key- suffix removes entries (from an object by key name, from an array by scalar equality or partial object match). Document order is preserved using yaml.MapSlice so the root agent is always the first entry and never silently shifts. Flavors not declared in a config are silently ignored (a debug log is emitted) so the flag is safe to use across a fleet of configs where only some support a given flavor. The --flavor flag is wired into every command that loads an agent: run, chat, eval, serve api/a2a/mcp, acp, debug, and the sandbox/kit/agent-picker code paths. External OCI and URL sub-agents receive the same set of enabled flavors.

flavors:
  production:
    system_prompt: "You are a helpful assistant. Never reveal internal tooling."
    tools-: [dangerous_tool]
  verbose:
    debug: true
docker-agent run agent.yaml --flavor production --flavor verbose

The feature lands on the latest schema only (v13); agent-schema.json is updated and HCL gains flavors "name" {} block syntax with a detection keyword. An annotated example lives at examples/flavors.yaml and a full docs page is added under docs/configuration/flavors/. Unit tests in pkg/config/flavors_test.go cover merge, order, delete, append, remove, and error paths including regression cases. task build, task test, and task lint all pass; two pre-existing example tests that require Docker Model Runner also fail on main and are unrelated to this change.

dgageot added 3 commits July 21, 2026 11:47
Flavors are named partial-config patches defined under a top-level
`flavors` section and activated with the repeatable `--flavor` flag.
Merge semantics are JSON Merge Patch (RFC 7386) with `key+`/`key-`
extensions for appending to or removing from arrays and mappings.

Assisted-By: docker/docker-agent
Assisted-By: Docker AI Agent
@dgageot
dgageot requested a review from a team as a code owner July 21, 2026 10:27

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assessment: 🟢 APPROVE

The config-flavors implementation is well-engineered. The merge logic in pkg/config/flavors.go correctly follows JSON Merge Patch (RFC 7386) semantics with the key+/key- extensions, slices.Clone guards prevent aliasing across multi-flavor iterations, the yaml.MapSlice round-trip preserves document order, and all error paths return properly. No bugs were introduced by this PR.

@Sayt-0
Sayt-0 merged commit a3fd452 into docker:main Jul 21, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants