Add OnAgentErrorCallback for error observability
- Dominant language
- Go
- Stars
- 8.8k
- Forks
- 1k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 88
Description
## Feature Request
We need a mechanism in the ADK framework to intercept errors that occur during agent execution (e.g., in `agent.Run`). This is crucial for enabling observability metrics, such as tracking agent failure counts in plugins.
## Rationale
Currently, there is no standardized way for plugins to listen for or handle errors yielded by `agent.Run`. This makes it difficult to implement cross-cutting concerns like failure metrics or centralized error logging within the ADK ecosystem without modifying individual agent implementations.
## Proposed Solution
Introduce an `OnAgentErrorCallback` mechanism:
- Allow registering `OnAgentErrorCallback` in `Config` and `Plugin`.
- Update `agent.Run` to trigger these callbacks when an error occurs.
- Broadcast errors to all registered plugins via `PluginManager`.
This will allow an observability plugin to increment an error counter whenever an agent fails, providing valuable telemetry.
## Reference Implementation
See PR #708 for the proposed implementation.
Contributor guide
Assessment
This issue has not been assessed yet.