Skip to content

Commit e28ddd3

Browse files
reference patched functions
1 parent 802bbfd commit e28ddd3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

sentry_sdk/integrations/openai_agents/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,29 @@ def _patch_tools() -> None:
5353

5454
class OpenAIAgentsIntegration(Integration):
5555
"""
56+
NOTE: With version 0.8.0, the class methods below have been refactored to functions.
57+
- `AgentRunner._get_model()` -> `agents.run_internal.turn_preparation.get_model()`
58+
- `AgentRunner._get_all_tools()` -> `agents.run_internal.turn_preparation.get_all_tools()`
59+
- `AgentRunner._run_single_turn()` -> `agents.run_internal.run_loop.run_single_turn()`
60+
- `RunImpl.execute_handoffs()` -> `agents.run_internal.turn_resolution.execute_handoffs()`
61+
- `RunImpl.execute_final_output()` -> `agents.run_internal.turn_resolution.execute_final_output()`
62+
5663
Typical interaction with the library:
5764
1. The user creates an Agent instance with configuration, including system instructions sent to every Responses API call.
5865
2. The user passes the agent instance to a Runner with `run()` and `run_streamed()` methods. The latter can be used to incrementally receive progress.
66+
- `Runner.run()` and `Runner.run_streamed()` are thin wrappers for `DEFAULT_AGENT_RUNNER.run()` and `DEFAULT_AGENT_RUNNER.run_streamed()`.
67+
- `DEFAULT_AGENT_RUNNER.run()` and `DEFAULT_AGENT_RUNNER.run_streamed()` are patched in `_patch_runner()` with `_create_run_wrapper()` and `_create_run_streamed_wrapper()`, respectively.
5968
3. In a loop, the agent repeatedly calls the Responses API, maintaining a conversation history that includes previous messages and tool results, which is passed to each call.
69+
- A Model instance is created at the start of the loop by calling the `Runner._get_model()`. We patch the Model instance using `_create_get_model_wrapper()` in `_patch_model()`.
70+
- Available tools are also deteremined at the start of the loop, with `Runner._get_all_tools()`. We patch the method using `_create_get_all_tools_wrapper()` in `_patch_tools()`
71+
- In each loop execution, `run_single_turn()` or `run_single_turn_streamed()` is responsible for calling the Responses API, patched with `patched_run_single_turn()` and `patched_run_single_turn_streamed()`.
72+
4. On loop termination, `RunImpl.execute_final_output()` is called. The function is patched with `patched_execute_final_output()`.
6073
6174
Local tools are run based on the return value from the Responses API as a post-API call step in the above loop.
6275
Hosted MCP Tools are run as part of the Responses API call, and involve OpenAI reaching out to an external MCP server.
6376
An agent can handoff to another agent, also directed by the return value of the Responses API and run post-API call in the loop.
6477
Handoffs are a way to switch agent-wide configuration.
78+
- Handoffs are executed by calling `RunImpl.execute_handoffs()`. The method is patched in `patched_execute_handoffs()`
6579
"""
6680

6781
identifier = "openai_agents"

0 commit comments

Comments
 (0)