Commit c316e90
fix(agents): resolve remote invoke name from inline service config (#9114)
* fix(agents): resolve remote invoke name from inline service config
Brownfield init against an existing Foundry project writes the hosted agent
name inline in the azure.ai.agent service, but does not populate the deployed
AGENT_<SERVICE>_NAME environment output. Remote invoke only consulted that env
value, so an otherwise valid unified azure.yaml service resolved with an empty
agent name and failed with the misleading "agent name is required" error.
Seed AgentServiceInfo.AgentName from the inline/config-nested hosted-agent
definition, then let AGENT_<SERVICE>_NAME override it after deployment. Do not
fall back to the azure.yaml service key because the service and deployed agent
names may intentionally differ.
Adds regression coverage for pre-deploy/brownfield inline-name resolution and
for deployed environment output retaining precedence.
Fixes #9109
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
* fix(agents): limit inline invoke fallback to brownfield adoption
Addresses review feedback on PR #9114. Using every inline azure.yaml agent name
as a pre-deploy fallback could silently invoke an older live agent with matching
name but different code or protocols.
Only use the inline name when the agent explicitly depends on an
azure.ai.project service with a non-empty endpoint, which is the brownfield
adoption signal from the reported scenario. Greenfield services without
AGENT_<SERVICE>_NAME remain blocked and now receive an actionable "deploy
first" validation error. Explicit agent names and --agent-endpoint continue to
support intentionally invoking existing agents without deployment.
Deployed AGENT_<SERVICE>_NAME remains authoritative. Adds tests for brownfield
fallback, greenfield rejection, env precedence, and the improved error.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
* fix(agents): scope brownfield inline-name fallback to invoke
A final call-site audit found that the shared agent resolver is also used by
destructive commands such as delete. Applying the brownfield inline-name
fallback globally could let delete target an adopted pre-existing agent before
azd had deployed it.
Make brownfield inline-name resolution an explicit resolver option and enable
it only from remote invoke. All other commands retain env-only deployed-name
resolution. The regression test asserts the default shared resolver does not
target the brownfield agent, while invoke's opt-in path still resolves it.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
* fix(agents): classify missing deploy output as dependency
Address review feedback by reporting a missing AGENT_<SERVICE>_NAME deployment
output as exterrors.Dependency with CodeMissingAgentEnvVars, matching existing
agent-context error classification. Assert the stable code and dependency
category in the invoke error test.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
* fix(agents): handle auto-protocol and env lookup edge cases
A final review found two ways invoke could still bypass deploy-first safety:
- Auto protocol detection caches the azure.yaml service key in flags.name. If
no agent name resolved, that key could remain as the remote target. Clear the
cached selector unless the protocol was explicit.
- A transient AGENT_<SERVICE>_NAME lookup error is not proof that the output is
absent. Enable the brownfield inline fallback only after the active env was
read and the name key was confirmed missing/empty; otherwise leave it empty.
Adds focused tests for auto-protocol clearing, explicit-name preservation,
resolved-name precedence, and transient env lookup failure.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
* fix(agents): surface auto-protocol resolver failures
Auto protocol detection caches the azure.yaml service key in flags.name. If a
second project-service resolution failed transiently, invoke could continue and
treat that cached selector as the Foundry agent name.
Surface resolver failures in auto-protocol mode. Explicit protocol mode still
ignores project resolution failures so a user-provided direct agent name works
without an azd service. Add tests for both branches.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
* fix(agents): confirm brownfield agent name reuse
Check adopted agent names against the selected existing Foundry project, require confirmation before reuse, and persist replacement names when declined.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ef953bfc-0f9a-477e-aef6-7e703f7e4bee
* fix(agents): address invoke resolution feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent 168f02a commit c316e90
10 files changed
Lines changed: 1131 additions & 60 deletions
File tree
- cli/azd/extensions/azure.ai.agents/internal/cmd
Lines changed: 175 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
544 | 545 | | |
545 | 546 | | |
546 | 547 | | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
551 | 553 | | |
552 | 554 | | |
553 | 555 | | |
| |||
656 | 658 | | |
657 | 659 | | |
658 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
659 | 763 | | |
660 | 764 | | |
661 | | - | |
662 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
663 | 775 | | |
664 | 776 | | |
665 | 777 | | |
666 | 778 | | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
667 | 784 | | |
668 | 785 | | |
669 | | - | |
| 786 | + | |
| 787 | + | |
670 | 788 | | |
671 | 789 | | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
672 | 799 | | |
673 | 800 | | |
674 | 801 | | |
675 | 802 | | |
676 | 803 | | |
677 | 804 | | |
678 | 805 | | |
679 | | - | |
| 806 | + | |
680 | 807 | | |
681 | 808 | | |
682 | | - | |
683 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
684 | 849 | | |
685 | 850 | | |
686 | 851 | | |
| |||
0 commit comments