From 078a60c615eef9ff5a59894fd28eba0eca79723e Mon Sep 17 00:00:00 2001 From: Tahosin Date: Sun, 23 Aug 2026 22:23:39 +0600 Subject: [PATCH 1/2] fix(openai_agents): patch get_all_tools to capture function calls accurately Fixes missing hook in the openai_agents integration that prevents Sentry from capturing dynamic tool calls when using the openai Swarm/Agents SDK. --- sentry_sdk/integrations/openai_agents/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sentry_sdk/integrations/openai_agents/__init__.py b/sentry_sdk/integrations/openai_agents/__init__.py index 94c5ecc7a5..4eb107dbb9 100644 --- a/sentry_sdk/integrations/openai_agents/__init__.py +++ b/sentry_sdk/integrations/openai_agents/__init__.py @@ -143,6 +143,18 @@ def new_wrapped_get_model( agents.run_internal.run_loop.get_model = new_wrapped_get_model + if hasattr(run_loop, "get_all_tools"): + original_get_all_tools = run_loop.get_all_tools + @wraps(original_get_all_tools) + async def new_wrapped_get_all_tools( + agent: "agents.Agent", context_wrapper: "agents.RunContextWrapper" + ) -> "list[agents.Tool]": + return await _get_all_tools( + original_get_all_tools, agent, context_wrapper + ) + agents.run_internal.run_loop.get_all_tools = new_wrapped_get_all_tools + + if turn_resolution is not None: original_execute_handoffs = turn_resolution.execute_handoffs From ecb315d1509849a7815be5df2207ea61a4447915 Mon Sep 17 00:00:00 2001 From: Tahosin Date: Sun, 23 Aug 2026 22:52:51 +0600 Subject: [PATCH 2/2] fix(openai_agents): correctly patch turn_preparation.get_model instead of run_loop --- sentry_sdk/integrations/openai_agents/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/openai_agents/__init__.py b/sentry_sdk/integrations/openai_agents/__init__.py index 4eb107dbb9..b704ed3d0c 100644 --- a/sentry_sdk/integrations/openai_agents/__init__.py +++ b/sentry_sdk/integrations/openai_agents/__init__.py @@ -143,7 +143,7 @@ def new_wrapped_get_model( agents.run_internal.run_loop.get_model = new_wrapped_get_model - if hasattr(run_loop, "get_all_tools"): + if not use_run_hooks and hasattr(run_loop, "get_all_tools"): original_get_all_tools = run_loop.get_all_tools @wraps(original_get_all_tools) async def new_wrapped_get_all_tools(