Skip to content

fix(agents): prompt for unified config env values#9212

Open
glharper wants to merge 3 commits into
mainfrom
glharper/9110-prompt-unified-env-vars
Open

fix(agents): prompt for unified config env values#9212
glharper wants to merge 3 commits into
mainfrom
glharper/9110-prompt-unified-env-vars

Conversation

@glharper

Copy link
Copy Markdown
Member

Summary

  • prompt for unset bare ${VAR} references in adopted Foundry service configuration during azd ai agent init
  • persist prompted values to the active azd environment and mask credential-like inputs
  • preserve existing values, ${VAR:-default}, Foundry ${{...}}, hook variables, and --no-prompt behavior

Testing

  • go test ./... -count=1
  • go build ./...
  • golangci-lint run ./internal/cmd/...

Fixes #9110

Prompt for unset bare ${VAR} references in adopted Foundry service configuration and persist the responses to the active azd environment. Preserve defaults, Foundry expressions, existing values, hook behavior, and --no-prompt execution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b4617dfd-adfb-4b30-9222-477a041f8af9
Copilot AI review requested due to automatic review settings July 20, 2026 14:07
@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
21 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

Pull request overview

Adds prompting and persistence for missing environment references in adopted Foundry configurations.

Changes:

  • Detects bare ${VAR} references while excluding defaults, hooks, and escaped references.
  • Masks credential-like prompts and saves responses to the active environment.
  • Integrates the flow into unified azure.yaml adoption with tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
init_env.go Implements reference discovery, prompting, and persistence.
init_env_test.go Tests detection, masking, persistence, and no-prompt behavior.
init_adopt.go Invokes environment configuration during adoption.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_env.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_env.go Outdated
Co-authored-by: glharper <64209257+glharper@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 20, 2026 14:28

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_env.go Outdated

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Traced the `` resolution through foundry.ResolveFileRefs (sibling keys overlay the loaded object) and confirmed the `${{...}}` masking is multiline-aware before the env-ref regex runs. Escape handling, `:-` default skipping, hooks exclusion, and secret-upgrade dedup all line up with the tests. Nothing blocking from me.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_env.go Outdated
Mask prompted values only when the reference appears under explicit credential or secret configuration. Avoid inferring sensitivity from arbitrary environment variable names while continuing to prompt for all unset Foundry references.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b4617dfd-adfb-4b30-9222-477a041f8af9
Copilot AI review requested due to automatic review settings July 20, 2026 22:05
@glharper
glharper requested a review from trangevi July 20, 2026 22:05

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +77 to +78
if existing[reference.Name] == "" {
missing = append(missing, reference)

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

init_env.go:78 - the missing-value check reads from GetValues, which returns only persisted dotenv entries. Foundry expansion resolves unset refs from the process environment as well (synthesis/synthesizer.go maybeExpand falls back to os.LookupEnv). A var that is exported in the shell but absent from the azd env is treated as missing here, so we prompt for it and then persist a value that shadows the exported one. Mirroring the same dotenv-first, process-env fallback lookup (while still counting an explicitly empty dotenv entry as missing) avoids the spurious prompt. A process-env-only regression test would lock it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd ai agent init does not prompt for environment variables referenced by unified azure.yaml 

5 participants