teams.py
Copilot instructions67 starsChanged 6 months agoMITView on GitHub
Microsoft Teams SDK for Python is a comprehensive SDK for building Microsoft Teams applications, bots, and AI agents using Python. This is a monorepo with workspace structure containing core packages and test applications. Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. ALWAYS manually validate changes by running at least one complete test application scenario:
- Installs packages
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
14 rules. About 0 are common, 5 are distinctive, and 9 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.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 76
Start the app: python src/main.py
- Very specific: line 122
Validate with test app: Use examples/echo for basic functionality validation (starts a blocking server process)
- Very specific: line 126
Consider mocking carefully.
- Distinctive: line 130
Hot reload: No hot reload - restart apps after changes
- Distinctive: line 131
Port conflicts: Default port is 3978 (main)
- Very specific: line 146
Network restrictions: Use python -m pip install uv instead of curl-based installation
- Very specific: line 148
Pre-commit hook installation may timeout: If pre-commit install fails with PyPI timeout, use git commit --no-verify for urgent commits
- Very specific: line 151
Import errors: Ensure virtual environment is activated (source .venv/bin/activate) or use uv run commands
- Very specific: line 153
Test failures: Run uv sync --all-packages --group dev to update dependencies
- Very specific: line 154
Type errors: Run pyright to catch type issues before CI
- Very specific: line 155
Format issues: Run ruff format to auto-fix formatting
- Distinctive: line 156
Pre-commit hook timeouts: Use git commit --no-verify to bypass hooks temporarily during network issues
- Distinctive: line 162
ALWAYS activate virtual environment or use uv run: before running Python commands
- Distinctive: line 163
ALWAYS validate with a test app: after making changes to core packages
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
Microsoft Teams SDK for Python
Microsoft Teams SDK for Python is a comprehensive SDK for building Microsoft Teams applications, bots, and AI agents using Python. This is a monorepo with workspace structure containing core packages and test applications.
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
Working Effectively
Prerequisites and Setup
- Install UV:
python -m pip install uv(curl method fails due to network restrictions) - Python version: 3.11+ (confirmed working with 3.11, 3.12, 3.13, and 3.14 in CI)
- Verify versions:
uv --version && python --version
Bootstrap, Build, and Test Repository
CRITICAL TIMING NOTES: NEVER CANCEL any build or test commands. Set timeouts appropriately:
- Install dependencies (8 seconds - set timeout to 60+ seconds):
uv sync --all-packages --group dev - Activate virtual environment (instant) or use
uv runfor commands:# On Linux/Mac source .venv/bin/activate # On Windows .venv\Scripts\Activate # Alternative: Use uv run (no activation needed) # Example: uv run pytest packages - Install pre-commit hooks (<1 second):
pre-commit install - Run linting (<1 second - 376 files checked):
ruff check - Run formatting check (<1 second):
ruff format --check - Run type checking (9 seconds - set timeout to 30+ seconds):
pyright - Run tests (18 seconds - 337 tests - set timeout to 60+ seconds):
pytest packages - Build all packages (3 seconds - set timeout to 60+ seconds):
uv build --all-packages
Quick Development Commands
- Combined format + lint:
poe check(<1 second) - Format code:
poe fmtorruff format - Lint only:
poe lintorruff check - Test only:
poe testorpytest packages
Validation Scenarios
ALWAYS manually validate changes by running at least one complete test application scenario:
Basic Teams App Validation
- Navigate to test app:
cd examples/echo - Start the app:
python src/main.py - Expected output: App starts on port 3978 with logs:
[INFO] Teams app started successfully - Test endpoints:
- Health check:
curl http://localhost:3978/(returns{"status":"healthy","port":3978})
- Health check:
- Stop with Ctrl+C
Required Pre-commit Validation
ALWAYS run before committing changes or CI will fail:
# These commands must pass:
ruff format --check # Format validation
ruff check # Linting validation
pyright # Type checking validationRepository Structure and Navigation
Core Packages (/packages)
- microsoft-teams-apps: Main application framework
- microsoft-teams-api: Teams API client
- microsoft-teams-cards: Adaptive cards support
- microsoft-teams-common: Shared utilities
- microsoft-teams-graph: Microsoft Graph integration
- microsoft-teams-botbuilder: Bot Framework integration plugin
Test Applications (/examples)
Available test apps for development and validation:
- echo: Basic message echo bot (recommended for quick validation)
- dialogs: Dialog handling examples
- message-extensions: Message extension samples
- oauth: OAuth authentication examples
- graph: Microsoft Graph integration examples
- stream: Streaming functionality examples
Creating New Components
- New package:
cookiecutter templates/package -o packages - New test app:
cookiecutter templates/examples -o examples
Common Development Tasks
Testing Changes
- Run commands with UV (recommended): Use
uv run pytest packages/[package-name]or activate virtual environment:source .venv/bin/activate - Run affected tests:
pytest packages/[package-name]for specific package (oruv run pytest packages/[package-name]) - Validate with test app: Use
examples/echofor basic functionality validation (starts a blocking server process)
Test Quality
- Tests should be thoughtfully created to exercise the intended purpose, not just to turn green. When possible, do red-green tests: confirm the test fails when the behavior is wrong and passes when it is right, so it actually guards the behavior it claims to.
- Consider mocking carefully. The goal is to guard against regressions for the intended behavior, so mocks should mirror the real contract (types, shapes, and edge values like
None) rather than a simplified stand-in that a broken implementation could still satisfy.
Debugging and Development
- Logging: Apps provide structured logging for debugging
- Hot reload: No hot reload - restart apps after changes
- Port conflicts: Default port is 3978 (main)
CI/CD Integration
The CI pipeline (.github/workflows/ci.yml) runs:
- Dependency installation with UV
- Ruff linting and formatting validation
- PyRight type checking
- Full test suite execution
Match CI requirements locally with: poe check && pyright && pytest packages
Troubleshooting
Known Issues
- generate-activity-handlers command fails: Path bug exists but doesn't affect normal development workflow
- Network restrictions: Use
python -m pip install uvinstead of curl-based installation - Build timeouts: UV operations are fast (3-18 seconds) but use generous timeouts for reliability
- Pre-commit hook installation may timeout: If
pre-commit installfails with PyPI timeout, usegit commit --no-verifyfor urgent commits
Common Problems
- Import errors: Ensure virtual environment is activated (
source .venv/bin/activate) or useuv runcommands - UV not found: Install with pip:
python -m pip install uv - Test failures: Run
uv sync --all-packages --group devto update dependencies - Type errors: Run
pyrightto catch type issues before CI - Format issues: Run
ruff formatto auto-fix formatting - Pre-commit hook timeouts: Use
git commit --no-verifyto bypass hooks temporarily during network issues
Critical Reminders
- NEVER CANCEL builds or tests - Commands complete in 3-18 seconds but network delays may occur
- ALWAYS use timeouts of 60+ seconds for any UV or build commands
- ALWAYS activate virtual environment or use uv run before running Python commands
- ALWAYS validate with a test app after making changes to core packages
- ALWAYS run pre-commit validation (
poe check && pyright) before committing - KEEP filesystem code and tests cross-platform - Release validation runs on Windows and Linux. Use
pathlibor path APIs, specify text encodings explicitly (normally UTF-8), and avoid locale-specific or Unix-only filesystem behavior. - NEVER skip manual testing - Automated tests don't cover integration scenarios
Repository Quick Reference
Package Root Structure
.
├── .github/ # GitHub workflows and configs
├── packages/ # Core SDK packages
├── tests/ # Test applications
├── templates/ # Cookiecutter templates
├── scripts/ # Build and release scripts
├── pyproject.toml # Workspace and tool configuration
├── uv.lock # Dependency lock file
└── README.md # Main documentationEssential Files
- pyproject.toml: Workspace configuration, dependencies, tool settings
- uv.lock: Locked dependency versions (do not edit manually)
- .pre-commit-config.yaml: Git hook configuration
- .github/workflows/ci.yml: CI pipeline definition
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.

