-
Notifications
You must be signed in to change notification settings - Fork 237
Integrate azd
copilot agent into azd
init flow
#5557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
azd
copilot agent into azd
init flowAzd ai agent intazd
copilot agent into azd
init flowAzd ai agent int
azd
copilot agent into azd
init flowAzd ai agent intazd
copilot agent into azd
init flow
Wow! This has come so far since the demo.
|
We can control the verbosity to some extent by telling the LLM how brief the summary should be. Right now I instruct the LLM to @SophCarp - the markdown to terminal styles are using glamour and can be pretty easily tweaked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates an azd
copilot agent into the azd
init flow to provide AI-powered project initialization capabilities. The implementation adds LLM infrastructure, agent tools, and MCP (Model Context Protocol) integration to enable intelligent project setup and configuration generation.
Key changes include:
- New LLM abstraction layer with support for Azure OpenAI and Ollama models
- Comprehensive agent tools for file I/O, command execution, and Azure operations
- MCP integration for external tool communication
- Rich markdown rendering for improved terminal output
Reviewed Changes
Copilot reviewed 63 out of 64 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
go.mod | Adds dependencies for MCP adapter, LangChain Go, Glamour markdown rendering, and related libraries |
cli/azd/pkg/output/colors.go | Adds markdown rendering capability using Glamour with console width detection |
cli/azd/pkg/llm/*.go | New LLM abstraction layer with model factory, providers for Azure OpenAI and Ollama |
cli/azd/internal/agent/tools/mcp/*.go | MCP integration for external tool communication and sampling handler |
cli/azd/internal/agent/tools/io/*.go | Comprehensive file I/O tools for reading, writing, copying, moving files and directories |
cli/azd/internal/agent/tools/dev/*.go | Command execution tools for running system commands |
cli/azd/internal/agent/tools/azd/prompts/*.go | Embedded prompts for agent operations |
// #nosec G204 - Command execution is the intended functionality of this tool | ||
cmd = exec.CommandContext(ctx, "sh", "-c", fullCommand) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command injection vulnerability: The tool executes arbitrary commands from user input without proper validation or sandboxing. This could allow malicious users to execute dangerous system commands.
// Directly execute the command with arguments to avoid command injection | |
cmd = exec.CommandContext(ctx, command, args...) | |
// If shell features are required (e.g., pipes, globbing), consider implementing allow-listing or input validation. | |
// Note: This change prevents command injection by not invoking a shell. |
Copilot uses AI. Check for mistakes.
if t.CallbacksHandler != nil { | ||
t.CallbacksHandler.HandleToolStart(ctx, fmt.Sprintf("http_fetcher: %s", input)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSRF vulnerability: The tool makes HTTP requests to arbitrary URLs without validation, which could allow attackers to access internal services or perform server-side request forgery attacks.
// SSRF protection: validate the input URL | |
if err := validateURLForSSRF(input); err != nil { | |
toolErr := fmt.Errorf("invalid or potentially unsafe URL: %w", err) | |
if t.CallbacksHandler != nil { | |
t.CallbacksHandler.HandleToolError(ctx, toolErr) | |
} | |
return "", toolErr | |
} |
Copilot uses AI. Check for mistakes.
return nil, &internal.ErrorWithSuggestion{ | ||
Err: fmt.Errorf("The model type '%s' is not supported. Support types include: azure, ollama", modelType), | ||
//nolint:lll | ||
Suggestion: "Use `azd config set` to set the model type and any model specific options, such as the model name or version.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message suggests using 'azd config set' but doesn't provide the specific command syntax for setting the model type configuration.
Suggestion: "Use `azd config set` to set the model type and any model specific options, such as the model name or version.", | |
Suggestion: "Use `azd config set llm.type <modelType>` to set the model type (e.g., `azd config set llm.type azure`). You can also set model-specific options, such as the model name or version.", |
Copilot uses AI. Check for mistakes.
|
||
// Provide feedback for large content | ||
if len(content) > 10000 { | ||
fmt.Printf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct use of fmt.Printf for user feedback should use the output package's formatting functions for consistent styling and color support.
fmt.Printf( | |
output.Warnf( |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome and overall felt nice to use!
Some initial thoughts:
- During init it seemed to set the azure location and subscription for me and it happened to pick a subscription that I did not have permissions for. I think it would be good to have the user still pick the location and subscription.
- The
provision --preview
failed (couldn't run WhatIf on subscription) so it never got the chance to correct any issues with the Bicep. (I realized after the fact I could've asked it to select a different subscription and revalidate the Bicep).
- The
- I like how it would pause every so often to ask for feedback, but I also wish there was some sort of indicator of high-level progress. I was often wondering, "How many more steps/pauses are left?"
- When I first ran it, I got an error about
azmcp
not found:ERROR: failed to start command: exec: "azmcp": executable file not found in %PATH%
. Is Azure MCP a hard requirement? It would be nice to let the user know if that's the case, or make it work even if it isn't installed.
Yeah, we likely could still just manually prompt for the subscription/location in this flow.
Makes sesnse - would be good to have some more visual indication like Step 3/5 or similar. Maybe @SophCarp has some ideas.
Agree it shouldn't be a hard requirement. We can "try" to use it but if not available we don't need to fail. |
I tried the latest set of changes on our Build lab sample: Another requirement that's helpful to call out is Azure CLI for Bicep validation: After installing az CLI, I had to open a new terminal session for it to detect the It spent ~10 minutes on the Validating project step - I think it got stuck in a loop trying to fix syntax errors in one of the bicep files and eventually gave up: Attached the logs if that helps: azd-agent-2025-08-08.log Problematic Bicep file (added invalid commas and some duplicated lines): ![]() The {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environmentName": {
"value": "dev"
},
"location": {
"value": "eastus"
},
"tags": {
"value": {
"owner": "team-hotelsearch",
"costCenter": "ai-lab",
"project": "hotelsearch"
}
}
}
}
On Windows, when inputting feedback, the cursor seems to be off by one character: Recording.2025-08-08.164024.mp4 |
great feedback @JeffreyCA . azd should not ask users to install bicep cli. azd its own copy of bicep cli. Maybe this needs to be added to the azd-mcp instructions. And we would need another internal tool to use bicep cli from |
25e7259
to
95e2972
Compare
Can we split this PR into 2 or 3? |
Get AI configuration from config Adds factory to create agent instances
beb87c9
to
5ee0b02
Compare
if !cc.isServerAlreadyTrusted(ctx, OperationTypeTool) { | ||
choices = append(choices, &ux.SelectChoice{ | ||
Value: "server", | ||
Label: "Allow all tools from this server", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add number in each label to allow quick selections for users?
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash:
pwsh:
WindowsPowerShell install
MSI install
Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
It will be too much churn to break it up at this point. It is all behind a feature flag and can iterate on anything that needs improvements. |
What are the changes
azd
agentazd
supporting toolsHow to configure
Enable LLM alpha feature
azd config set alpha.llm on
Configure
azd
agentazd
global config file @~/.azd/config.json
Ensure a section similar to the following exists in your
azd
configurationImportant
Works best with GPT 4.1 model right now
Configure MCP Server
To add
azd
MCP server to your dev tools add the following configuration.Example configuration for VS Code
Running Project Migration with VS Code
After configuring the
azd
MCP server the same tools can be leveraged to migrate or initialize applications to becomeazd
compatible.Running
azd init
withazd
CopilotSelect copilot mode
Running discovery & analysis step
Running Architecture Planning step
Docker File Generation
Running Infrastructure generation
Providing Feedback
Feedback Submission
Generating azure.yaml
Final Project Validation
Final feedback
Consent System
All tools and sampling requests require user consent. Users can choose from various levels of consent for individual tools, servers, or classification of tools.
Consent Commands
azd mcp consent list
- List all consent rulesazd mcp consent grant
- Grants a new consent ruleazd mcp consent revoke
- Revokes a previously granted consent rulePrompt for consent to run tools
The selected option is persisted in consent system configuration.