|
1 | | -Welcome to the OpenAI Agents SDK repository. This file contains the main points for new contributors. |
| 1 | +# Contributor Guide |
2 | 2 |
|
3 | | -## Repository overview |
| 3 | +This guide helps new contributors get started with the OpenAI Agents Python repository. It covers repo structure, how to test your work, available utilities, and guidelines for commits and PRs. |
4 | 4 |
|
5 | | -- **Source code**: `src/agents/` contains the implementation. |
6 | | -- **Tests**: `tests/` with a short guide in `tests/README.md`. |
7 | | -- **Examples**: under `examples/`. |
8 | | -- **Documentation**: markdown pages live in `docs/` with `mkdocs.yml` controlling the site. Translated docs under `docs/ja`, `docs/ko`, and `docs/zh` are managed by an automated job; do not edit them manually. |
9 | | -- **Utilities**: developer commands are defined in the `Makefile`. |
10 | | -- **PR template**: `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md` describes the information every PR must include. |
| 5 | +**Location:** `AGENTS.md` at the repository root. |
11 | 6 |
|
12 | | -## Agent requirements |
| 7 | +## Table of Contents |
13 | 8 |
|
14 | | -- Always invoke `$verify-changes` before completing any work. The skill encapsulates the required formatting, linting, type-checking, and tests; follow `.codex/skills/verify-changes/SKILL.md` for how to run it. |
| 9 | +1. [Mandatory Skill Usage](#mandatory-skill-usage) |
| 10 | +2. [Overview](#overview) |
| 11 | +3. [Repo Structure & Important Files](#repo-structure--important-files) |
| 12 | +4. [Testing & Automated Checks](#testing--automated-checks) |
| 13 | +5. [Repo-Specific Utilities](#repo-specific-utilities) |
| 14 | +6. [Style, Linting & Type Checking](#style-linting--type-checking) |
| 15 | +7. [Development Workflow](#development-workflow) |
| 16 | +8. [Pull Request & Commit Guidelines](#pull-request--commit-guidelines) |
| 17 | +9. [Review Process & What Reviewers Look For](#review-process--what-reviewers-look-for) |
| 18 | +10. [Tips for Navigating the Repo](#tips-for-navigating-the-repo) |
| 19 | +11. [Prerequisites](#prerequisites) |
15 | 20 |
|
16 | | -## Planning guidance |
| 21 | +## Mandatory Skill Usage |
17 | 22 |
|
18 | | -- Before starting work, surface any potential backward compatibility risks in your implementation plan and confirm the approach when breaking changes could affect existing users. |
| 23 | +### `$code-change-verification` |
19 | 24 |
|
20 | | -## Local workflow |
| 25 | +Run `$code-change-verification` before marking work complete when changes affect runtime code, tests, or build/test behavior. |
21 | 26 |
|
22 | | -1. Run `$verify-changes` before handing off work; it formats, lints, type-checks, and runs the test suite (see `.codex/skills/verify-changes/SKILL.md` for the workflow). |
23 | | -2. To run a single test, use `uv run pytest -s -k <test_name>`. |
24 | | -3. Build the documentation when you touch docs: `make build-docs`. |
| 27 | +Run it when you change: |
| 28 | +- `src/agents/` (library code) or shared utilities. |
| 29 | +- `tests/` or add or modify snapshot tests. |
| 30 | +- `examples/`. |
| 31 | +- Build or test configuration such as `pyproject.toml`, `Makefile`, `mkdocs.yml`, `docs/scripts/`, or CI workflows. |
25 | 32 |
|
26 | | -Coverage can be generated with `make coverage`. |
| 33 | +You can skip `$code-change-verification` for docs-only or repo-meta changes (for example, `docs/`, `.codex/`, `README.md`, `AGENTS.md`, `.github/`), unless a user explicitly asks to run the full verification stack. |
27 | 34 |
|
28 | | -All python commands should be run via `uv run python ...` |
| 35 | +### `$openai-knowledge` |
29 | 36 |
|
30 | | -## Snapshot tests |
| 37 | +When working on OpenAI API or OpenAI platform integrations in this repo (Responses API, tools, streaming, Realtime API, auth, models, rate limits, MCP, Agents SDK or ChatGPT Apps SDK), use `$openai-knowledge` to pull authoritative docs via the OpenAI Developer Docs MCP server (and guide setup if it is not configured). |
31 | 38 |
|
32 | | -Some tests rely on inline snapshots. See `tests/README.md` for details on updating them: |
| 39 | +### Planning expectations |
33 | 40 |
|
34 | | -```bash |
35 | | -make snapshots-fix # update existing snapshots |
36 | | -make snapshots-create # create new snapshots |
37 | | -``` |
| 41 | +Call out potential backward compatibility or public API risks early in your plan and confirm the approach before implementing changes that could impact users. |
| 42 | + |
| 43 | +## Overview |
| 44 | + |
| 45 | +The OpenAI Agents Python repository provides the Python Agents SDK, examples, and documentation built with MkDocs. Use `uv run python ...` for Python commands to ensure a consistent environment. |
| 46 | + |
| 47 | +## Repo Structure & Important Files |
| 48 | + |
| 49 | +- `src/agents/`: Core library implementation. |
| 50 | +- `tests/`: Test suite; see `tests/README.md` for snapshot guidance. |
| 51 | +- `examples/`: Sample projects showing SDK usage. |
| 52 | +- `docs/`: MkDocs documentation source; do not edit translated docs under `docs/ja`, `docs/ko`, or `docs/zh` (they are generated). |
| 53 | +- `docs/scripts/`: Documentation utilities, including translation and reference generation. |
| 54 | +- `mkdocs.yml`: Documentation site configuration. |
| 55 | +- `Makefile`: Common developer commands. |
| 56 | +- `pyproject.toml`, `uv.lock`: Python dependencies and tool configuration. |
| 57 | +- `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md`: Pull request template to use when opening PRs. |
| 58 | +- `site/`: Built documentation output. |
| 59 | + |
| 60 | +## Testing & Automated Checks |
38 | 61 |
|
39 | | -Run `make tests` again after updating snapshots to ensure they pass. |
| 62 | +Before submitting changes, ensure relevant checks pass and extend tests when you touch code. |
40 | 63 |
|
41 | | -## Style notes |
| 64 | +When `$code-change-verification` applies, run it to execute the required verification stack from the repository root. Rerun the full stack after applying fixes. |
42 | 65 |
|
43 | | -- Write comments as full sentences and end them with a period. |
| 66 | +### Unit tests and type checking |
44 | 67 |
|
45 | | -## Pull request expectations |
| 68 | +- Run the full test suite: |
| 69 | + ```bash |
| 70 | + make tests |
| 71 | + ``` |
| 72 | +- Run a focused test: |
| 73 | + ```bash |
| 74 | + uv run pytest -s -k <pattern> |
| 75 | + ``` |
| 76 | +- Type checking: |
| 77 | + ```bash |
| 78 | + make mypy |
| 79 | + ``` |
46 | 80 |
|
47 | | -PRs should use the template located at `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md`. Provide a summary, test plan and issue number if applicable, then check that: |
| 81 | +### Snapshot tests |
48 | 82 |
|
49 | | -- New tests are added when needed. |
50 | | -- Documentation is updated. |
51 | | -- `make lint` and `make format` have been run. |
52 | | -- The full test suite passes. |
| 83 | +Some tests rely on inline snapshots; see `tests/README.md` for details. Re-run `make tests` after updating snapshots. |
53 | 84 |
|
54 | | -Commit messages should be concise and written in the imperative mood. Small, focused commits are preferred. |
| 85 | +- Fix snapshots: |
| 86 | + ```bash |
| 87 | + make snapshots-fix |
| 88 | + ``` |
| 89 | +- Create new snapshots: |
| 90 | + ```bash |
| 91 | + make snapshots-create |
| 92 | + ``` |
55 | 93 |
|
56 | | -## What reviewers look for |
| 94 | +### Coverage |
| 95 | + |
| 96 | +- Generate coverage (fails if coverage drops below threshold): |
| 97 | + ```bash |
| 98 | + make coverage |
| 99 | + ``` |
| 100 | + |
| 101 | +### Mandatory local run order |
| 102 | + |
| 103 | +When `$code-change-verification` applies, run the full sequence in order (or use the skill scripts): |
| 104 | + |
| 105 | +```bash |
| 106 | +make format |
| 107 | +make lint |
| 108 | +make mypy |
| 109 | +make tests |
| 110 | +``` |
57 | 111 |
|
58 | | -- Tests covering new behaviour. |
59 | | -- Consistent style: code formatted with `uv run ruff format`, imports sorted, and type hints passing `uv run mypy .`. |
60 | | -- Clear documentation for any public API changes. |
61 | | -- Clean history and a helpful PR description. |
| 112 | +## Repo-Specific Utilities |
| 113 | + |
| 114 | +- Install or refresh development dependencies: |
| 115 | + ```bash |
| 116 | + make sync |
| 117 | + ``` |
| 118 | +- Run tests against Python 3.9 in an isolated environment: |
| 119 | + ```bash |
| 120 | + make old_version_tests |
| 121 | + ``` |
| 122 | +- Documentation workflows: |
| 123 | + ```bash |
| 124 | + make build-docs # build docs after editing docs |
| 125 | + make serve-docs # preview docs locally |
| 126 | + make build-full-docs # run translations and build |
| 127 | + ``` |
| 128 | +- Snapshot helpers: |
| 129 | + ```bash |
| 130 | + make snapshots-fix |
| 131 | + make snapshots-create |
| 132 | + ``` |
| 133 | + |
| 134 | +## Style, Linting & Type Checking |
| 135 | + |
| 136 | +- Formatting and linting use `ruff`; run `make format` (applies fixes) and `make lint` (checks only). |
| 137 | +- Type hints must pass `make mypy`. |
| 138 | +- Write comments as full sentences ending with a period. |
| 139 | +- Imports are managed by Ruff and should stay sorted. |
| 140 | + |
| 141 | +## Development Workflow |
| 142 | + |
| 143 | +1. Sync with `main` and create a feature branch: |
| 144 | + ```bash |
| 145 | + git checkout -b feat/<short-description> |
| 146 | + ``` |
| 147 | +2. If dependencies changed or you are setting up the repo, run `make sync`. |
| 148 | +3. Implement changes and add or update tests alongside code updates. |
| 149 | +4. Highlight backward compatibility or API risks in your plan before implementing breaking or user-facing changes. |
| 150 | +5. Build docs when you touch documentation: |
| 151 | + ```bash |
| 152 | + make build-docs |
| 153 | + ``` |
| 154 | +6. When `$code-change-verification` applies, run it to execute the full verification stack before handoff. |
| 155 | +7. Commit with concise, imperative messages; keep commits small and focused, then open a pull request. |
| 156 | +8. When reporting code changes as complete, include what you changed plus a draft pull request title and description for your local changes; start the description with prose such as “This pull request resolves/updates/adds …” using a verb that matches the change (you can use bullets later), explain the change background (for bugs, clearly describe the bug, symptoms, or repro; for features, what is needed and why), any behavior changes or considerations to be aware of, and you do not need to mention tests you ran. |
| 157 | + |
| 158 | +## Pull Request & Commit Guidelines |
| 159 | + |
| 160 | +- Use the template at `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md`; include a summary, test plan, and issue number if applicable. |
| 161 | +- Add tests for new behavior when feasible and update documentation for user-facing changes. |
| 162 | +- Run `make format`, `make lint`, `make mypy`, and `make tests` before marking work ready. |
| 163 | +- Commit messages should be concise and written in the imperative mood. Small, focused commits are preferred. |
| 164 | + |
| 165 | +## Review Process & What Reviewers Look For |
| 166 | + |
| 167 | +- ✅ Checks pass (`make format`, `make lint`, `make mypy`, `make tests`). |
| 168 | +- ✅ Tests cover new behavior and edge cases. |
| 169 | +- ✅ Code is readable, maintainable, and consistent with existing style. |
| 170 | +- ✅ Public APIs and user-facing behavior changes are documented. |
| 171 | +- ✅ Examples are updated if behavior changes. |
| 172 | +- ✅ History is clean with a clear PR description. |
| 173 | + |
| 174 | +## Tips for Navigating the Repo |
| 175 | + |
| 176 | +- Use `examples/` to see common SDK usage patterns. |
| 177 | +- Review `Makefile` for common commands and use `uv run` for Python invocations. |
| 178 | +- Explore `docs/` and `docs/scripts/` to understand the documentation pipeline. |
| 179 | +- Consult `tests/README.md` for test and snapshot workflows. |
| 180 | +- Check `mkdocs.yml` to understand how docs are organized. |
| 181 | + |
| 182 | +## Prerequisites |
| 183 | + |
| 184 | +- Python 3.9+. |
| 185 | +- `uv` installed for dependency management (`uv sync`) and `uv run` for Python commands. |
| 186 | +- `make` available to run repository tasks. |
0 commit comments