Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: XinyueZ/openai-agents-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ff65fb4
Choose a base ref
...
head repository: openai/openai-agents-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5c7c678
Choose a head ref

Commits on Mar 12, 2025

  1. Copy the full SHA
    b381537 View commit details
  2. Copy the full SHA
    87f397d View commit details
  3. Update README.md

    vincentkoc authored Mar 12, 2025
    Copy the full SHA
    d76486e View commit details
  4. Update tracing.md

    vincentkoc authored Mar 12, 2025
    Copy the full SHA
    40dcad3 View commit details
  5. Copy the full SHA
    03869a7 View commit details
  6. Update tracing.md

    vincentkoc authored Mar 12, 2025
    Copy the full SHA
    7e85c03 View commit details

Commits on Mar 13, 2025

  1. Copy the full SHA
    5865c6f View commit details
  2. Copy the full SHA
    cecdcd0 View commit details
  3. Copy the full SHA
    9b972b3 View commit details
  4. Copy the full SHA
    2993d26 View commit details
  5. Linting

    MartinEBravo committed Mar 13, 2025
    Copy the full SHA
    29e9983 View commit details
  6. Copy the full SHA
    333858b View commit details

Commits on Mar 17, 2025

  1. Copy the full SHA
    e984274 View commit details
  2. Copy the full SHA
    47aed7d View commit details
  3. Copy the full SHA
    aff1d60 View commit details

Commits on Mar 18, 2025

  1. Copy the full SHA
    f7c594d View commit details
  2. Copy the full SHA
    6f2f729 View commit details
  3. Copy the full SHA
    c745fe1 View commit details
  4. Copy the full SHA
    53367be View commit details
  5. Copy the full SHA
    39ff00d View commit details
  6. Copy the full SHA
    0079bca View commit details
  7. Copy the full SHA
    b7627cb View commit details
  8. Copy the full SHA
    f4edc1f View commit details

Commits on Mar 19, 2025

  1. Update tests and docs for strict mode decorator (openai#205)

    As titled. Test plan: unit tests/docs.
    rm-openai authored Mar 19, 2025
    Copy the full SHA
    6f7e801 View commit details
  2. Copy the full SHA
    10aa555 View commit details
  3. Copy the full SHA
    bc8369c View commit details
  4. Copy the full SHA
    48ff99b View commit details
  5. Copy the full SHA
    e7c2c19 View commit details
  6. Introduce tool_use_behavior on agents (openai#203)

    ## Context
    By default, the outputs of tools are sent to the LLM again. The LLM gets
    to read the outputs, and produce a new response. There are cases where
    this is not desired:
    1. Every tool results in another round trip, and sometimes the output of
    the tool is enough.
    2. If you force tool use (via model settings `tool_choice=required`),
    then the agent will just infinite loop.
    
    This enables you to have different behavior, e.g. use the first tool
    output as the final output, or write a custom function to process tool
    results and potentially produce an output.
    
    ## Test plan
    Added new tests and ran existing tests
    Also added examples.
    
    
    Closes openai#117
    rm-openai authored Mar 19, 2025
    Copy the full SHA
    6d35c33 View commit details
  7. Copy the full SHA
    8c9974b View commit details
  8. chore(docs): Added comet opik to tracing AND formatted into a list (o…

    …penai#73)
    
    Comet Opik added support for Agent SDK tracing and should be included.
    rm-openai authored Mar 19, 2025
    Copy the full SHA
    545c203 View commit details
  9. Fix breaking changes from openai 1.66.2 (openai#232)

    Breaking change in 1.66.2
    rm-openai authored Mar 19, 2025
    Copy the full SHA
    54cf54c View commit details
  10. v0.0.5

    rm-openai committed Mar 19, 2025
    Copy the full SHA
    1ed181c View commit details
  11. v0.0.5 (openai#241)

    rm-openai authored Mar 19, 2025
    Copy the full SHA
    82754c7 View commit details
  12. add examples section to docs

    jhills20 committed Mar 19, 2025
    Copy the full SHA
    4dd3e21 View commit details
  13. add examples section to docs (openai#242)

    Have gotten feedback that Examples are somewhat buried in the Github
    docs. Adding new page after quickstart.
    rm-openai authored Mar 19, 2025
    Copy the full SHA
    249bb56 View commit details
  14. Copy the full SHA
    d295a53 View commit details
  15. Copy the full SHA
    cef3d53 View commit details

Commits on Mar 20, 2025

  1. Copy the full SHA
    0dec571 View commit details
  2. fix typos in /examples

    0xRaduan committed Mar 20, 2025
    Copy the full SHA
    65264b6 View commit details
  3. fix typos in src/

    0xRaduan committed Mar 20, 2025
    Copy the full SHA
    e9f6d08 View commit details
  4. fix typos in tests

    0xRaduan committed Mar 20, 2025
    Copy the full SHA
    96d1e8a View commit details
  5. Copy the full SHA
    7031d4a View commit details
  6. lint

    alexmojaki committed Mar 20, 2025
    Copy the full SHA
    ea3e8ce View commit details
  7. Copy the full SHA
    fb77c74 View commit details
  8. Copy the full SHA
    cde67f2 View commit details
  9. Copy the full SHA
    9384a0f View commit details
  10. Copy the full SHA
    d169d79 View commit details
  11. Adds example for financial agent (openai#255)

    This example shows how you might compose a richer financial research
    agent using the Agents SDK. The pattern is similar to the `research_bot`
    example, but with more specialized sub‑agents and a verification step.
    
    The flow is:
    
    1. **Planning**: A planner agent turns the end user’s request into a
    list of search terms relevant to financial analysis – recent news,
    earnings calls, corporate filings, industry commentary, etc.
    2. **Search**: A search agent uses the built‑in `WebSearchTool` to
    retrieve terse summaries for each search term. (You could also add
    `FileSearchTool` if you have indexed PDFs or 10‑Ks.)
    3. **Sub‑analysts**: Additional agents (e.g. a fundamentals analyst and
    a risk analyst) are exposed as tools so the writer can call them inline
    and incorporate their outputs.
    4. **Writing**: A writer agent brings together the search snippets and
    any sub‑analyst summaries into a long‑form markdown report plus a short
    executive summary.
    5. **Verification**: A final verifier agent audits the report for
    obvious inconsistencies or missing sourcing.
    rm-openai authored Mar 20, 2025
    Copy the full SHA
    03dc8f7 View commit details
  12. Indentation for mkdocs.yml

    rm-openai committed Mar 20, 2025
    Copy the full SHA
    5c77298 View commit details
Showing with 17,898 additions and 2,000 deletions.
  1. +1 −1 .github/ISSUE_TEMPLATE/feature_request.md
  2. +1 −1 .github/ISSUE_TEMPLATE/question.md
  3. +6 −3 .github/workflows/issues.yml
  4. +4 −2 .github/workflows/tests.yml
  5. +2 −1 .gitignore
  6. +7 −0 .vscode/settings.json
  7. +69 −0 AGENTS.md
  8. +6 −1 Makefile
  9. +6 −3 README.md
  10. +19 −4 docs/agents.md
  11. BIN docs/assets/images/graph.png
  12. BIN docs/assets/images/mcp-tracing.jpg
  13. +1 −1 docs/config.md
  14. +3 −3 docs/context.md
  15. +42 −0 docs/examples.md
  16. +2 −2 docs/guardrails.md
  17. +151 −0 docs/ja/agents.md
  18. +98 −0 docs/ja/config.md
  19. +81 −0 docs/ja/context.md
  20. +45 −0 docs/ja/examples.md
  21. +158 −0 docs/ja/guardrails.md
  22. +117 −0 docs/ja/handoffs.md
  23. +56 −0 docs/ja/index.md
  24. +65 −0 docs/ja/mcp.md
  25. +106 −0 docs/ja/models.md
  26. +116 −0 docs/ja/models/index.md
  27. +77 −0 docs/ja/models/litellm.md
  28. +41 −0 docs/ja/multi_agent.md
  29. +193 −0 docs/ja/quickstart.md
  30. +22 −0 docs/ja/repl.md
  31. +56 −0 docs/ja/results.md
  32. +99 −0 docs/ja/running_agents.md
  33. +91 −0 docs/ja/streaming.md
  34. +299 −0 docs/ja/tools.md
  35. +123 −0 docs/ja/tracing.md
  36. +87 −0 docs/ja/visualization.md
  37. +81 −0 docs/ja/voice/pipeline.md
  38. +198 −0 docs/ja/voice/quickstart.md
  39. +18 −0 docs/ja/voice/tracing.md
  40. +61 −0 docs/mcp.md
  41. +51 −13 docs/{models.md → models/index.md}
  42. +73 −0 docs/models/litellm.md
  43. +2 −2 docs/quickstart.md
  44. +3 −0 docs/ref/extensions/litellm.md
  45. +3 −0 docs/ref/mcp/server.md
  46. +3 −0 docs/ref/mcp/util.md
  47. +6 −0 docs/ref/repl.md
  48. +3 −0 docs/ref/voice/events.md
  49. +3 −0 docs/ref/voice/exceptions.md
  50. +3 −0 docs/ref/voice/input.md
  51. +3 −0 docs/ref/voice/model.md
  52. +3 −0 docs/ref/voice/models/openai_provider.md
  53. +3 −0 docs/ref/voice/models/openai_stt.md
  54. +3 −0 docs/ref/voice/models/openai_tts.md
  55. +3 −0 docs/ref/voice/pipeline.md
  56. +3 −0 docs/ref/voice/pipeline_config.md
  57. +3 −0 docs/ref/voice/result.md
  58. +3 −0 docs/ref/voice/utils.md
  59. +3 −0 docs/ref/voice/workflow.md
  60. +18 −0 docs/release.md
  61. +19 −0 docs/repl.md
  62. +1 −1 docs/running_agents.md
  63. +288 −0 docs/scripts/translate_docs.py
  64. +25 −0 docs/tools.md
  65. +18 −2 docs/tracing.md
  66. +84 −0 docs/visualization.md
  67. +75 −0 docs/voice/pipeline.md
  68. +194 −0 docs/voice/quickstart.md
  69. +14 −0 docs/voice/tracing.md
  70. +99 −0 examples/agent_patterns/forcing_tool_use.py
  71. +1 −1 examples/agent_patterns/input_guardrails.py
  72. +93 −0 examples/agent_patterns/streaming_guardrails.py
  73. +1 −1 examples/basic/lifecycle_example.py
  74. +48 −0 examples/basic/local_image.py
  75. BIN examples/basic/media/image_bison.jpg
  76. +81 −0 examples/basic/non_strict_output_type.py
  77. +66 −0 examples/basic/previous_response_id.py
  78. +31 −0 examples/basic/remote_image.py
  79. +34 −0 examples/basic/tools.py
  80. +38 −0 examples/financial_research_agent/README.md
  81. 0 examples/financial_research_agent/__init__.py
  82. 0 examples/financial_research_agent/agents/__init__.py
  83. +23 −0 examples/financial_research_agent/agents/financials_agent.py
  84. +35 −0 examples/financial_research_agent/agents/planner_agent.py
  85. +22 −0 examples/financial_research_agent/agents/risk_agent.py
  86. +18 −0 examples/financial_research_agent/agents/search_agent.py
  87. +27 −0 examples/financial_research_agent/agents/verifier_agent.py
  88. +34 −0 examples/financial_research_agent/agents/writer_agent.py
  89. +17 −0 examples/financial_research_agent/main.py
  90. +135 −0 examples/financial_research_agent/manager.py
  91. +46 −0 examples/financial_research_agent/printer.py
  92. 0 examples/hosted_mcp/__init__.py
  93. +61 −0 examples/hosted_mcp/approvals.py
  94. +47 −0 examples/hosted_mcp/simple.py
  95. +26 −0 examples/mcp/filesystem_example/README.md
  96. +57 −0 examples/mcp/filesystem_example/main.py
  97. +20 −0 examples/mcp/filesystem_example/sample_files/favorite_books.txt
  98. +4 −0 examples/mcp/filesystem_example/sample_files/favorite_cities.txt
  99. +10 −0 examples/mcp/filesystem_example/sample_files/favorite_songs.txt
  100. +26 −0 examples/mcp/git_example/README.md
  101. +44 −0 examples/mcp/git_example/main.py
  102. +13 −0 examples/mcp/sse_example/README.md
  103. +83 −0 examples/mcp/sse_example/main.py
  104. +33 −0 examples/mcp/sse_example/server.py
  105. +13 −0 examples/mcp/streamablehttp_example/README.md
  106. +83 −0 examples/mcp/streamablehttp_example/main.py
  107. +33 −0 examples/mcp/streamablehttp_example/server.py
  108. +41 −0 examples/model_providers/litellm_auto.py
  109. +55 −0 examples/model_providers/litellm_provider.py
  110. +5 −5 examples/research_bot/agents/search_agent.py
  111. +1 −1 examples/research_bot/manager.py
  112. +1 −1 examples/research_bot/sample_outputs/product_recs.txt
  113. +1 −1 examples/research_bot/sample_outputs/vacation.txt
  114. +34 −0 examples/tools/code_interpreter.py
  115. +5 −3 examples/tools/computer_use.py
  116. +54 −0 examples/tools/image_generator.py
  117. 0 examples/voice/__init__.py
  118. +26 −0 examples/voice/static/README.md
  119. 0 examples/voice/static/__init__.py
  120. +88 −0 examples/voice/static/main.py
  121. +69 −0 examples/voice/static/util.py
  122. +25 −0 examples/voice/streamed/README.md
  123. 0 examples/voice/streamed/__init__.py
  124. +233 −0 examples/voice/streamed/main.py
  125. +81 −0 examples/voice/streamed/my_workflow.py
  126. +189 −107 mkdocs.yml
  127. +31 −15 pyproject.toml
  128. +47 −2 src/agents/__init__.py
  129. +375 −22 src/agents/_run_impl.py
  130. +114 −5 src/agents/agent.py
  131. +58 −8 src/agents/agent_output.py
  132. +38 −5 src/agents/exceptions.py
  133. 0 src/agents/extensions/models/__init__.py
  134. +395 −0 src/agents/extensions/models/litellm_model.py
  135. +21 −0 src/agents/extensions/models/litellm_provider.py
  136. +154 −0 src/agents/extensions/visualization.py
  137. +1 −1 src/agents/function_schema.py
  138. +1 −1 src/agents/handoffs.py
  139. +64 −6 src/agents/items.py
  140. +25 −0 src/agents/mcp/__init__.py
  141. +412 −0 src/agents/mcp/server.py
  142. +136 −0 src/agents/mcp/util.py
  143. +58 −14 src/agents/model_settings.py
  144. +466 −0 src/agents/models/chatcmpl_converter.py
  145. +37 −0 src/agents/models/chatcmpl_helpers.py
  146. +316 −0 src/agents/models/chatcmpl_stream_handler.py
  147. +11 −3 src/agents/models/interface.py
  148. +144 −0 src/agents/models/multi_provider.py
  149. +85 −754 src/agents/models/openai_chatcompletions.py
  150. +13 −0 src/agents/models/openai_provider.py
  151. +74 −25 src/agents/models/openai_responses.py
  152. +1 −0 src/agents/py.typed
  153. +65 −0 src/agents/repl.py
  154. +70 −19 src/agents/result.py
  155. +116 −23 src/agents/run.py
  156. +3 −0 src/agents/stream_events.py
  157. +1 −1 src/agents/strict_schema.py
  158. +153 −12 src/agents/tool.py
  159. +16 −0 src/agents/tracing/__init__.py
  160. +150 −1 src/agents/tracing/create.py
  161. +61 −11 src/agents/tracing/processors.py
  162. +4 −0 src/agents/tracing/scope.py
  163. +3 −0 src/agents/tracing/setup.py
  164. +189 −3 src/agents/tracing/span_data.py
  165. +5 −0 src/agents/tracing/util.py
  166. +21 −1 src/agents/usage.py
  167. +12 −0 src/agents/util/_pretty_print.py
  168. +1 −1 src/agents/version.py
  169. +53 −0 src/agents/voice/__init__.py
  170. +47 −0 src/agents/voice/events.py
  171. +8 −0 src/agents/voice/exceptions.py
  172. +11 −0 src/agents/voice/imports.py
  173. +88 −0 src/agents/voice/input.py
  174. +194 −0 src/agents/voice/model.py
  175. 0 src/agents/voice/models/__init__.py
  176. +97 −0 src/agents/voice/models/openai_model_provider.py
  177. +456 −0 src/agents/voice/models/openai_stt.py
  178. +54 −0 src/agents/voice/models/openai_tts.py
  179. +151 −0 src/agents/voice/pipeline.py
  180. +46 −0 src/agents/voice/pipeline_config.py
  181. +287 −0 src/agents/voice/result.py
  182. +37 −0 src/agents/voice/utils.py
  183. +93 −0 src/agents/voice/workflow.py
  184. +48 −8 tests/fake_model.py
  185. 0 tests/fastapi/__init__.py
  186. +30 −0 tests/fastapi/streaming_app.py
  187. +29 −0 tests/fastapi/test_streaming_context.py
  188. 0 tests/mcp/__init__.py
  189. +11 −0 tests/mcp/conftest.py
  190. +58 −0 tests/mcp/helpers.py
  191. +57 −0 tests/mcp/test_caching.py
  192. +69 −0 tests/mcp/test_connect_disconnect.py
  193. +216 −0 tests/mcp/test_mcp_tracing.py
  194. +291 −0 tests/mcp/test_mcp_util.py
  195. +197 −0 tests/mcp/test_runner_calls_mcp.py
  196. +42 −0 tests/mcp/test_server_errors.py
  197. +59 −0 tests/model_settings/test_serialization.py
  198. 0 tests/models/__init__.py
  199. +11 −0 tests/models/conftest.py
  200. +298 −0 tests/models/test_litellm_chatcompletions_stream.py
  201. +44 −0 tests/models/test_litellm_extra_body.py
  202. +20 −0 tests/models/test_map.py
  203. +3 −2 tests/test_agent_config.py
  204. +2 −2 tests/test_agent_hooks.py
  205. +228 −0 tests/test_agent_runner.py
  206. +38 −1 tests/test_agent_runner_streamed.py
  207. +148 −62 tests/test_agent_tracing.py
  208. +116 −0 tests/test_cancel_streaming.py
  209. +100 −0 tests/test_extra_headers.py
  210. +13 −2 tests/test_function_schema.py
  211. +44 −3 tests/test_function_tool.py
  212. +47 −4 tests/test_function_tool_decorator.py
  213. +2 −2 tests/test_global_hooks.py
  214. +6 −6 tests/test_items_helpers.py
  215. +94 −5 tests/test_openai_chatcompletions.py
  216. +38 −38 tests/test_openai_chatcompletions_converter.py
  217. +17 −2 tests/test_openai_chatcompletions_stream.py
  218. +1 −1 tests/test_openai_responses_converter.py
  219. +56 −3 tests/test_output_tool.py
  220. +28 −0 tests/test_repl.py
  221. +127 −38 tests/test_responses_tracing.py
  222. +2 −1 tests/test_result_cast.py
  223. +48 −0 tests/test_run_error_details.py
  224. +11 −10 tests/test_run_step_execution.py
  225. +98 −38 tests/test_run_step_processing.py
  226. +210 −0 tests/test_tool_choice_reset.py
  227. +5 −5 tests/test_tool_converter.py
  228. +194 −0 tests/test_tool_use_behavior.py
  229. +143 −142 tests/test_tracing.py
  230. +23 −88 tests/test_tracing_errors.py
  231. +12 −175 tests/test_tracing_errors_streamed.py
  232. +52 −0 tests/test_usage.py
  233. +151 −0 tests/test_visualization.py
  234. +23 −5 tests/testing_processor.py
  235. +27 −0 tests/tracing/test_processor_api_key.py
  236. 0 tests/voice/__init__.py
  237. +11 −0 tests/voice/conftest.py
  238. +115 −0 tests/voice/fake_models.py
  239. +21 −0 tests/voice/helpers.py
  240. +127 −0 tests/voice/test_input.py
  241. +367 −0 tests/voice/test_openai_stt.py
  242. +94 −0 tests/voice/test_openai_tts.py
  243. +179 −0 tests/voice/test_pipeline.py
  244. +194 −0 tests/voice/test_workflow.py
  245. +1,803 −264 uv.lock
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ assignees: ''
### Please read this first

- **Have you read the docs?**[Agents SDK docs](https://openai.github.io/openai-agents-python/)
- **Have you searched for related issues?** Others may have had similar requesrs
- **Have you searched for related issues?** Others may have had similar requests

### Describe the feature
What is the feature you're requesting? How would it work? Please provide examples and details if possible.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ assignees: ''
### Please read this first

- **Have you read the docs?**[Agents SDK docs](https://openai.github.io/openai-agents-python/)
- **Have you searched for related issues?** Others may have had similar requesrs
- **Have you searched for related issues?** Others may have had similar requests

### Question
Describe your question. Provide details if available.
9 changes: 6 additions & 3 deletions .github/workflows/issues.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,10 @@ jobs:
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 7 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 3 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
any-of-labels: 'question,needs-more-info'
any-of-issue-labels: 'question,needs-more-info'
days-before-pr-stale: 10
days-before-pr-close: 7
stale-pr-label: "stale"
stale-pr-message: "This PR is stale because it has been open for 10 days with no activity."
close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale."
repo-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@ on:
branches:
- main
pull_request:
branches:
- main
# All PRs, including stacked PRs

env:
UV_FROZEN: "1"

jobs:
lint:
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -135,10 +135,11 @@ dmypy.json
cython_debug/

# PyCharm
#.idea/
.idea/

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc
.aider*
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
69 changes: 69 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Welcome to the OpenAI Agents SDK repository. This file contains the main points for new contributors.

## Repository overview

- **Source code**: `src/agents/` contains the implementation.
- **Tests**: `tests/` with a short guide in `tests/README.md`.
- **Examples**: under `examples/`.
- **Documentation**: markdown pages live in `docs/` with `mkdocs.yml` controlling the site.
- **Utilities**: developer commands are defined in the `Makefile`.
- **PR template**: `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md` describes the information every PR must include.

## Local workflow

1. Format, lint and type‑check your changes:

```bash
make format
make lint
make mypy
```

2. Run the tests:

```bash
make tests
```

To run a single test, use `uv run pytest -s -k <test_name>`.

3. Build the documentation (optional but recommended for docs changes):

```bash
make build-docs
```

Coverage can be generated with `make coverage`.

## Snapshot tests

Some tests rely on inline snapshots. See `tests/README.md` for details on updating them:

```bash
make snapshots-fix # update existing snapshots
make snapshots-create # create new snapshots
```

Run `make tests` again after updating snapshots to ensure they pass.

## Style notes

- Write comments as full sentences and end them with a period.

## Pull request expectations

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:

- New tests are added when needed.
- Documentation is updated.
- `make lint` and `make format` have been run.
- The full test suite passes.

Commit messages should be concise and written in the imperative mood. Small, focused commits are preferred.

## What reviewers look for

- Tests covering new behaviour.
- Consistent style: code formatted with `ruff format`, imports sorted, and type hints passing `mypy`.
- Clear documentation for any public API changes.
- Clean history and a helpful PR description.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ sync:
.PHONY: format
format:
uv run ruff format
uv run ruff check --fix

.PHONY: lint
lint:
@@ -36,12 +37,16 @@ snapshots-create:
.PHONY: old_version_tests
old_version_tests:
UV_PROJECT_ENVIRONMENT=.venv_39 uv run --python 3.9 -m pytest
UV_PROJECT_ENVIRONMENT=.venv_39 uv run --python 3.9 -m mypy .

.PHONY: build-docs
build-docs:
uv run mkdocs build

.PHONY: build-full-docs
build-full-docs:
uv run docs/scripts/translate_docs.py
uv run mkdocs build

.PHONY: serve-docs
serve-docs:
uv run mkdocs serve
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# OpenAI Agents SDK

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. It is provider-agnostic, supporting the OpenAI Responses and Chat Completions APIs, as well as 100+ other LLMs.

<img src="https://cdn.openai.com/API/docs/images/orchestration.png" alt="Image of the Agents Tracing UI" style="max-height: 803px;">

> [!NOTE]
> Looking for the JavaScript/TypeScript version? Check out [Agents SDK JS/TS](https://github.com/openai/openai-agents-js).
### Core concepts:

1. [**Agents**](https://openai.github.io/openai-agents-python/agents): LLMs configured with instructions, tools, guardrails, and handoffs
@@ -13,8 +16,6 @@ The OpenAI Agents SDK is a lightweight yet powerful framework for building multi

Explore the [examples](examples) directory to see the SDK in action, and read our [documentation](https://openai.github.io/openai-agents-python/) for more details.

Notably, our SDK [is compatible](https://openai.github.io/openai-agents-python/models/) with any model providers that support the OpenAI Chat Completions API format.

## Get started

1. Set up your Python environment
@@ -30,6 +31,8 @@ source env/bin/activate
pip install openai-agents
```

For voice support, install with the optional `voice` group: `pip install 'openai-agents[voice]'`.

## Hello world example

```python
23 changes: 19 additions & 4 deletions docs/agents.md
Original file line number Diff line number Diff line change
@@ -32,11 +32,11 @@ Agents are generic on their `context` type. Context is a dependency-injection to
```python
@dataclass
class UserContext:
uid: str
is_pro_user: bool
uid: str
is_pro_user: bool

async def fetch_purchases() -> list[Purchase]:
return ...
async def fetch_purchases() -> list[Purchase]:
return ...

agent = Agent[UserContext](
...,
@@ -130,3 +130,18 @@ robot_agent = pirate_agent.clone(
instructions="Write like a robot",
)
```

## Forcing tool use

Supplying a list of tools doesn't always mean the LLM will use a tool. You can force tool use by setting [`ModelSettings.tool_choice`][agents.model_settings.ModelSettings.tool_choice]. Valid values are:

1. `auto`, which allows the LLM to decide whether or not to use a tool.
2. `required`, which requires the LLM to use a tool (but it can intelligently decide which tool).
3. `none`, which requires the LLM to _not_ use a tool.
4. Setting a specific string e.g. `my_tool`, which requires the LLM to use that specific tool.

!!! note

To prevent infinite loops, the framework automatically resets `tool_choice` to "auto" after a tool call. This behavior is configurable via [`agent.reset_tool_choice`][agents.agent.Agent.reset_tool_choice]. The infinite loop is because tool results are sent to the LLM, which then generates another tool call because of `tool_choice`, ad infinitum.

If you want the Agent to completely stop after a tool call (rather than continuing with auto mode), you can set [`Agent.tool_use_behavior="stop_on_first_tool"`] which will directly use the tool output as the final response without further LLM processing.
Binary file added docs/assets/images/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/mcp-tracing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ Alternatively, you can customize the logs by adding handlers, filters, formatter
```python
import logging

logger = logging.getLogger("openai.agents") # or openai.agents.tracing for the Tracing logger
logger = logging.getLogger("openai.agents") # or openai.agents.tracing for the Tracing logger

# To make all logs show up
logger.setLevel(logging.DEBUG)
6 changes: 3 additions & 3 deletions docs/context.md
Original file line number Diff line number Diff line change
@@ -41,14 +41,14 @@ async def fetch_user_age(wrapper: RunContextWrapper[UserInfo]) -> str: # (2)!
return f"User {wrapper.context.name} is 47 years old"

async def main():
user_info = UserInfo(name="John", uid=123) # (3)!
user_info = UserInfo(name="John", uid=123)

agent = Agent[UserInfo]( # (4)!
agent = Agent[UserInfo]( # (3)!
name="Assistant",
tools=[fetch_user_age],
)

result = await Runner.run(
result = await Runner.run( # (4)!
starting_agent=agent,
input="What is the age of the user?",
context=user_info,
42 changes: 42 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Examples

Check out a variety of sample implementations of the SDK in the examples section of the [repo](https://github.com/openai/openai-agents-python/tree/main/examples). The examples are organized into several categories that demonstrate different patterns and capabilities.


## Categories

- **[agent_patterns](https://github.com/openai/openai-agents-python/tree/main/examples/agent_patterns):**
Examples in this category illustrate common agent design patterns, such as

- Deterministic workflows
- Agents as tools
- Parallel agent execution

- **[basic](https://github.com/openai/openai-agents-python/tree/main/examples/basic):**
These examples showcase foundational capabilities of the SDK, such as

- Dynamic system prompts
- Streaming outputs
- Lifecycle events

- **[tool examples](https://github.com/openai/openai-agents-python/tree/main/examples/tools):**
Learn how to implement OAI hosted tools such as web search and file search,
and integrate them into your agents.

- **[model providers](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers):**
Explore how to use non-OpenAI models with the SDK.

- **[handoffs](https://github.com/openai/openai-agents-python/tree/main/examples/handoffs):**
See practical examples of agent handoffs.

- **[mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp):**
Learn how to build agents with MCP.

- **[customer_service](https://github.com/openai/openai-agents-python/tree/main/examples/customer_service)** and **[research_bot](https://github.com/openai/openai-agents-python/tree/main/examples/research_bot):**
Two more built-out examples that illustrate real-world applications

- **customer_service**: Example customer service system for an airline.
- **research_bot**: Simple deep research clone.

- **[voice](https://github.com/openai/openai-agents-python/tree/main/examples/voice):**
See examples of voice agents, using our TTS and STT models.
4 changes: 2 additions & 2 deletions docs/guardrails.md
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ Output guardrails run in 3 steps:

!!! Note

Output guardrails are intended to run on the final agent input, so an agent's guardrails only run if the agent is the *last* agent. Similar to the input guardrails, we do this because guardrails tend to be related to the actual Agent - you'd run different guardrails for different agents, so colocating the code is useful for readability.
Output guardrails are intended to run on the final agent output, so an agent's guardrails only run if the agent is the *last* agent. Similar to the input guardrails, we do this because guardrails tend to be related to the actual Agent - you'd run different guardrails for different agents, so colocating the code is useful for readability.

## Tripwires

@@ -111,8 +111,8 @@ class MessageOutput(BaseModel): # (1)!
response: str

class MathOutput(BaseModel): # (2)!
is_math: bool
reasoning: str
is_math: bool

guardrail_agent = Agent(
name="Guardrail check",
Loading