azure-dev / azure.ai.toolboxes
AGENTS.md573 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.toolboxes is a first-party azd extension under cli/azd/extensions/azure.ai.toolboxes/. It runs as a separate Go binary and talks to the azd host over gRPC. The user-facing surface is azd ai toolbox <verb> — CRUD plus a connection subgroup for managing the connection-backed tools attached to a Foundry toolbox. Useful places to start: - internal/cmd/: Cobra commands, verb implementations, and…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 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 repository25 other files it gives its agents.
- cli/azd/AGENTS.mdAGENTS.md
- cli/azd/extensions/azure.ai.agents/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
- ext/vscode/AGENTS.mdAGENTS.md
- .github/skills/extension-user-contract-review/evals/fixtures/cli/azd/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
- extension-user-contract-reviewSkill
- 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
We split this AGENTS.md into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
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 35
If extension work depends on a new azd core change, plan for two PRs:
- Very specific: line 61
No toolbox-specific logic inside
internal/foundry/: Keep that package to primitives any sibling extension would also need … - Very specific: line 74
Use plain Go errors by default.
- Distinctive: line 90
Create a structured error once, as close as possible to the place where you know the final category, code, and suggestion.
- Very specific: line 93
If err is already a structured error, usually return it unchanged.
- Very specific: line 95
Do not add context with fmt.Errorf("context: %w", err) after err is already structured.
- Distinctive: line 138
Prefer the dedicated helpers instead of hand-rolling conversions:
- Distinctive: line 153
keep them stable once introduced
- Very specific: line 173
After the GitHub release is live, a follow-up PR updates cli/azd/extensions/registry.json so azd users can install the new version.
- Very specific: line 188
Do not use log.Fatal or log.Panic for expected failures — return a structured error via exterrors instead.
- Distinctive: line 207
Use modern Go 1.26 patterns where they help readability.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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 Toolboxes 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.toolboxes is a first-party azd extension under
cli/azd/extensions/azure.ai.toolboxes/. It runs as a separate Go binary and talks
to the azd host over gRPC.
The user-facing surface is azd ai toolbox <verb> — CRUD plus a connection
subgroup for managing the connection-backed tools attached to a Foundry toolbox.
Useful places to start:
internal/cmd/: Cobra commands, verb implementations, andconnectionsubgroupinternal/pkg/azure/:FoundryToolboxClient(toolbox CRUD data-plane client)internal/foundry/: Foundry primitives shared with sibling extensions (project-endpoint cascade, credential factory, single-connection lookup)internal/exterrors/: structured error factories and toolbox-specific codes
Build and test
From cli/azd/extensions/azure.ai.toolboxes:
# 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.
Package boundaries
internal/foundry/ holds Foundry data-plane primitives that are currently
duplicated from azure.ai.agents and intended to be lifted into a shared module
later. Two rules keep that future lift mechanical:
- One-way import contract. Files under
internal/foundry/MUST NOT import anything underinternal/cmd/. Files underinternal/cmd/may importinternal/foundry/...freely. - No toolbox-specific logic inside
internal/foundry/. Keep that package to primitives any sibling extension would also need (project-endpoint resolution, single-connection lookup, credential factory). Toolbox-specific concepts (projectConnection,connectionResolver, theFoundryToolboxClient) live ininternal/cmd/andinternal/pkg/azure/.
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 usually happens in internal/cmd/.
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 |
| User cancellation | exterrors.Cancelled |
| Azure SDK HTTP failure | exterrors.ServiceFromAzure |
| gRPC failure from an azd host Prompt call | exterrors.FromPrompt |
| Unexpected bug or local failure with no better category | exterrors.Internal |
Recommended pattern
func parseInput(path string) error {
if err := readFile(path); err != nil {
return fmt.Errorf("read %s: %w", path, err)
}
return nil
}
func runCommand() error {
if err := parseInput("tools.json"); err != nil {
return exterrors.Validation(
exterrors.CodeInvalidParameter,
fmt.Sprintf("invalid input file: %s", err),
"fix the file and retry",
)
}
return nil
}Azure and gRPC boundaries
Prefer the dedicated helpers instead of hand-rolling conversions:
exterrors.ServiceFromAzure(err, operation)forazcore.ResponseError(data-plane and ARM calls).exterrors.FromPrompt(err, contextMessage)forazdClient.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
- co-locate any new
Op*constant with the matchingServiceFromAzurecall site
Release preparation
A new extension release ships in two PRs:
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).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("toolbox show: pending-toolbox read failed for %q: %v", name, err)
// ✅ fmt — user-facing status and results
fmt.Printf("Created toolbox %s at version %s.\n", name, version)
// ❌ fmt used for debug noise — user sees internal details they can't act on
fmt.Printf("Parsed endpoint: host=%s, path=%s\n", host, path) // use log.Printf
// ❌ log used for user-facing info — user never sees it without --debug
log.Printf("No toolboxes found on project") // use fmt.Print*Other extension conventions
- Use modern Go 1.26 patterns where they help readability.
- Reserved azd globals (
--output,--no-prompt) are inherited fromextCtx, not registered as flags on each verb. - Lowercase-normalize
--outputwhen reading it fromextCtxso downstream branches can compare with== "json".
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.

