Add commands for agent management and enhance functionality#6972
Draft
therealjohn wants to merge 3 commits intoAzure:mainfrom
Draft
Add commands for agent management and enhance functionality#6972therealjohn wants to merge 3 commits intoAzure:mainfrom
therealjohn wants to merge 3 commits intoAzure:mainfrom
Conversation
- Implement `invoke` command to send messages to agents, supporting both local and remote invocation. - Introduce `list` command to retrieve and display all deployed agents in a Foundry project, with options for JSON and table output. - Add `monitor` command to stream logs from agent containers, with auto-detection of agent name and version. - Enhance `show` command to retrieve runtime status of agents, with improved auto-resolution of agent details. - Update error codes to include new cases for invalid arguments and template download failures. - Create unit tests for template URL resolution, repository slug extraction, and agent YAML file discovery.
- Updated command names from `azd ai agent dev` to `azd ai agent run` for clarity. - Enhanced the initialization process to prompt for container settings and startup commands. - Simplified agent service listing and improved output formatting. - Removed deprecated commands and streamlined the command structure. - Introduced container presets for easier configuration. - Added auto-resolution for agent names and versions in `show` and `monitor` commands. - Implemented a local state file for session and conversation persistence. - Updated error handling and messaging for better user experience.
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.
New Command Surface
azd ai agent initazd ai agent runazd ai agent invoke [message]azd ai agent listazd ai agent showazd ai agent monitorAll commands operate in the context of the current azd project and environment.
1. Init from Template (
init --template)Scaffolds an agent project from a GitHub template repository and starts the setup of agent.yaml (shortcuts azd init -t & azd ai agent init).
--template(-t): GitHub repo — full URL,owner/repo, or bare name (resolved toAzure-Samples/{name}).--templateand--manifestare mutually exclusive.git clone; falls back to GitHub REST API ifgitis unavailable.GITHUB_TOKEN/GH_TOKENfor authenticated access.Behavior by project state:
infra/. Collisions offer overwrite / skip / cancel.--infrainfra/directory from the template.--infra)src/<agent-name>/.Agent manifest discovery searches root →
src/*/→ recursive, looking foragent.yaml,agent.yml,agent.manifest.yaml,agent.manifest.yml.2. Init from Code (
initwith no flags)Initializes an agent project from local source code.
agent.yaml, not directory name).azure.yamldefaults to the agent name.<agent-name>-dev.agent.yamlAgentDefinition is found (haskind, notemplate), it is preserved — not overwritten.3. Prompt Re-ordering & Startup Commands (All Init Paths)
Azure subscription and location questions are asked only when needed (e.g., deploying a model or querying a Foundry project), not upfront.
Before:
After:
Subscription is extracted from
--project-idwhen provided. Resolved values are persisted to the azd environment (AZURE_TENANT_ID,AZURE_SUBSCRIPTION_ID,AZURE_LOCATION).Startup Commands
To support the
runcommand, use thestartupCommandproperty of a service, already available in the schema. Theinitsteps can attempt to auto-detect defaults:Look for a main.py, *.csproj
Python:
uv run python main.py.NET:
dotnet run <name>.csprojThe interactive experience for init should ask the user for the command, providing these auto-detected experiences as defaults.
For --no-prompt scenarios, add a
--startup-commandargument toinitto allow specifying this.4. Container Configuration Presets
All init paths present a single question for container resource settings instead of silent defaults or per-field prompts:
5. Local Development (
run)Runs the agent locally for interactive development.
--start-command→startupCommandinazure.yaml→ auto-detect by project type.pyproject.toml/requirements.txt→python main.py), .NET (*.csproj→dotnet run), Node.js (package.json→npm start).uv(preferred) orpip; Node.js vianpm install; .NET: none needed.PORTenv var; loads azd environment variables into the child process.6. Agent Invocation (
invoke)Sends a message to a local or remote agent.
http://localhost:{port}/responses. Default port: 8088.--nameimplies--remote. Auto-resolves agent name fromazure.yaml+ environment."hello".Session & Conversation State
State is stored as azd environment variables (not a local JSON file):
AZD_AI_AGENT_INVOKE_NAMEAZD_AI_AGENT_INVOKE_SESSIONIDAZD_AI_AGENT_INVOKE_CONVERSATIONID--new-sessionresets all three variables.--sessionoverrides the session ID for one invocation.7. List Agents (
list)Lists the agent services defined in
azure.yaml.azure.ai.agentfromazure.yaml.AZD_AI_AGENT_INVOKE_NAMEwith an arrow indicator.8. Error Codes
New error codes:
invalid_args,template_download_failed,agent_yaml_not_found.9. Manifest File Naming
Recognized manifest filenames:
agent.yaml,agent.yml,agent.manifest.yaml,agent.manifest.yml. User-facing messages use the term "agent manifest file" rather than a specific filename.