fix: stop agent lifecycle from rewriting azure.yaml - #9397
Conversation
|
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. |
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
|
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. |
There was a problem hiding this comment.
Pull request overview
Prevents agent lifecycle hooks from rewriting azure.yaml while preserving runtime container defaults.
Changes:
- Removes project persistence calls from container-setting preparation.
- Keeps inline, legacy, missing-default, and
$refsettings resolved in memory. - Updates tests for in-memory behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/cmd/listen.go |
Applies lifecycle container settings without persisting them. |
internal/cmd/listen_test.go |
Verifies in-memory resolution across configuration paths. |
jongio
left a comment
There was a problem hiding this comment.
Verified the core claim: deploy applies the same defaults, so dropping the lifecycle write doesn't change deployed behavior. service_target_agent.go falls back to DefaultCpu/DefaultMemory (same constants) when the resolved config leaves them empty, and the remaining hook writes (updateLegacyProjectDeployments, envUpdate) only touch env vars, never azure.yaml. Dropping the client parameter from prepareContainerSettings also means the function can't write back to the host at all now, which is a stronger guarantee than the assertion the tests used to carry.
One thing outside the diff worth a follow-up: the comment at cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent.go:1488 still reads "$ref services never persist resolved defaults to azure.yaml, so deploy applies the extension defaults here to keep $ref and inline services consistent". After this change no service shape persists resolved defaults during preprovision/predeploy, so that fallback is now the only place defaults get applied for every service, not just the $ref ones. Rewording it would stop a future reader from assuming inline services still carry persisted values and reintroducing the write.
jongio
left a comment
There was a problem hiding this comment.
Re-reviewed at e2be080. My earlier comment about the discarded return values from SetAgentContainerSettings is addressed: it now returns only error, the doc comment no longer advertises a persistence target, and both the caller in listen.go and the test are updated to match. Confirmed listen.go is the only production caller, so nothing else loses the path/value pair.
Verified against the head commit locally: go build ./..., go vet, and go test ./internal/project ./internal/cmd -count=1 all pass.
Summary
$refconfiguration pathsWhy
The
azure.ai.agentsextension persisted resolved CPU and memory settings during every preprovision and predeploy event. That project mutation caused azd core to reserialize the entireazure.yamlfile, which changed formatting and could remove user-authored metadata and hook fields.Lifecycle persistence is removed because deployment already applies the same CPU and memory defaults when values are omitted. This preserves
azure.yamlwithout changing deployed agent behavior, while explicit configuration commands such as init, adopt, and optimize continue to write intended changes.Testing
go test .\internal\cmd .\internal\project -count=1go build .\...End-to-end steps
azure.ai.agentsfrom the PR head SHA in an isolated azd profile.azure.yamlbefore running lifecycle commands.azd provision --no-prompt,azd infra create --no-prompt,azd deploy --no-prompt, andazd up --no-prompt.azure.yamlis unchanged.Fixes #8025