Commit graph

440 commits

Author SHA1 Message Date
pakrym-oai
91c62c1dea
Prepare 0.0.19 release (#895) 2025-06-17 20:47:26 -04:00
pakrym-oai
0cf503e1c2
Allow replacing AgentRunner and TraceProvider (#720) 2025-06-17 17:41:10 -07:00
Rohan Mehta
901d2ac57c
v0.0.18 (#878) 2025-06-16 15:49:36 -04:00
Rohan Mehta
2b9b8f7e73
Prompts support (#876)
Add support for the new openai prompts feature.
2025-06-16 15:47:48 -04:00
Daniele Morotti
281a7b2bb6
adopted float instead of timedelta for timeout parameters (#874)
I replaced the `timedelta` parameters for MCP timeouts with `float`
values, addressing issue #845 .

Given that the MCP official repository has incorporated these changes in
[this PR](https://github.com/modelcontextprotocol/python-sdk/pull/941),
updating the MCP version in openai-agents and specifying the timeouts as
floats should be enough.
2025-06-16 11:35:09 -04:00
Rohan Mehta
6d2806f10c
Fix function_schema name override bug (#872)
## Summary
- ensure `name_override` is always used in `function_schema`
- test name override when docstring info is disabled

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

Resolves #860
------
https://chatgpt.com/codex/tasks/task_i_684f1cf885b08321b4dd3f4294e24ca2
2025-06-16 10:50:20 -04:00
Rohan Mehta
0eee6b8305
Allow arbitrary kwargs in model (#842)
Sometimes users want to provide parameters specific to a model provider.
This is an escape hatch.
2025-06-10 18:14:34 -04:00
Niv Hertz
8dfd6ff35c
Added support for passing tool_call_id via the RunContextWrapper (#766)
This PR fixes issue:
https://github.com/openai/openai-agents-python/issues/559

By adding the tool_call_id to the RunContextWrapper prior to calling
tools. This gives the ability to access the tool_call_id in the
implementation of the tool.
2025-06-09 11:08:50 -04:00
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
James Hills
c98e234845
Fix handoff transfer message JSON (#818)
## Summary
- ensure `Handoff.get_transfer_message` emits valid JSON
- test transfer message validity

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


------
https://chatgpt.com/codex/tasks/task_i_68432f925b048324a16878d28e850841
2025-06-09 10:13:43 -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
05db7a68cd
Crosslink to js/ts (#815) 2025-06-04 15:37:09 -04:00
Rohan Mehta
4a529e6c16
Add REPL run_demo_loop helper (#811) 2025-06-04 11:53:17 -04:00
Rohan Mehta
204bec1b8b
v0.0.17 (#809)
bump version
2025-06-03 22:36:51 -04:00
Rohan Mehta
4046fcb3fa
Add is_enabled to FunctionTool (#808)
### Summary:
Allows a user to do `function_tool(is_enabled=<some_callable>)`; the
callable is called when the agent runs.

This allows you to dynamically enable/disable a tool based on the
context/env.

The meta-goal is to allow `Agent` to be effectively immutable. That
enables some nice things down the line, and this allows you to
dynamically modify the tools list without mutating the agent.

### Test Plan:
Unit tests
2025-06-03 13:44:16 -04:00
Rohan Mehta
995af4d83e
Only start tracing worker thread on first span/trace (#804)
Closes #796. Shouldn't start a busy waiting thread if there aren't any
traces.

Test plan
```
import threading
assert threading.active_count() == 1
import agents
assert threading.active_count() == 1
```
2025-06-02 15:32:02 -04:00
Rohan Mehta
d4c7a23e1d
Don't cache agent tools during a run (#803)
### Summary:
Towards #767. We were caching the list of tools for an agent, so if you
did `agent.tools.append(...)` from a tool call, the next call to the
model wouldn't include the new tool. THis is a bug.

### Test Plan:
Unit tests. Note that now MCP tools are listed each time the agent runs
(users can still cache the `list_tools` however).
2025-06-02 14:49:16 -04:00
westhood
775d3e237e
Ensure item.model_dump only contains JSON serializable types (#801)
The EmbeddedResource from MCP tool call contains a field with type
AnyUrl that is not JSON-serializable. To avoid this exception, use
item.model_dump(mode="json") to ensure a JSON-serializable return value.
2025-06-02 11:10:21 -04:00
Kazuhiro Sera
3e7b2863e9
Fix #777 by handling MCPCall events in RunImpl (#799)
This pull request resolves #777; If you think we should introduce a new
item type for MCP call output, please let me know. As other hosted tools
use this event, I believe using the same should be good to go tho.
2025-06-02 11:10:07 -04:00
Rohan Mehta
cfe9099f3f
Add comment to handoff_occured misspelling (#792)
People keep trying to fix this, but its a breaking change.
2025-05-30 14:41:54 -04:00
Rehan Ul Haq
64383502dd
docs: fix typo in docstring for is_strict_json_schema method (#775)
### Overview

This PR fixes a small typo in the docstring of the
`is_strict_json_schema` abstract method of the `AgentOutputSchemaBase`
class in `agent_output.py`.

### Changes

- Corrected the word “valis” to “valid” in the docstring.

### Motivation

Clear and correct documentation improves code readability and reduces
confusion for users and contributors.

### Checklist

- [x] I have reviewed the docstring after making the change.
- [x] No functionality is affected.
- [x] The change follows the repository’s contribution guidelines.
2025-05-30 12:14:10 -04:00
Venkat Naveen
ad80f788b9
Update input_guardrails.py (#774)
Changed the function comment as input_guardrails only deals with input
messages
2025-05-30 12:13:57 -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
Rehan Ul Haq
16fb29c1f0
Fix typo in assertion message for handoff function (#780)
### Overview

This PR fixes a typo in the assert statement within the `handoff`
function in `handoffs.py`, changing `'on_input'` to `'on_handoff`' for
accuracy and clarity.

### Changes

- Corrected the word “on_input” to “on_handoff” in the docstring.

### Motivation

Clear and correct documentation improves code readability and reduces
confusion for users and contributors.

### Checklist

- [x] I have reviewed the docstring after making the change.
- [x] No functionality is affected.
- [x] The change follows the repository’s contribution guidelines.
2025-05-30 11:53:15 -04:00
rob-openai
b699d9a533
Small fix for litellm model (#789)
Small fix:

Removing `import litellm.types` as its outside the try except block for
importing litellm so the import error message isn't displayed, and the
line actually isn't needed. I was reproducing a GitHub issue and came
across this in the process.
2025-05-30 10:32:25 -04:00
Sarmad Gulzar
47fa8e87b1
Fixed Python syntax (#665) 2025-05-29 17:24:31 -04:00
Daniele Morotti
71968625cc
Added RunErrorDetails object for MaxTurnsExceeded exception (#743)
### Summary

Introduced the `RunErrorDetails` object to get partial results from a
run interrupted by `MaxTurnsExceeded` exception. In this proposal the
`RunErrorDetails` object contains all the fields from `RunResult` with
`final_output` set to `None` and `output_guardrail_results` set to an
empty list. We can decide to return less information.

@rm-openai At the moment the exception doesn't return the
`RunErrorDetails` object for the streaming mode. Do you have any
suggestions on how to deal with it? In the `_check_errors` function of
`agents/result.py` file.

### Test plan

I have not implemented any tests currently, but if needed I can
implement a basic test to retrieve partial data.

### Issue number

This PR is an attempt to solve issue #719 

### Checks

- [ ] I've added new tests (if relevant)
- [ ] I've added/updated the relevant documentation
- [ ] I've run `make lint` and `make format`
- [ ] I've made sure tests pass
2025-05-29 16:11:33 -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
6e078bf7a9
Fix Gemini API content filter handling (#746)
## Summary
- avoid AttributeError when Gemini API returns `None` for chat message
- return empty output if message is filtered
- add regression test

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

Towards #744
2025-05-23 13:00:30 -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
Rohan Mehta
db462e32a3
Fix visualization recursion with cycle detection (#737)
## Summary
- avoid infinite recursion in visualization by tracking visited agents
- test cycle detection in graph utility

## Testing
- `make mypy`
- `make tests` 

Resolves #668
2025-05-23 13:00:10 -04:00
Andrew Han
1364f4408e
fix Gemini token validation issue with LiteLLM (#735)
Fix for #734
2025-05-21 17:59:47 -04:00
Rohan Mehta
1992be3e8d
v0.0.16 (#733) 2025-05-21 16:06:13 -04:00
Rohan Mehta
079764f0ab
Add support for local shell, image generator, code interpreter tools (#732) 2025-05-21 15:26:22 -04:00
Rohan Mehta
9fa5c39d69
Hosted MCP support (#731)
---
[//]: # (BEGIN SAPLING FOOTER)
* #732
* __->__ #731
2025-05-21 15:21:37 -04:00
Rohan Mehta
ce2e2a4571
Upgrade openAI sdk version (#730)
---
[//]: # (BEGIN SAPLING FOOTER)
* #732
* #731
* __->__ #730
2025-05-21 15:17:58 -04:00
WJPBProjects
466b44df18
Dev/add usage details to Usage class (#726)
PR to enhance the `Usage` object and related logic, to support more
granular token accounting, matching the details available in the [OpenAI
Responses API](https://platform.openai.com/docs/api-reference/responses)
. Specifically, it:

- Adds `input_tokens_details` and `output_tokens_details` fields to the
`Usage` dataclass, storing detailed token breakdowns (e.g.,
`cached_tokens`, `reasoning_tokens`).
- Flows this change through
- Updates and extends tests to match
- Adds a test for the Usage.add method

### Motivation
- Aligns the SDK’s usage with the latest OpenAI responses API Usage
object
- Supports downstream use cases that require fine-grained token usage
data (e.g., billing, analytics, optimization) requested by startups

---------

Co-authored-by: Wulfie Bain <wulfie@openai.com>
2025-05-20 18:23:56 +01:00
franz101
428c9a65bf
Add Galileo to external tracing processors list (#662) 2025-05-19 15:41:11 -04:00
Daniele Morotti
003cbfe5f5
Added mcp 'instructions' attribute to the server (#706)
Added the `instructions` attribute to the MCP servers to solve #704 .

Let me know if you want to add an example to the documentation.
2025-05-18 13:25:08 -04:00
Dominik Kundel
c282324d95
Create AGENTS.md (#707)
Adding an AGENTS.md file for Codex use
2025-05-18 13:24:24 -04:00
Rohan Mehta
5fe096df67
v0.0.15 (#701) 2025-05-15 18:41:00 -04:00
Akshit97
1847008e0f
feat: Streamable HTTP support (#643)
Co-authored-by: aagarwal25 <akshit_agarwal@intuit.com>
2025-05-14 14:45:14 -04:00
leohpark
02b6e7013c
Update search_agent.py (#677)
Added missing word "be" in prompt instructions.

This is unlikely to change the agent functionality in most cases, but
optimal clarity in prompt language is a best practice.
2025-05-14 12:37:06 -04:00
Ashok Saravanan
1994f9d4c4
feat: pass extra_body through to LiteLLM acompletion (#638)
**Purpose**  
Allow arbitrary `extra_body` parameters (e.g. `cached_content`) to be
forwarded into the LiteLLM call. Useful for context caching in Gemini
models
([docs](https://ai.google.dev/gemini-api/docs/caching?lang=python)).

**Example usage**  
```python
import os
from agents import Agent, ModelSettings
from agents.extensions.models.litellm_model import LitellmModel

cache_name = "cachedContents/34jopukfx5di"  # previously stored context

gemini_model = LitellmModel(
    model="gemini/gemini-1.5-flash-002",
    api_key=os.getenv("GOOGLE_API_KEY")
)

agent = Agent(
    name="Cached Gemini Agent",
    model=gemini_model,
    model_settings=ModelSettings(
        extra_body={"cached_content": cache_name}
    )
)
2025-05-14 12:34:27 -04:00
Daniele Morotti
2c46dae377
Fixed a bug for "detail" attribute in input image (#685)
When an input image is given as input, the code tries to access the
'detail' key, that may not be present as noted in #159.

With this pull request, now it tries to access the key, otherwise set
the value to `None`.
@pakrym-oai  or @rm-openai let me know if you want any changes.
2025-05-14 11:31:42 -04:00
pakrym-oai
f9763495b8
0.0.14 release (#635) 2025-04-30 08:15:35 -07:00
pakrym-oai
db0ee9d5a5
Update litellm version (#626)
Addresses https://github.com/openai/openai-agents-python/issues/614
2025-04-29 16:12:24 -07: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
Stefano Baccianella
aa197e1e14
Make the TTS voices type exportable (#577)
When using the voice agent in typed code, it is suboptimal and error
prone to type the TTS voice variables in your code independently.

With this commit we are making the type exportable so that developers
can just use that and be future-proof.

Example of usage in code:

```
DEFAULT_TTS_VOICE: TTSModelSettings.TTSVoice = "alloy"

...

tts_voice: TTSModelSettings.TTSVoice = DEFAULT_TTS_VOICE 

...

output = await VoicePipeline(
  workflow=workflow,
  config=VoicePipelineConfig(
  tts_settings=TTSModelSettings(
    buffer_size=512,
    transform_data=transform_data,
    voice=tts_voice,
    instructions=tts_instructions,
  ))
).run(audio_input)
```

---------

Co-authored-by: Rohan Mehta <rm@openai.com>
2025-04-24 19:11:25 -04:00
Rohan Mehta
8fd7773a5e
Add usage to context in streaming (#595) 2025-04-24 18:20:35 -04:00