Commit graph

103 commits

Author SHA1 Message Date
Javier Leguina
dcb88e69cd
docs: custom output extraction (#817)
In deep agent workflows, each sub‐agent automatically performs an LLM
step to summarize its tool calls before returning to its parent. This
leads to:
1. Excessive latency: every nested agent invokes the LLM, compounding
delays.
2. Loss of raw tool data: summaries may strip out details the top‐level
agent needs.

We discovered that `Agent.as_tool(...)` already accepts an
(undocumented) `custom_output_extractor` parameter. By providing a
callback, a parent agent can override what the sub‐agent returns e.g.
hand back raw tool outputs or a custom slice so that only the final
agent does summarization.

---

This PR adds a “Custom output extraction” section to the Markdown docs
under “Agents as tools,” with a minimal code example.
2025-06-09 10:24:51 -04:00
Rohan Mehta
5c7c678aef
Add release documentation (#814)
## Summary
- describe semantic versioning and release steps
- add release page to documentation nav

## Testing
- `make format`
- `make lint`
- `make mypy`
- `make tests`
- `make build-docs`


------
https://chatgpt.com/codex/tasks/task_i_68409d25afdc83218ad362d10c8a80a1
2025-06-04 16:57:19 -04:00
Rohan Mehta
4a529e6c16
Add REPL run_demo_loop helper (#811) 2025-06-04 11:53:17 -04:00
Chang Luo
0a28d71cca
Fix typo: Replace 'two' with 'three' in /docs/mcp.md (#757)
The documentation in `docs/mcp.md` listed three server types (stdio,
HTTP over SSE, Streamable HTTP) but incorrectly stated "two kinds of
servers" in the heading. This PR fixes the numerical discrepancy.

**Changes:** 

- Modified from "two kinds of servers" to "three kinds of servers". 
- File: `docs/mcp.md` (line 11).
2025-05-30 12:11:10 -04:00
Sarmad Gulzar
47fa8e87b1
Fixed Python syntax (#665) 2025-05-29 17:24:31 -04:00
siddharth Sambharia
d46e2ec35b
Add Portkey AI as a tracing provider (#785)
This PR adds Portkey AI as a tracing provider. Portkey helps you take
your OpenAI agents from prototype to production.

Portkey turns your experimental OpenAI Agents into production-ready
systems by providing:

- Complete observability of every agent step, tool use, and interaction
- Built-in reliability with fallbacks, retries, and load balancing
- Cost tracking and optimization to manage your AI spend
- Access to 1600+ LLMs through a single integration
- Guardrails to keep agent behavior safe and compliant
- Version-controlled prompts for consistent agent performance


Towards #786
2025-05-29 11:43:25 -04:00
Rohan Mehta
a96108e279
Update MCP and tool docs (#736)
## Summary
- mention MCPServerStreamableHttp in MCP server docs
- document CodeInterpreterTool, HostedMCPTool, ImageGenerationTool and
LocalShellTool
- update Japanese translations
2025-05-23 13:00:21 -04:00
franz101
428c9a65bf
Add Galileo to external tracing processors list (#662) 2025-05-19 15:41:11 -04:00
N V J K Kartik
4187fba955
docs: add FutureAGI to tracing documentation (#592)
Hi Team! 

This PR adds FutureAGI to the tracing documentation as one of the
automatic tracing processors for OpenAI agents SDK.


![image](https://github.com/user-attachments/assets/4de3aadc-5efa-4712-8b02-decdedf8f8ef)
2025-04-25 12:10:59 -04:00
Rohan Mehta
942ba9840b
Docs and tests for litellm (#561) 2025-04-21 16:59:01 -04:00
Yuya Haruna
0a3dfa071a
Fix visualize graph filename to without extension. (#554)
Only the file name is needed since graphviz's `render()` automatically
adds the file extension.
Also, unnecessary .gv (.dot) files are output, so the `cleanup=True`
option has been modified to prevent them from being saved.

Here is a similar modification, but in a different content.
- https://github.com/openai/openai-agents-python/pull/451
2025-04-21 13:47:51 -04:00
Kazuhiro Sera
5639606163
Docs: Switch to o3 model; exclude translated pages from search (#533)
This pull request introduces the following changes:
1. **Exclude translated pages from search**: I explored ways to make the
search plugin work with the i18n plugin, but it would require extensive
custom JavaScript hacks. So for now, I’m holding off on this work.
2. **Switch from GPT-4.1 to o3 for even better translation quality**:
While 4.1 performs well, o3 shows even greater quality for this task,
and there’s no reason to avoid using it.
2025-04-16 21:29:09 -04:00
Rohan Mehta
472e8c13bd
Docs for LiteLLM integration (#532) 2025-04-16 18:54:22 -04:00
Kazuhiro Sera
360f173b73
Evolve the doc translation workflow by using gpt-4.1 (#507)
This pull request enhances the document translation workflow by
switching to the new GPT-4.1 model. The generator script’s prompt now
includes a “workflow” section that guides the model to iterate
self-reviews on its outputs to autonomously achieve the highest quality.
This addition has noticeably improved the naturalness and consistency of
the wording in the translated outputs.
2025-04-14 22:04:07 -04:00
Rohan Mehta
5183f528f4
Add docs for customizng agent-as-tool (#504)
Co-authored-by: pakrym-oai <pakrym@openai.com>
2025-04-14 12:40:32 -04:00
Kazuhiro Sera
25f97f979b
Fix typos and misspellings (#486)
Detected typos using typos-cli (https://crates.io/crates/typos-cli). It
detected "occured" in a string constant "handoff_occured" too, but I
didn't change the part this time because it could be a minor breaking
change.


Full outputs:
```
% typos .
error: `Supresses` should be `Suppresses`
  --> ./src/agents/function_schema.py:134:7
    |
134 |     # Supresses warnings about missing annotations for params
    |       ^^^^^^^^^
    |
error: `typ` should be `typo`, `type`
  --> ./src/agents/strict_schema.py:51:5
   |
51 |     typ = json_schema.get("type")
   |     ^^^
   |
error: `typ` should be `typo`, `type`
  --> ./src/agents/strict_schema.py:52:8
   |
52 |     if typ == "object" and "additionalProperties" not in json_schema:
   |        ^^^
   |
error: `typ` should be `typo`, `type`
  --> ./src/agents/strict_schema.py:55:9
   |
55 |         typ == "object"
   |         ^^^
   |
error: `occured` should be `occurred`
  --> ./src/agents/stream_events.py:34:18
   |
34 |         "handoff_occured",
   |                  ^^^^^^^
   |
error: `occured` should be `occurred`
  --> ./src/agents/_run_impl.py:723:69
    |
723 |                 event = RunItemStreamEvent(item=item, name="handoff_occured")
    |                                                                     ^^^^^^^
    |
error: `desitnation` should be `destination`
  --> ./src/agents/tracing/span_data.py:171:25
    |
171 |     Includes source and desitnation agents.
    |                         ^^^^^^^^^^^
    |
error: `exmaples` should be `examples`
  --> ./docs/scripts/translate_docs.py:71:145
   |
71 |         "* The term 'examples' must be code examples when the page mentions the code examples in the repo, it can be translated as either 'code exmaples' or 'sample code'.",
   |                                                                                                                                                 ^^^^^^^^
   |
error: `structed` should be `structured`
  --> ./tests/test_agent_hooks.py:227:16
    |
227 | async def test_structed_output_non_streamed_agent_hooks():
    |                ^^^^^^^^
    |
error: `structed` should be `structured`
  --> ./tests/test_agent_hooks.py:298:16
    |
298 | async def test_structed_output_streamed_agent_hooks():
    |                ^^^^^^^^
    |
```
2025-04-14 10:37:13 -04:00
Kazuhiro Sera
e115d5a459
Add model_settings guide to models document page (#484)
This is a pretty minor improvement to the docs: `model_settings`
parameter is only mentioned on the agent doc page, but first-time
visitors may want to know it’s also available on the models page.
2025-04-11 13:27:01 -04:00
Kazuhiro Sera
68c725f942
Improve translation pipeline details (#475)
This pull request improves the translation pipeline, which was
introduced by #460. Now the document generation works pretty well with
gpt-4o model.
2025-04-10 16:54:05 -04:00
Kazuhiro Sera
ece647b93f
Add i18n support to the documents (#460) 2025-04-08 09:41:48 -04:00
James Hills
064e25b01b
add links and mcp + voice examples (#438) 2025-04-04 19:53:12 -04:00
Drew Youngwerth
bef3394859
Fix reference to group id as session id (#430)
Group ID is being mistakenly referenced as Session ID, which is a bit
confusing.
2025-04-03 15:36:35 -04:00
Hoc Phan
3454e3b323
Update tracing.md - Added Okahu-Monocle (#385)
Monocle is an open source tracing and eval for GenAI apps.
2025-04-01 11:57:43 -04:00
Eric Peter
9c53abe8c1
Databricks MLflow tracing integration (#401) 2025-03-30 23:53:09 -04:00
Ali Waleed
382500d841
Add Langtrace to tracing.md (#371) 2025-03-27 21:33:49 -04:00
Rohan Mehta
f99fa5f23c
Tracing screenshot for MCP docs (#355) 2025-03-26 10:56:34 -07:00
Rohan Mehta
dd881eed9a
feat: Add Graphviz-based agent visualization functionality (#147)
This pull request introduces functionality for visualizing agent
structures using Graphviz. The changes include adding a new dependency,
implementing functions to generate and draw graphs, and adding tests for
these functions.

New functionality for visualizing agent structures:

* Added `graphviz` as a new dependency in `pyproject.toml`.
* Implemented functions in `src/agents/visualizations.py` to generate
and draw graphs for agents using Graphviz. These functions include
`get_main_graph`, `get_all_nodes`, `get_all_edges`, and `draw_graph`.

Testing the new visualization functionality:

* Added tests in `tests/test_visualizations.py` to verify the
correctness of the graph generation and drawing functions. The tests
cover `get_main_graph`, `get_all_nodes`, `get_all_edges`, and
`draw_graph`.

For example, given the following code:

```python
from agents import Agent, function_tool
from agents.visualizations import draw_graph


@function_tool
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny."


spanish_agent = Agent(
    name="Spanish agent",
    instructions="You only speak Spanish.",
)

english_agent = Agent(
    name="English agent",
    instructions="You only speak English",
)

triage_agent = Agent(
    name="Triage agent",
    instructions="Handoff to the appropriate agent based on the language of the request.",
    handoffs=[spanish_agent, english_agent],
    tools=[get_weather],
)


draw_graph(triage_agent)
```

Generates the following image:

<img width="614" alt="Screenshot 2025-03-13 at 18 36 23"
src="https://github.com/user-attachments/assets/d01fe502-6886-4efb-aaf8-c92e4524b0fe"
/>
2025-03-25 19:22:58 -04:00
Rohan Mehta
6be9b2a222
Update visualization.md 2025-03-25 13:34:45 -04:00
Martín Bravo
698fd69eb4 Update installation instructions for visualization dependency to use 'viz' 2025-03-25 18:29:55 +01:00
Rohan Mehta
6fb5792b77 Make the reset behavior on tool use configurable
## Summary:

#263 added this behavior. The goal was to prevent infinite loops when tool choice was set. The key change I'm making is:
1. Making it configurable on the agent.
2. Doing bookkeeping in the Runner to track this, to prevent mutating agents.
3. Not resetting the global tool choice in RunConfig.

## Test Plan:
Unit tests.
.
2025-03-25 13:29:32 -04:00
Rohan Mehta
b98a6bd4ac [4/n] Add docs for MCP
Just adding docs.
-
2025-03-25 13:25:50 -04:00
Martín Bravo
900a97fa55 Merge branch 'main' of https://github.com/openai/openai-agents-python into feat/draw_graph 2025-03-25 16:58:01 +01:00
Rohan Mehta
927a29c56b
Fix potential infinite tool call loop by resetting tool_choice after … (#263)
# Fix potential infinite tool call loop by resetting tool_choice after
tool execution

## Summary

This PR fixes an issue where setting `tool_choice` to "required" or a
specific function name could cause models to get stuck in an infinite
tool call loop.

When `tool_choice` is set to force tool usage, this setting persists
across model invocations. This PR automatically resets `tool_choice` to
"auto" after tool execution, allowing the model to decide whether to
make additional tool calls in subsequent turns.

Unlike using `tool_use_behavior="stop_on_first_tool"`, this approach
lets the model continue processing tool results while preventing forced
repeated tool calls.

## Test plan

- Added tests to verify tool_choice reset behavior for both agent and
run_config settings
- Added integration test to verify the solution prevents infinite loops
- All tests pass

## Checks

- [x] I've added new tests for the fix
- [x] I've updated the relevant documentation (added comment in code)
- [x] I've run `make lint` and `make format`
- [x] I've made sure tests pass
2025-03-25 11:30:53 -04:00
Rohan Mehta
791a6f6812
Update quickstart.md 2025-03-23 17:56:55 -04:00
xianghuijin
8f2f76cb65 docs: Update tool_choice reset documentation to match implementation 2025-03-22 14:22:47 +08:00
Rohan Mehta
8d906f88f0
Fix code examples in voice pipeline quickstart docs (#277) 2025-03-21 21:44:14 -04:00
Rohan Mehta
486b4e87e5
[docs] fix annotation numbering in context management (#293)
Fix inconsistent numbering between code and explanatory annotations in
the context management documentation.
2025-03-21 19:33:30 -04:00
Scott Condron
13eca63732
Add Weights & Biases to tracing docs 2025-03-21 21:37:54 +00:00
Han Hwang Lim
d56047be51 fix annotation numbering in context management
Fix inconsistent numbering between code and explanatory annotations in
the context management documentation.
2025-03-21 21:10:30 +00:00
James Hills
fa1c3f40a1
fix line in guardrails 2025-03-21 15:58:34 -04:00
Rohan Mehta
851f0ce539
docs: add Langfuse to tracing documentation (#284) 2025-03-21 10:31:05 -04:00
Jannik Maierhöfer
37ddc4e5a1
docs: add Langfuse to tracing documentation 2025-03-21 13:39:17 +01:00
Pepijn
3da3b51b87 Fix voice pipeline code examples in quickstart docs 2025-03-21 06:47:12 +01:00
Sir Qasim
5f7a0b9508
fixed from agents.voice import SingleAgentVoiceWorkflow, VoicePipeline in quickstart.md
from agents.voice import SingleAgentVoiceWorkflow, VoicePipeline,

remove extra "," from the first line
2025-03-21 06:58:47 +05:00
Kazuhiro Sera
98c4b45b6a Make the optional dependency installation compatible with zsh 2025-03-21 10:01:24 +09:00
Rohan Mehta
180a8ab043
Updating tracing doc for new spans (#272) 2025-03-20 20:05:42 -04:00
Dmitry Pimenov
1b12fce95d fixing object path 2025-03-20 17:03:52 -07:00
Yoshinori Sano
0dd5b37936 [doc] fix invalid imports 2025-03-21 08:37:45 +09:00
Dmitry Pimenov
21634f31d5 removing erroneous changes 2025-03-20 15:53:41 -07:00
Dominik Kundel
c7ce154637 feat: add voice pipeline support
> Co-authored-by: rm@openai.com
2025-03-20 09:43:13 -07:00
xianghuijin
d169d79288 Update documentation for tool_choice auto-reset feature 2025-03-20 21:49:38 +08:00