google / google/adk-go

Add OnAgentErrorCallback for error observability

Open
#709 0 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.