fix: allow --local with a named agent in azd ai agent invoke#8771
Conversation
Remove the validation guard that rejected --local combined with a positional agent name. The downstream local code paths (responsesLocal, invocationsLocal) already accept and use the agent name for session key resolution and protocol detection. Also fix resolveProtocol to pass the agent name (instead of empty string) when --local is set, so protocol auto-detection reads the correct agent's agent.yaml in multi-agent projects. Fixes #7928 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
This PR updates the azd ai agent invoke command in the azure.ai.agents extension to allow combining --local with an explicitly named agent, which is important for multi-agent projects to avoid interactive selection and to ensure protocol detection reads the correct agent’s agent.yaml.
Changes:
- Removed the validation that rejected
--localwhen a positional agent name is provided. - Fixed protocol auto-detection for local invocation to use the provided agent name.
- Added a CLI example and a regression test covering
invoke <name> --local.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/cmd/invoke.go | Removes the --local+name validation guard and ensures protocol resolution uses the named agent for local invokes; adds an example for the new supported usage. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/invoke_test.go | Adds a test to verify --local with a positional agent name is not rejected during argument/flag validation. |
Collapse redundant if/else branches in resolveProtocol since both paths now call resolveAgentProtocol with identical arguments. Improve TestInvokeLocalWithNamedAgent: assert error is returned, discard Cobra output to keep test runs clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
…voke-named-agent # Conflicts: # cli/azd/extensions/azure.ai.agents/internal/cmd/invoke.go Co-authored-by: huimiu <107838226+huimiu@users.noreply.github.com>
Resolved the merge conflict in |
|
/check-enforcer override |
Why
In multi-agent projects,
azd ai agent invoke my-agent --local "message"fails with:This forces users to go through the interactive picker every time, even when they already know the agent name. The downstream local code paths (
responsesLocal,invocationsLocal) already accept and correctly use the agent name for session key resolution, so the validation guard was unnecessarily restrictive.What changed
--localcombined with a positional agent name.resolveProtocol()to passa.flags.name(instead of empty string) when--localis set, so protocol auto-detection reads the correct agent'sagent.yamlin multi-agent projects.azd ai agent invoke my-agent --local "Hello!".TestInvokeLocalWithNamedAgentverifying the combination passes validation.All existing tests pass.
Fixes: #7928