Support HCL as an alternative agent config format#2598
Open
dgageot wants to merge 6 commits intodocker:mainfrom
Open
Support HCL as an alternative agent config format#2598dgageot wants to merge 6 commits intodocker:mainfrom
dgageot wants to merge 6 commits intodocker:mainfrom
Conversation
gtardif
previously approved these changes
Apr 30, 2026
|
❌ PR Review Failed — The review agent encountered an error and could not complete the review. View logs. |
f4973f0 to
4648ae3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds HCL as an alternative authoring format for agent configuration files,
alongside YAML. HCL documents are converted to YAML at load time, so the
existing schema, version dispatch, and migration chain are reused unchanged.
What it looks like
Conventions:
agents,models,providers,mcps,rag) arewritten as labeled blocks:
agent "root" { … }↔agents.root: { … }.command "name" { … }↔commands.name: { … }.typefield:toolset "mcp" { … }↔toolsets: [{ type: mcp, … }].\${…},any literal
\${…}in instructions must be escaped as\$\${…}.See
examples/pirate.hclandexamples/gopher.hcl— both produceconfigurations byte-identical to their
.yamlsiblings (locked in byTestHCLExamplesMatchYAML).How it's wired
The HCL → YAML step happens once, before anyone looks at the
versionfield.Detection is by
.hclextension, with a content-sniff fallback (LooksLikeHCL)for OCI artifacts and other sources that don't have a filename hint.
The converter is version-agnostic: it applies stable structural rules
(labeled-block → keyed map, etc.) that target the broad shape every schema
version has shared since v0. Field-level renames between versions are still
absorbed by the existing up-migrators. The
blockRulestable is the union ofHCL conventions across all supported versions; new entries are additive.
Drift protection
TestHCLExamplesMatchYAML— every.hclexample produces a config equalto its
.yamlsibling.TestHCLBlockRulesCoverSchemaMaps— walksagent-schema.jsonand assertsevery top-level property of shape
{additionalProperties: …}has a matchingmodeMapByLabelrule registered. Verified to fail with a clear messagewhen a new keyed map is added to the schema without an HCL rule.
TestJsonSchemaWorksForExamples— now also validates.hclexamples(via the converter) against the JSON schema.
Notable design choices
agent "root",model "claude") rather thanagents { root { … } }. Idiomatic HCL (cf. Terraformresource "type" "name") and lighter to write.toolset "mcp" { … }blocks aggregateinto the YAML
toolsets:list withtypeinjected.yaml.MapSlicefor label-keyed outputs so agent declaration orderis preserved through the YAML-marshal step (
Agentsis a slice in theGo config; order matters).
empty
hcl.EvalContext{}, so templates can't reach out to anything.Files
pkg/config/hcl/hcl.gopkg/config/hcl/hcl_test.gopkg/config/config.goLoad, convert before YAML pipelinepkg/config/resolve.go,pkg/sandbox/args.go.hclextensionpkg/config/examples_test.go.hclexamples + sibling-equivalence testpkg/config/schema_test.go.hcl+ drift testexamples/pirate.hcl,examples/gopher.hclValidation
mise lintandmise testare both green../bin/docker-agent agent run --dry-runloads both example HCL files successfully.