8000 Set tool span to failed if an error is raised in the tool by antonpirker · Pull Request #4527 · getsentry/sentry-python · GitHub
[go: up one dir, main page]

Skip to content

Set tool span to failed if an error is raised in the tool #4527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sentry_sdk
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
from sentry_sdk.scope import should_send_default_pii

from ..consts import SPAN_ORIGIN
Expand Down Expand Up @@ -39,5 +39,10 @@ def update_execute_tool_span(span, agent, tool, result):
# type: (sentry_sdk.tracing.Span, agents.Agent, agents.Tool, Any) -> None
_set_agent_data(span, agent)

if isinstance(result, str) and result.startswith(
"An error occurred while running the tool"
):
span.set_status(SPANSTATUS.INTERNAL_ERROR)

if should_send_default_pii():
span.set_data(SPANDATA.GEN_AI_TOOL_OUTPUT, result)
Loading
0