getsentry / getsentry/sentry-python
Better way to capture errors in tool execution
- 主要語言
- Python
- 星號
- 2.2k
- 分支
- 669
- 平均合併
- 1 天 40 分鐘
- 30 天內合併 PR
- 212
描述
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)
貢獻指南
研究方向
從連結的 openai-agents-python 中的 src/agents/tool.py 第 409-422 行開始,檢視 _on_invoke_tool 和 function_tool 如何使用預設的工具錯誤函式。將該行為與此 repository 中的 Sentry 整合進行比較。完成後應提供工具執行例外的內容,包括堆疊追蹤,而不是依賴傳回的錯誤字串前綴。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- observability
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 35/100