Skip to content

Commit b2c5c40

Browse files
fix(pydantic-ai): Remove Agent.run_stream_events patch
1 parent 5728097 commit b2c5c40

1 file changed

Lines changed: 0 additions & 29 deletions

File tree

sentry_sdk/integrations/pydantic_ai/patches/agent_run.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -179,31 +179,6 @@ def wrapper(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
179179
return wrapper
180180

181181

182-
def _create_streaming_events_wrapper(
183-
original_func: "Callable[..., Any]",
184-
) -> "Callable[..., Any]":
185-
"""
186-
Wraps run_stream_events method - no span needed as it delegates to run().
187-
188-
Note: run_stream_events internally calls self.run() with an event_stream_handler,
189-
so the invoke_agent span will be created by the run() wrapper.
190-
"""
191-
192-
@wraps(original_func)
193-
async def wrapper(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
194-
# Just call the original generator - it will call run() which has the instrumentation
195-
try:
196-
async for event in original_func(self, *args, **kwargs):
197-
yield event
198-
except Exception as exc:
199-
exc_info = sys.exc_info()
200-
with capture_internal_exceptions():
201-
_capture_exception(exc)
202-
reraise(*exc_info)
203-
204-
return wrapper
205-
206-
207182
def _patch_agent_run() -> None:
208183
"""
209184
Patches the Agent run methods to create spans for agent execution.
@@ -215,13 +190,9 @@ def _patch_agent_run() -> None:
215190
# Store original methods
216191
original_run = Agent.run
217192
original_run_stream = Agent.run_stream
218-
original_run_stream_events = Agent.run_stream_events
219193

220194
# Wrap and apply patches for non-streaming methods
221195
Agent.run = _create_run_wrapper(original_run, is_streaming=False)
222196

223197
# Wrap and apply patches for streaming methods
224198
Agent.run_stream = _create_streaming_wrapper(original_run_stream)
225-
Agent.run_stream_events = _create_streaming_events_wrapper(
226-
original_run_stream_events
227-
)

0 commit comments

Comments
 (0)