Commit graph

353 commits

Author SHA1 Message Date
Daniele Morotti
e04d87cb1f
Add extra request parameters extra_query and extra_body (#500)
Added the possibility to pass `extra_query` and `extra_body` parameters
when sending a request.
In this implementation I added the attributes to `ModelSettings` as
suggested by @rm-openai in #487 .

I'll be happy to add some tests if you have any suggestions.
2025-04-14 10:37:00 -04:00
LouisShark
d0693a192e
fix: ensure metadata is non-null in response handling (#483)
ensure metadata is non-null in response handling
2025-04-11 18:20:59 -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
Ddper
8ded8a9981
add overwrite mechanism for stream_options (#465)
fix issue https://github.com/openai/openai-agents-python/issues/442

below is an example to overwrite include_usage


```
    result = Runner.run_streamed(
        agent,
        "Write a haiku about recursion in programming.",
        run_config=RunConfig(
            model_provider=CUSTOM_MODEL_PROVIDER,
            model_settings=ModelSettings(include_usage=True)
        ),
    )
```
2025-04-10 16:54:00 -04:00
Dmitry Pimenov
84fb734ba0
Adding scope and span_data doc strings (#463)
Built docs and tested outputs locally
2025-04-09 14:59:07 -04:00
nikkie
d089886f01
examples(research_bot): Add space to INSTRUCTIONS (#439)
Thanks to awesome example `research_bot`

Fix andproduce and goodgrammar (and so on)

```python
>>> from examples.research_bot.agents import search_agent
>>> print(search_agent.INSTRUCTIONS)
You are a research assistant. Given a search term, you search the web for that term andproduce a concise summary of the results. The summary must 2-3 paragraphs and less than 300words. Capture the main points. Write succinctly, no need to have complete sentences or goodgrammar. This will be consumed by someone synthesizing a report, so its vital you capture theessence and ignore any fluff. Do not include any additional commentary other than the summaryitself.
```
2025-04-08 14:01:09 -04:00
nikkie
ccff74dcfa
docs: Make default model clear (#457)
close https://github.com/openai/openai-agents-python/issues/440
2025-04-08 11:47:23 -04:00
kanchi
869c95b012
Update computer-use example to support simultaneous key presses (#452)
### Summary

Updated the `computer-use` example to support simultaneous key presses.
The current implementation presses and releases keys one at a time,
which prevents combo inputs like copy (CTRL+C) from working correctly.

### Test plan

N/A

### Issue number

N/A

### Checks

- [ ] I've added new tests (if relevant)
- [ ] I've added/updated the relevant documentation
- [x] I've run `make lint` and `make format`
- [ ] I've made sure tests pass
2025-04-08 11:47:15 -04:00
Kazuhiro Sera
ece647b93f
Add i18n support to the documents (#460) 2025-04-08 09:41:48 -04:00
Rohan Mehta
9d3d6a58e5
v0.0.9 (#456)
bump version.
2025-04-07 19:27:19 -04:00
Rohan Mehta
2bcc864b81
Don't send the "store" param unless its hitting OpenAI (#455)
Summary: See #443. Causes issues with Gemini.

Test Plan: Tests. Also tested with Gemini to ensure it works.
2025-04-07 19:13:08 -04:00
Rohan Mehta
50bbfdd8be
Ensure MCP works when inputSchema.properties is missing (#454)
Resolves #449 - TLDR, [OpenAI's
API](https://platform.openai.com/docs/api-reference/responses/create)
expects the properties field to be present, whereas the MCP schema
explicitly allows omitting the properties field. [MCP
Spec](https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-03-26/schema.json)
2025-04-07 18:38:36 -04:00
James Hills
064e25b01b
add links and mcp + voice examples (#438) 2025-04-04 19:53:12 -04:00
Rohan Mehta
0396052dcd
v0.0.8 (#432)
bump
2025-04-03 19:46:26 -04:00
Suveen Ellawela
07a627e8eb
Add reasoning parameter to ModelSettings (#388)
fixes #189 

@rm-openai Would really appreciate if this can get a quick review.

---------

Co-authored-by: Rohan Mehta <rm@openai.com>
2025-04-03 19:35:59 -04:00
Drew Youngwerth
0110f3ad96
Add metadata to ModelSettings (#431) 2025-04-03 17:50:24 -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
amri369
506d73cfa4
Fix small typos and mcp example command (#417) 2025-04-03 12:34:53 -04:00
Rohan Mehta
7c2d7f4abd
Misc small fixes - mcp version, test for function_schema, version gen (#429)
Summary:
1. Use <2 for MCP version so it doesn't break if the MCP sdk upgrades.
2. Test the func schema extraction logic.
3. Fix the logic to get the version nuber of the framework

Test Plan:
unit tests
2025-04-03 12:08:01 -04:00
Rohan Mehta
bf302c574c
Use "{}" instead of empty string for arguments (#422) 2025-04-02 12:27:42 -04:00
Rohan Mehta
01f5e86ea5
Convert MCP schemas to strict where possible (#414)
## Summary:
Towards #404. I made this configurable because it's not clear this is
always a good thing to do. I also made it default to False because I'm
not sure if this could cause errors.

If it works out well, we can switch the default in the future as a small
breaking changes

## Test Plan:
Unit tests
2025-04-01 16:50:13 -04:00
Muhammad Anas Baig
45c25f8ab0
Fix Docstring Reference in 'ToolsToFinalOutputFunction' in 'agent.py' (#391)
### **Summary**
This pull request fixes docstring in `ToolsToFinalOutputFunction`, where
`ToolToFinalOutputResult` was incorrectly referenced instead of
`ToolsToFinalOutputResult`.

### **Changes Made**
- Updated the docstring of `ToolsToFinalOutputFunction` to correctly
reference `ToolsToFinalOutputResult`.

### **Before**
```python
"""A function that takes a run context and a list of tool results, and returns a
`ToolToFinalOutputResult`.
"""
```

### **After**
```python
"""A function that takes a run context and a list of tool results, and returns a
`ToolsToFinalOutputResult`.
"""
```

### **Why This Change?**
- The incorrect reference could cause confusion for developers reading
the code.
- This aligns the documentation with the actual return type of the
function.

### **Checklist**
- [x] Verify correct reference to `ToolsToFinalOutputResult`
- [x] Ensure no functionality is affected

### **Testing**
This is a documentation-only change and does not affect runtime
behavior.

### **Reviewer Notes**
- Please review for accuracy in documentation.
- No additional tests are needed since this is a non-functional change.
2025-04-01 14:09:26 -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
Travis Dent
db3975f06c
Fix incorrect slot name on SpeechSpanData (#386)
Slot had inconsistent name. 

`"first_byte_at"` -> `"first_content_at"`
2025-04-01 11:51:58 -04:00
Carmen(Jia) Liu
e827dfe75f
Fix: Correct the trace path in examples (#395)
### What changed?
The trace URL was using the wrong path format:
- Old: `/traces/{trace_id}`
- Fixed: `/traces/trace?trace_id={trace_id}`

<img width="781" alt="Screenshot 2025-03-30 at 5 54 11 pm"
src="https://github.com/user-attachments/assets/982fbb1d-7163-4438-b237-493e3100b5c7"
/>
2025-04-01 11:51:52 -04:00
Toufik Airane
757b7dafb1
Update README.md (#405)
fix typo
2025-04-01 11:50:40 -04:00
Ddper
8b2bc0b4ba
fix duplicate declaration of _shutdown_event (#410)
fix duplicate declaration of _shutdown_event
reported by issue
https://github.com/openai/openai-agents-python/issues/314
2025-04-01 11:48:02 -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
Martin Jagusch
b268829d08
Remove duplicate dependency definition of pynput (#367)
`pynput` is in the pyproject.toml file twice, as you can see on line 54.

The uv.lock file doesn't change.
2025-03-27 13:40:06 -04:00
amri369
377ddbace6
Hotfix mcp example (#365)
Small typo in uv command fixed
2025-03-27 13:05:30 -04:00
Steven Heidel
aad8accc86
Expose the "store" parameter through ModelSettings (#357)
Closes https://github.com/openai/openai-agents-python/issues/173

This will also set stored completions to True by default, encouraging a
best practice.
2025-03-26 19:01:28 -04:00
Rohan Mehta
4854a745e8
Raise error on more invalid function schemas (#356)
Towards #345

## Summary:
Using a `dict` or `Mapping` isn't strict-mode compliant. But we were
checking for the literal `True` whereas the value can also be an array,
for example. Fix that.

## Test Plan:

Unit tests
2025-03-26 15:52:19 -04:00
Rohan Mehta
f99fa5f23c
Tracing screenshot for MCP docs (#355) 2025-03-26 10:56:34 -07:00
Rohan Mehta
bd47a41d0b
MCP example for SSE (#354)
Simple example with a local SSE server.
2025-03-26 12:56:35 -04:00
Rohan Mehta
7f02967156
v0.0.7 (#353)
Upgrade version to prepare for a new release.
2025-03-26 09:06:24 -07:00
pakrym-oai
6d95a3f191
Mark handoff span as errored when multiple handoffs are requested (#344)
Also includes the set of requested agents in the error data.
<img width="968" alt="image"
src="https://github.com/user-attachments/assets/0c5c2e81-08f7-445c-bbb0-3e169ef744a5"
/>
2025-03-26 10:44:59 -04:00
Rohan Mehta
2261aabeeb
Adding Git MCP server example (#343)
- Adding new example showing a single agent interacting with local MCP
server for git
2025-03-25 19:54:59 -04:00
Rohan Mehta
b5ba22904a
[5/n] MCP tracing (#342)
## Summary:

Adds tracing and tests for tracing.
- Tools are added to the agents
- Theres a span for the mcp tools lookup
- Functions have MCP data

## Test Plan:

Unit tests
.
2025-03-25 19:54:28 -04:00
Dmitry Pimenov
5385f8b10e added readme, fixed typo 2025-03-25 16:52:52 -07:00
Dmitry Pimenov
88c8acbc5a fixing lint issues 2025-03-25 16:34:00 -07:00
Dmitry Pimenov
0944390c3f adding Git MCP server example 2025-03-25 16:30:50 -07:00
Rohan Mehta
010022777b [5/n] MCP tracing
## Summary:

Adds tracing and tests for tracing.
- Tools are added to the agents
- Theres a span for the mcp tools lookup
- Functions have MCP data

## Test Plan:

Unit tests
.
2025-03-25 19:28:48 -04: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
a0c5abce8f
fix(examples): make sure audio playback finishes (#340)
Previously the stream was closing as soon as all the audio was added but
didn't wait for it to be finished. Additionally the audio might seem
chopped off if there is no additional silence so this PR also adds one
second of silence before exiting the program.
2025-03-25 15:22:55 -04:00
Dominik Kundel
2104f5400b fix(examples): make sure audio playback finishes 2025-03-25 12:11:33 -07:00
Martín Bravo
c16deb22a1 Remove Jupyter Notebook files from .gitignore 2025-03-25 19:31:32 +01:00
Martín Bravo
70aff1d39d linting 2025-03-25 19:18:57 +01:00
Martín Bravo
3068e42029 Fix type ignore comment for agent check in get_all_edges function 2025-03-25 19:17:35 +01:00