You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 95d9645
Browse filesBrowse the repository at this point in the historyBrowse files
## Summary
Observe local tool failures without sending application exceptions to
the model. Previously, logging inside a handler missed
argument-validation failures before invocation and serialization
failures after it returned:
```python
with client.beta.agents.sessions.stream(
SESSION_ID, input="Find catalog item A123.", tool_handlers=handlers,
) as stream:
stream.until_done()
```
Now attach an optional observer alongside the handlers:
```python
def report_tool_error(failure):
logger.error(
"Tool %s failed during %s (call %s)",
failure.tool_name, failure.stage, failure.call_id,
)
with client.beta.agents.sessions.stream(
SESSION_ID, input="Find catalog item A123.", tool_handlers=handlers,
on_tool_error=report_tool_error,
) as stream:
stream.until_done()
```
The beta `AgentToolError` carries the original local exception, failure
stage, and call identifiers. `AsyncOpenAI` also accepts awaitable
observers. Ordinary observer exceptions do not prevent submission of the
sanitized tool failure; cancellation and API/stream errors retain their
existing propagation. No automatic logging is added.
0 commit comments