foundry-samples / hosted-agents
AGENTS.md21 starsChanged 3 months agoMITView on GitHub
Conventions for AI agents creating or editing samples under samples/python/hosted-agents/. Agents read the nearest AGENTS.md up the tree, so this applies to Python hosted-agent samples. Treat these as shared conventions and a starting point — adapt to what each sample actually needs. Copy both shared templates into the new sample: 1. Copy README-template.md to README.md. 2. Copy AGENTS-template.md to AGENTS.md. 3. Replace the placeholders, update paths and commands, and remove sections or bullets that do not apply. The Foundry Toolkit…
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 35,266 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 repository301 other files it gives its agents.
- samples/cli/prompt-agents/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/a2a/01-delegation/caller/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/a2a/01-delegation/executor/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/agent-skills/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/azure-search-rag/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/browser-automation/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/egress-control/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/file-tools/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/foundry-memory-rag/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/foundry-toolbox-mcp-skills/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/foundry-toolbox-server-side/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/harness-data-processing/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/harness-research/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/harness-scaling-capabilities/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/hello-world/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/invocations-echo-agent/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/local-tools/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/mcp-tools/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/observability/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/resilient-workflow/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/simple-agent/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/steerable-workflow/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/steering/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/teams-activity/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/text-search-rag/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/toolbox-auth-paths/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/agent-framework/workflows/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/conversation_engine/adapter_mode/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/conversation_engine/basic/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/invocations/HelloWorld/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/invocations/human-in-the-loop/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/invocations/notetaking-agent/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/invocations_ws/HelloWorld/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/responses/background-agent/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/responses/browser-automation/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/responses/env-vars-agent/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/responses/HelloWorld/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/responses/notetaking-agent/AGENTS.mdAGENTS.md
- samples/csharp/hosted-agents/bring-your-own/responses/openai-computer-tool/AGENTS.mdAGENTS.md
- samples/python/autopilot-agents/foundry-toolbox/AGENTS.mdAGENTS.md
- samples/python/autopilot-agents/hello-world/AGENTS.mdAGENTS.md
- samples/python/autopilot-agents/meeting-assistant/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/a2a/01-delegation/caller/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/a2a/01-delegation/executor/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/invocations/01-basic/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/invocations/02-content-safety-guardrail/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/01-basic/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/02-tools/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/05-workflows/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/06-files/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/07-skills/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/07-teams-activity/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/08-observability/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/09-declarative-customer-support/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/10-downstream-azure/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/11-azure-search-rag/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/12-foundry-skills/AGENTS.mdAGENTS.md
- samples/python/hosted-agents/agent-framework/responses/13-foundry-memory/AGENTS.mdAGENTS.md
- The first 60 shown.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 0 are common, 4 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 33
Follow DEPENDENCY_POLICY.md whenever you create a Python Hosted Agent runtime or change its dependencies.
- Very specific: line 36
Use pyproject.toml and uv.lock by default in each executable runtime project referenced by services.<name>.project in azure.yaml.
- Distinctive: line 45
When a dependency input changes, update the selected lock artifact in the same change.
- Distinctive: line 47
Do not update dependency versions during unrelated work.
- Very specific: line 49
Before finishing a dependency change, run the checker documented in DEPENDENCY_POLICY.md, including --resolve when network access is …
- Very specific: line 58
Every new Python hosted-agent sample must add a public test-spec.yml with a responsible Microsoft owner alias, supported experiences, …
- Very specific: line 63
Read and follow the authoritative hosted-agent cloud E2E test-spec schema and onboarding checklist.
- Very specific: line 65
Run both the documented validate and protocol-aware plan commands before submitting changes.
- Very specific: line 70
Use the standard logging module for diagnostics emitted by a running hosted agent.
- Very specific: line 75
Use print() only when stdout is intentionally part of a CLI, provisioning script, local test utility, or tool-result contract.
- Very specific: line 102
Prefer the current CLI commands (the template reflects these.
- Very specific: line 104
Prefer self-contained READMEs over deferring run/deploy steps to a parent README or hiding steps inside collapsible <details> blocks.
- Very specific: line 106
Keep Toolkit-generated .vscode launch/task files out of the sample.
- Distinctive: line 111
Not every sample fits the two-option shape, and that's fine — adapt rather than force it:
- Distinctive: line 120
Use the template for structure and shared vocabulary, and keep whatever sample-specific sections a reader needs.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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
Coding Agent Instructions — Python hosted-agent samples
Conventions for AI agents creating or editing samples under
samples/python/hosted-agents/. Agents read the nearest AGENTS.md up the
tree, so this applies to Python hosted-agent samples. Treat these as shared
conventions and a starting point — adapt to what each sample actually needs.
Starting a new sample
Copy both shared templates into the new sample:
- Copy
README-template.mdtoREADME.md. - Copy
AGENTS-template.mdtoAGENTS.md. - Replace the placeholders, update paths and commands, and remove sections or bullets that do not apply.
The Foundry Toolkit generates .vscode/launch.json and .vscode/tasks.json in
the scaffolded workspace to support the F5 flow. Do not commit those generated
files to the sample.
Match deployment guidance to the sample's azure.yaml: direct code deployment
uses codeConfiguration and does not require a Dockerfile; Dockerfile guidance
applies only when the sample uses container deployment through docker.path.
Configure PYTHONNOUSERSITE: "1" in each Python hosted service's env map
and ENV PYTHONNOUSERSITE=1 in Python Dockerfiles, not in individual run
commands or inside main.py.
See the shared Python startup configuration
for deployment environment and dependency guidance.
Python dependency policy
Follow DEPENDENCY_POLICY.md whenever you create a
Python Hosted Agent runtime or change its dependencies.
- Use
pyproject.tomlanduv.lockby default in each executable runtime project referenced byservices.<name>.projectinazure.yaml. - A fully resolved
requirements.txtremains accepted as a backward-compatible fallback for existing samples or concrete compatibility constraints. - The selected artifact must pin the complete direct and transitive runtime dependency graph. When both forms exist, the uv pair is authoritative.
- Preserve required extras, prereleases, and environment markers. Do not leave bare names, version ranges, wildcard pins, editable/local paths, or mutable source references in the consumer artifact.
- When a dependency input changes, update the selected lock artifact in the same change.
- Do not update dependency versions during unrelated work. Existing legacy samples are grandfathered until a dependency input changes.
- Before finishing a dependency change, run the checker documented in
DEPENDENCY_POLICY.md, including--resolvewhen network access is available.
A uv-native sample may omit requirements.txt. Keep pyproject.toml and
uv.lock synchronized, and run the frozen resolution check before submitting
dependency changes.
Cloud E2E contract for new samples
Every new Python hosted-agent sample must add a public test-spec.yml with a
responsible Microsoft owner alias, supported experiences, deterministic turns,
and assertions for its defining behavior. Legacy payload/default support is for
migration and is not sufficient for a new sample.
Read and follow the authoritative hosted-agent cloud E2E test-spec schema and
onboarding checklist.
Run both the documented validate and protocol-aware plan commands before
submitting changes.
Runtime logging
Use the standard logging module for diagnostics emitted by a running hosted
agent. Prefer logger.info(), logger.warning(), and logger.exception() over
print() when output must be observable while the long-running process remains
alive; Python stdout may remain buffered in hosted containers.
Use print() only when stdout is intentionally part of a CLI, provisioning
script, local test utility, or tool-result contract. If stdout is required from a
long-running process, flush it explicitly. E2E log assertions must target a
deliberate sample-owned log event, not mutable framework or dependency wording.
README conventions
Most samples follow the shared template,
README-template.md. It keeps a familiar section flow:
- What this sample demonstrates
- How it works — plus any sample-specific background (e.g. "Environment variables", "Architecture", "Features")
- Prerequisites — what the sample needs: a Foundry project + model deployment, Python 3.10+, and (only if applicable) RBAC roles, extra Azure resources, and environment variables / secrets
- Option 1: Azure Developer CLI (
azd) — init → provision → run → invoke → deploy → invoke-deployed - Option 2: VS Code (Foundry Toolkit) — the one-click F5 run-and-debug flow
(Agent Inspector opens automatically) and/or a manual run (
python main.py) → open the Agent Inspector → deploy - Any sample-specific deep-dive sections (customization, advanced demos, reference)
- Troubleshooting
- Next steps
Conventions worth keeping
- Prefer the current CLI commands (the template reflects these; avoid older
forms such as
azd ext install azure.ai.agents). - Prefer self-contained READMEs over deferring run/deploy steps to a parent
README or hiding steps inside collapsible
<details>blocks. - Keep Toolkit-generated
.vscodelaunch/task files out of the sample; document that the Toolkit creates them in the scaffolded workspace.
When a sample legitimately differs
Not every sample fits the two-option shape, and that's fine — adapt rather than force it:
- Command-line-only samples (e.g. VoiceLive, WebSocket, some A2A samples) may
have no VS Code / Agent Inspector path. Document the flow they actually support
(curl /
azd/ a browser client) and omit Option 2 when it doesn't apply. - Deploy-first samples (e.g. A2A) may lead with deployment instead of a local run. Keep the section order sensible for the scenario.
Use the template for structure and shared vocabulary, and keep whatever sample-specific sections a reader needs.
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.

