getsentry / getsentry/sentry-python

Better way to capture errors in tool execution

Đang mở
#4,526 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Errors Improvement Python
Ngôn ngữ chính
Python
Star
2.2k
Fork
669
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
213

Mô tả

We can not capture exceptions in tool execution here because `_on_invoke_tool` is swallowing the exception here:

[https://github.com/openai/openai-agents-python/blob/main/src/agents/tool.py#L409-L422](https://github.com/openai/openai-agents-python/blob/main/src/agents/tool.py#L409-L422)

And because `function_tool` is a decorator with `default_tool_error_function` set as a default parameter

I was unable to monkey patch it because those are evaluated at module import time and the SDK is too late to patch it. I was also unable to patch `_on_invoke_tool_impl` because it is nested inside this import time code. As if they made it hard to patch on purpose...

Right now we just check if the output of the tool is a string that starts with `"An error occurred while running the tool"` and if so set the spans status to `internal_error`. But we do not have any stack trace or all the other context information. There must be a better way.

Here is the communication I started with OpenAI to improve things:

[https://github.com/openai/openai-agents-python/issues/945](https://github.com/openai/openai-agents-python/issues/945)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.