with one click
python-samples
Guidelines for creating and modifying sample code in the Agent Framework Python codebase. Use this when writing new samples or updating existing ones.
Menu
Guidelines for creating and modifying sample code in the Agent Framework Python codebase. Use this when writing new samples or updating existing ones.
How to use the verify-samples tool to run, verify, and manage sample definitions in the Agent Framework repository. Use this when adding, updating, or running sample verification.
Coding standards, conventions, and patterns for developing Python code in the Agent Framework repository. Use this when writing or modifying Python source files in the python/ directory.
Validate, test, and debug regular expressions by executing them against sample inputs. Use when asked to build, verify, or explain a regex pattern.
When and how to escalate Contoso Outdoors customer-support tickets.
Contoso Outdoors customer-support tone and formatting guidelines.
Convert between common units using a multiplication factor. Use when asked to convert miles, kilometers, pounds, or kilograms.
| name | python-samples |
| description | Guidelines for creating and modifying sample code in the Agent Framework Python codebase. Use this when writing new samples or updating existing ones. |
Every sample file follows this order:
# Copyright (c) Microsoft. All rights reserved."""This sample demonstrates..."""if __name__ == "__main__": asyncio.run(main())Use PEP 723 inline script metadata for external packages not in the dev environment:
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "some-external-package",
# ]
# ///
# Run with: uv run samples/path/to/script.py
# Copyright (c) Microsoft. All rights reserved.
Do not add sample-only dependencies to the root pyproject.toml dev group.
# Format + lint samples
uv run poe syntax -S
# Check samples for syntax errors and missing imports
uv run poe pyright -S
# Lint samples only
uv run poe syntax -S -C
Samples should be over-documented:
# 1. Create the client instance.
...
# 2. Create the agent with the client.
...
"""
Sample output:
User:> Why is the sky blue?
Assistant:> The sky is blue due to Rayleigh scattering...
"""
step<number>_<name>.py