Skip to content

Add OnAgentErrorCallback for error observability #709

@jlapenna

Description

@jlapenna

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions