Skip to content

Commit c7a8a44

Browse files
remove _SingleTurnException
1 parent 5d9e0d0 commit c7a8a44

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

sentry_sdk/integrations/openai_agents/patches/agent_run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import sys
12
from functools import wraps
23

34
from sentry_sdk.integrations import DidNotEnable
45
from sentry_sdk.tracing_utils import set_span_errored
6+
from sentry_sdk.utils import reraise
57
from ..spans import (
68
invoke_agent_span,
79
update_invoke_agent_span,
810
end_invoke_agent_span,
911
handoff_span,
1012
)
11-
from ..utils import _capture_exception, _record_exception_on_span, _SingleTurnException
13+
from ..utils import _capture_exception, _record_exception_on_span
1214

1315
from typing import TYPE_CHECKING
1416

@@ -97,7 +99,7 @@ async def patched_run_single_turn(cls, *args, **kwargs):
9799
_record_exception_on_span(span, exc)
98100
end_invoke_agent_span(context_wrapper, agent)
99101

100-
raise _SingleTurnException(exc)
102+
reraise(*sys.exc_info())
101103

102104
return result
103105

sentry_sdk/integrations/openai_agents/patches/runner.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sentry_sdk.integrations import DidNotEnable
55

66
from ..spans import agent_workflow_span, end_invoke_agent_span
7-
from ..utils import _capture_exception, _record_exception_on_span, _SingleTurnException
7+
from ..utils import _capture_exception, _record_exception_on_span
88

99
try:
1010
from agents.exceptions import AgentsException
@@ -38,9 +38,6 @@ async def wrapper(*args, **kwargs):
3838
args = (agent, *args[1:])
3939
try:
4040
run_result = await original_func(*args, **kwargs)
41-
except _SingleTurnException as exc:
42-
_capture_exception(exc.original)
43-
raise exc.original from None
4441
except AgentsException as exc:
4542
_capture_exception(exc)
4643

sentry_sdk/integrations/openai_agents/utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
raise DidNotEnable("OpenAI Agents not installed")
2828

2929

30-
class _SingleTurnException(Exception):
31-
def __init__(self, original):
32-
# type: (Exception) -> None
33-
self.original = original
34-
35-
3630
def _capture_exception(exc):
3731
# type: (Any) -> None
3832
set_span_errored()

0 commit comments

Comments
 (0)