eino icon indicating copy to clipboard operation
eino copied to clipboard

[ADK] Add structured AgentEvent types for debugging, tracing and durable event logs

Open wucm667 opened this issue 7 months ago • 2 comments

Summary

I would like to propose adding structured event types and metadata to ADK AgentEvent.

Eino ADK currently exposes agent execution through AsyncIterator[*AgentEvent], which is very useful. However, for debugging, tracing, UI rendering, and durable event logs, applications often need to distinguish different event kinds in a stable way.

Motivation

When building an agent runtime or service layer on top of Eino, developers need to observe and persist events such as:

  • Agent start/end
  • Model start/end
  • Model stream delta
  • Tool start/end
  • Tool stream delta
  • Agent transfer
  • Interrupt
  • Resume
  • Error
  • Final answer

Currently, users can infer some of this from AgentEvent.Output, AgentEvent.Action, and callbacks, but there is no single structured event taxonomy that can be used reliably by UIs, tracing systems, or durable event stores.

Proposed Design

Add an explicit event type field and structured metadata to AgentEvent.

A rough shape could be:

type AgentEventType string

const (
    AgentEventAgentStart AgentEventType = "agent_start"
    AgentEventAgentEnd AgentEventType = "agent_end"
    AgentEventModelStart AgentEventType = "model_start"
    AgentEventModelEnd AgentEventType = "model_end"
    AgentEventModelDelta AgentEventType = "model_delta"
    AgentEventToolStart AgentEventType = "tool_start"
    AgentEventToolEnd AgentEventType = "tool_end"
    AgentEventToolDelta AgentEventType = "tool_delta"
    AgentEventTransfer AgentEventType = "transfer"
    AgentEventInterrupt AgentEventType = "interrupt"
    AgentEventResume AgentEventType = "resume"
    AgentEventError AgentEventType = "error"
)

type AgentEvent struct {
    Type AgentEventType
    AgentName string
    RunPath []RunStep
    Output *AgentOutput
    Action *AgentAction
    Err error
    Metadata map[string]any
}

The exact API does not have to match this sketch, but having a stable event taxonomy would be very helpful.

Expected Benefits

  • Easier debugging for complex multi-agent workflows
  • Easier integration with tracing systems such as Langfuse/Cozeloop/OpenTelemetry
  • Easier implementation of WebSocket/SSE agent service layers
  • Easier durable event storage and replay
  • Better compatibility with visual debugging tools

Related Issues / PRs

This request is related to existing observability and debugging needs, including:

  • #603: Langfuse trace information missing
  • #614: Framework is powerful but hard to debug
  • #590: Agent callbacks and Multi-Agent definition for ADK

This issue is intended to focus specifically on a stable ADK event taxonomy and event metadata model.

wucm667 avatar Apr 24 '26 12:04 wucm667

This still requires a public taxonomy/compatibility decision before implementation. SessionEventVariant is now the durable session-event model (#1106), while TurnID was subsequently removed in #1121. Adding an independent AgentEventType would otherwise create a second event classification system whose relationship to persisted session events is undefined. A minimal implementation can expose a stable kind derived from existing output/action/error variants, but maintainers need to decide whether that kind mirrors SessionEventVariant or remains a separate UI-facing taxonomy, and whether lifecycle events such as model/tool start/end belong in AgentEvent or callbacks.

March-77 avatar Jul 24 '26 06:07 March-77

I implemented a first increment of this and opened #1231.

Design decision: rather than emitting brand-new agent_start/model_start/tool_start events (which would require adding lifecycle-boundary emission points and is more invasive), the first pass adds an additive Type AgentEventType field to TypedAgentEvent and populates it at the existing central constructors:

  • model/tool messages (end vs. delta) via typedEventFromMessage / EventFromAgenticMessage
  • interrupt actions via TypedInterrupt/StatefulInterrupt/CompositeInterrupt
  • exit / transfer / break-loop actions at the action-attachment points
  • every terminal error event (~30 sites)

This gives UIs, tracers (Langfuse/Cozeloop/OTel) and durable event stores a stable taxonomy today, while staying purely additive — the zero value AgentEventUnknown means existing consumers and persisted checkpoints are unaffected.

agent_start/model_start/tool_start are left as a follow-up since they need new emission points. Happy to adjust naming/scope to whatever the maintainers prefer.

Ethanz11-creat avatar Aug 30 '26 16:08 Ethanz11-creat