Commit graph

440 commits

Author SHA1 Message Date
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
Martín Bravo
351b6074e5 Refactor visualization functions to improve formatting and streamline edge generation 2025-03-25 19:12:40 +01:00
Martín Bravo
5ad53d8000 Add start and end nodes to graph visualization and update edge generation 2025-03-25 19:11:43 +01:00
Martín Bravo
29103caba9 Add Jupyter Notebook files to .gitignore 2025-03-25 19:03:39 +01:00
Martín Bravo
b9d32cda0f Refactor get_all_edges function to remove unused parent parameter 2025-03-25 19:02:21 +01:00
Martín Bravo
d8922ff472 Add visualization.md to navigation in mkdocs.yml 2025-03-25 18:56:01 +01:00
Martín Bravo
2f2606e5ea Add graphviz as a dependency and update import statements 2025-03-25 18:46:23 +01:00
Rohan Mehta
59aed3490d
Update pyproject.toml 2025-03-25 13:37:01 -04:00
Rohan Mehta
6be9b2a222
Update visualization.md 2025-03-25 13:34:45 -04:00
Rohan Mehta
ad020b73b5
Make the reset behavior on tool use configurable (#335)
## 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:30:32 -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
362a9dc078
[4/n] Add docs for MCP (#338)
Just adding docs.

(Repeat of #324)
2025-03-25 13:27:15 -04:00
Rohan Mehta
86618494a9
[3/n] Add an MCP stdio example (#337)
### Summary:
Spins up a stdio server with some local files, then asks the model
questions.

### Test Plan:
Run the example, see it work.

(repeat of #322)
2025-03-25 13:27:05 -04:00