feat(agents): resolve $ref file includes with overlay overrides in Foundry config#8627
Merged
therealjohn merged 2 commits intoJun 12, 2026
Merged
Conversation
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new helper in the azure.ai.agents extension to resolve Foundry $ref file includes inside already-parsed service configuration data, including shallow sibling overlays, nested include resolution, path rebasing, and structured validation errors.
Changes:
- Added
ResolveFileRefsimplementation to recursively resolve$refYAML/JSON includes, apply shallow overlays, and rebase certain paths to the project root. - Added table-driven unit tests covering includes, overlays, rebasing behavior, and common error cases (missing/malformed/cyclic/URL/non-string/empty refs).
- Introduced a new extension error code for invalid
$refusage (invalid_file_ref).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/project/includes.go | New $ref resolver implementation (load, overlay, recurse, rebase, cycle/depth safety). |
| cli/azd/extensions/azure.ai.agents/internal/project/includes_test.go | Table-driven tests validating include resolution, rebasing rules, and error handling. |
| cli/azd/extensions/azure.ai.agents/internal/exterrors/codes.go | Adds CodeInvalidFileRef error code for structured validation errors. |
This was referenced Jun 12, 2026
therealjohn
approved these changes
Jun 12, 2026
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.
What
Adds an extension-owned resolver for the
azure.ai.agentsextension that resolves$reffile includes within a parsed Foundry service configuration, implementing spec §2.4 of #8590 (docs/specs/unify-azure-yaml/spec.md).ResolveFileRefs(cfg map[string]any, projectRoot string):$refstring is replaced by the referenced YAML or JSON file (JSON parses as a subset of YAML, so one decoder handles both).$refare overlaid on the loaded file as a shallow, top-level merge: sibling scalars, arrays, and objects each replace the loaded value wholesale.$refinside a loaded file resolves relative to that file's own directory.project,instructions, and$refpaths are rebased so the returned config has every path anchored toprojectRootin clean, forward-slash form. Inline values authored directly inazure.yamlare left exactly as written.instructionsis rebased only when it looks like a path (single line ending in.md/.txt), so inline prose is preserved.$refvalues are trimmed of surrounding whitespace before path resolution, so" ./agents/a.yaml "resolves correctly.slices.Contains/slices.Clonefor correctness); URL$reftargets are rejected; unreadable or malformed files produce structuredexterrorsvalidation errors.This is a self-contained helper plus thorough tests, mirroring the merged
${...}templating helper (#8602). There is no product call-site yet — the consumer is the not-yet-builtmicrosoft.foundryservice target (§2.2/§2.6).Testing
go build ./...,go vet ./...,gofmt,golangci-lint run(0 issues),go test ./...(full extension suite), andcspell— all clean.$refwhitespace trimming, sibling overlay, nested includes, top-level sequence files,project/instructionsrebasing, inline-vs-pathinstructions, and the missing-file / malformed / cyclic / URL / non-string / empty-$referror paths.Fixes #8626