azure-dev / azure.ai.agents
AGENTS.md570 starsChanged 8 months agoMITView on GitHub
Use this file together with cli/azd/AGENTS.md. This guide supplements the root azd instructions with the conventions that are specific to this extension. azure.ai.agents is a first-party azd extension under cli/azd/extensions/azure.ai.agents/. It runs as a separate Go binary and talks to the azd host over gRPC. Useful places to start: From cli/azd/extensions/azure.ai.agents: If extension work depends on a new azd core change, plan for two PRs: For local development, draft work, or validating both sides together before the core PR is…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cli/azd/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.connections/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.inspector/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.projects/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.routines/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.skills/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.toolboxes/AGENTS.mdAGENTS.md
- ext/vscode/AGENTS.mdAGENTS.md
- ext/vscode/.github/copilot-instructions.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- azdSkill
- agentic-workflowsSkill
- azd-code-reviewerSkill
- azd-grpc-contractsSkill
- azd-preflightSkill
- changelog-generationSkill
- foundry-extension-scenario-authoringSkill
- foundry-extension-scenario-pr-regressionSkill
- foundry-extension-scenario-suite-runSkill
- senseiSkill
- tool-version-upgradeSkill
- weekly-demo-videoSkill
- weekly-reportSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
14 rules. About 0 are common, 7 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 3
Use this file together with cli/azd/AGENTS.md.
- Distinctive: line 28
If extension work depends on a new azd core change, plan for two PRs:
- Very specific: line 69
Surface them to the user: when you make a change that touches a user-facing command path covered by an existing scenario (anything under …
- Distinctive: line 77
Add or update a scenario: when your change introduces a new command, flag, prompt, or user-visible flow — or meaningfully alters an …
- Distinctive: line 116
Use the marker only when the snippet is intentionally partial.
- Very specific: line 125
Use plain Go errors by default.
- Distinctive: line 140
Create a structured error once, as close as possible to the place where you know the final category, code, and suggestion.
- Very specific: line 142
If err is already a structured error, usually return it unchanged.
- Very specific: line 144
Do not add context with fmt.Errorf("context: %w", err) after err is already structured.
- Distinctive: line 185
Prefer the dedicated helpers instead of hand-rolling conversions:
- Distinctive: line 200
keep them stable once introduced
- Very specific: line 230
Do not use log.Fatal or log.Panic for expected failures — return a structured error via exterrors instead.
- Distinctive: line 248
Use modern Go 1.26 patterns where they help readability
- Very specific: line 249
When using PromptSubscription(), create credentials with Subscription.UserTenantId, not Subscription.TenantId
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Azure AI Agents Extension - Agent Instructions
Use this file together with cli/azd/AGENTS.md. This guide supplements the root azd instructions with the conventions that are specific to this extension.
Overview
azure.ai.agents is a first-party azd extension under cli/azd/extensions/azure.ai.agents/. It runs as a separate Go binary and talks to the azd host over gRPC.
Useful places to start:
internal/cmd/: Cobra commands and top-level orchestrationinternal/project/: project/service target integration and deployment flowsinternal/pkg/: lower-level helpers, parsers, and API-facing logicinternal/exterrors/: structured error factories and extension-specific codes
Build and test
From cli/azd/extensions/azure.ai.agents:
# Build using developer extension (for local development)
azd x build
# Or build using Go directly
go buildIf extension work depends on a new azd core change, plan for two PRs:
- Land the core change in
cli/azdfirst. - Land the extension change after that, updating this module to the newer azd dependency with
go get github.com/azure/azure-dev/cli/azd && go mod tidy.
For local development, draft work, or validating both sides together before the core PR is merged, you may temporarily add:
replace github.com/azure/azure-dev/cli/azd => ../../That replace points this extension at your local cli/azd checkout instead of the version in go.mod. Do not merge the extension with that replace still present.
Interactive CLI test scenarios
This extension ships a suite of goal-based scenarios for the
cli-interactive-tester
MCP server under tests/cli-interactive-tester-scenarios/. They drive real
azd ai agent flows end-to-end (init, provision, deploy, invoke, run, sessions,
files, monitor, endpoint, doctor, down) and are organized by tier:
- Tier 0 — offline, no Azure auth, no cost (help, version, validation, picker UX)
- Tier 1 — local-only with Azure auth (init flows)
- Tier 1b — deploy-verify: provisions a Tier 1 scaffold to confirm it deploys (incurs Azure cost)
- Tier 2 — full cloud E2E against a deployed shared agent (incurs Azure cost)
Each scenario carries a set of tags based on what is being tested and how.
See tests/cli-interactive-tester-scenarios/README.md for the tag taxonomy,
profile setup, and the human authoring contract, and
tests/cli-interactive-tester-scenarios/driving-mechanics.md for the executor
mechanics. Runs are driven through the foundry-extension-scenario-orchestrator agent — it routes
to the foundry-extension-scenario-pr-regression and foundry-extension-scenario-suite-run skills and fans work out
to foundry-extension-scenario-worker agents; new scenarios are authored through the
foundry-extension-scenario-author agent / foundry-extension-scenario-authoring skill.
Guidance for coding agents
These scenarios are never run automatically — they require the
cli-interactive-tester MCP server, a populated profile.local.yaml, and
(for Tier 2) real Azure resources. Do not invoke them on your own. Instead:
- Surface them to the user when you make a change that touches a
user-facing command path covered by an existing scenario (anything under
internal/cmd/that maps to acmd:*tag, or shared helpers used by those commands). In your summary, point the user at the relevant scenario(s) and suggest they validate the change by selecting thefoundry-extension-scenario-orchestratoragent (for a PR, thefoundry-extension-scenario-pr-regressionskill maps the diff to the matching tag set automatically). - Add or update a scenario when your change introduces a new command,
flag, prompt, or user-visible flow — or meaningfully alters an existing
one. Use the
foundry-extension-scenario-authoragent (or thefoundry-extension-scenario-authoringskill) to place the new YAML alongside the others following the tagging taxonomy and authoring contract, and mention the new/changed scenario in the PR description so reviewers know to exercise it. - Do not modify scenarios to match buggy behavior. Scenarios are user-facing specifications of how the command should behave; if a scenario fails because of your change, prefer fixing the code unless the behavior change is intentional and documented.
Documentation examples
azure.yaml examples in this extension's markdown docs are validated by
TestDocExamplesAreValid (internal/project/doc_examples_test.go). Every fenced
YAML block declaring an azure.ai.agent service must:
- Resolve through
AgentDefinitionFromServicewithout error, and - Satisfy
schemas/azure.ai.agent.json, including required fields, types, enums, patterns, and declared properties, and - Parse core-owned service fields (
docker,k8s,infra,hooks, and the scalar fields) with the same YAML shapes azd core expects.
azd ignores unknown service properties at runtime, so an undocumented key deploys cleanly while doing nothing — the test blocks that in our docs.
Snippets that are deliberately incomplete opt out of the "must fully resolve" check with a marker on the line before the fence:
<!-- azd:doc-example partial -->
```yaml
services:
my-agent:
host: azure.ai.agent
```Use the marker only when the snippet is intentionally partial. If a complete example fails, fix the example rather than adding the marker.
Error handling
This extension uses internal/exterrors so the azd host can show a useful message, attach an optional suggestion, and emit stable telemetry.
Default rule
Use plain Go errors by default. Switch to exterrors.* only when the current code can confidently answer all three of these:
- What category should telemetry see?
- What stable error code should be recorded?
- What suggestion, if any, should the user get?
That usually means:
- lower-level helpers return
fmt.Errorf("context: %w", err) - user-facing orchestration code classifies the failure with
exterrors.*
In this extension, that classification often happens in internal/cmd/ and internal/project/, not only in Cobra RunE handlers.
Most important rule
Create a structured error once, as close as possible to the place where you know the final category, code, and suggestion.
If err is already a structured error, usually return it unchanged.
Do not add context with fmt.Errorf("context: %w", err) after err is already structured. During gRPC serialization, azd preserves the structured error's own message/code/category, not the outer wrapper text. If you need extra context, include it in the structured error message when you create it.
Choosing an Error Type
| Situation | Prefer |
| Invalid input, manifest, or option combination | exterrors.Validation |
| Missing environment value, missing resource, unavailable dependency | exterrors.Dependency |
| Auth or tenant/credential failure | exterrors.Auth |
| azd/extension version or capability mismatch | exterrors.Compatibility |
| User cancellation | exterrors.Cancelled |
| Azure SDK HTTP failure | exterrors.ServiceFromAzure |
| gRPC failure from azd host AI/prompt calls | exterrors.FromAiService / exterrors.FromPrompt |
| Unexpected bug or local failure with no better category | exterrors.Internal |
Recommended pattern
func loadThing(path string) error {
if err := parse(path); err != nil {
return fmt.Errorf("parse %s: %w", path, err)
}
return nil
}
func runCommand() error {
if err := loadThing("agent.yaml"); err != nil {
return exterrors.Validation(
exterrors.CodeInvalidAgentManifest,
fmt.Sprintf("agent manifest is invalid: %s", err),
"fix the manifest and retry",
)
}
return nil
}Azure and gRPC boundaries
Prefer the dedicated helpers instead of hand-rolling conversions:
exterrors.ServiceFromAzure(err, operation)forazcore.ResponseErrorexterrors.FromHost(err, operation, context)for azd host gRPC service callsexterrors.FromAiService(err, fallbackCode)for azd host AI service callsexterrors.FromPrompt(err, contextMessage)for prompt failures
These helpers keep telemetry and user-facing behavior consistent.
Error codes
Define new codes in internal/exterrors/codes.go.
- use lowercase
snake_case - describe the specific failure, not the general category
- keep them stable once introduced
Release preparation
A new extension release ships in two PRs:
Provider handoff release
The release that removes microsoft.foundry from this extension must be coordinated with the provider-bearing azure.ai.projects release. Publish both artifacts before updating either registry entry, then update both entries and the microsoft.foundry meta-package together.
PR 1 — Version bump
Bumps the extension to the new version. Touches only:
version.txt— new semver stringextension.yaml—version:fieldCHANGELOG.md— new release section at the top
Once merged, the team triggers the CI release pipeline, which builds, signs, and publishes the extension binaries as a GitHub release.
PR 2 — Registry update
After the GitHub release is live, a follow-up PR updates cli/azd/extensions/registry.json so azd users can install the new version. The contents of that file are produced by running azd x publish against the published release artifacts (which computes the artifact URLs and checksums). The resulting PR should contain only the regenerated registry.json entry for the extension, and in some cases updated test snapshots as well.
Output: log vs fmt
Extensions write directly to stdout/stderr — there is no Console abstraction from azd core.
fmt.Print*— user-facing output (stdout). Pair withoutput.With*Formathelpers for styled text.log.Print*— developer diagnostics (stderr). Hidden unless--debugis set. Never uselogfor anything the user needs to see.- Do not use
log.Fatalorlog.Panicfor expected failures — return a structured error viaexterrorsinstead.
// ✅ log — internal detail the user doesn't need to see
log.Printf("ARM response: status=%d, id=%s", resp.StatusCode, resourceId)
// ✅ fmt — user-facing status and results
fmt.Println(output.WithSuccessFormat("Agent deployed to %s", endpoint))
// ❌ fmt used for debug noise — user sees internal details they can't act on
fmt.Printf("Parsed resource ID: sub=%s, rg=%s\n", subId, rg) // use log.Printf
// ❌ log used for user-facing info — user never sees it without --debug
log.Printf("No Foundry projects found in subscription") // use fmt + output helperOther extension conventions
- Use modern Go 1.26 patterns where they help readability
- When using
PromptSubscription(), create credentials withSubscription.UserTenantId, notSubscription.TenantId
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

