Skip to content

feat(adk): add structured AgentEventType taxonomy to AgentEvent - #1231

Open
Ethanz11-creat wants to merge 2 commits into
cloudwego:mainfrom
Ethanz11-creat:feat/adk-agent-event-type
Open

feat(adk): add structured AgentEventType taxonomy to AgentEvent#1231
Ethanz11-creat wants to merge 2 commits into
cloudwego:mainfrom
Ethanz11-creat:feat/adk-agent-event-type

Conversation

@Ethanz11-creat

Copy link
Copy Markdown

Closes #997

Adds a stable, documented event taxonomy to ADK AgentEvent so applications can reliably distinguish event kinds for debugging, tracing, UI rendering and durable event logs — without inferring them from Output/Action/Err.

What changed

TypedAgentEvent[M] gains an additive Type AgentEventType field (zero value AgentEventUnknown, so existing consumers and persisted checkpoints are unaffected), plus the following taxonomy:

Constant Meaning Populated from
AgentEventModelEnd / ModelDelta model output (final / streaming chunk) typedEventFromMessage, EventFromAgenticMessage
AgentEventToolEnd / ToolDelta tool result (final / streaming chunk) same
AgentEventAgentEnd Exit action action attachment
AgentEventTransfer transfer-to-agent action attachment
AgentEventBreakLoop break-loop action action attachment
AgentEventInterrupt interrupt action TypedInterrupt/StatefulInterrupt/CompositeInterrupt + Runner reconstruction
AgentEventError terminal error every error emission point (~30 sites)
AgentEventResume reserved for future resume events not emitted yet

Type is set at the framework's central constructors (typedEventFromMessage, EventFromAgenticMessage) and action-attachment points (typedEventSenderToolWrapper, sendTransferEvents, Runner interrupt reconstruction), so it is populated uniformly across the message and AgenticMessage paths.

Scope note

agent_start / model_start / tool_start are intentionally deferred: they require new emission points at lifecycle boundaries rather than tagging existing events, and are better as a follow-up so this change stays purely additive and low-risk. This PR establishes the taxonomy and metadata model the issue asks for.

Tests

  • adk/event_type_test.go covers message/tool/agentic type mapping, action classification (exit/transfer/interrupt/break-loop), and interrupt event typing.
  • Full go test ./adk/... passes.

Add a reusable ADK middleware that connects the agent lifecycle hooks to an
application-provided MemoryStore, so long-running agents can retrieve and
inject long-term memory before a run and optionally write facts or summaries
back after a run.

The middleware injects memory once per run (before the first model call) to
avoid re-injecting on every tool-call loop, resolves a configurable memory
namespace in BeforeAgent, and delegates persistence decisions to a WritePolicy
invoked in AfterAgent.

Memory backend implementations stay outside eino core; the middleware only
depends on the MemoryStore interface (closes cloudwego#995).
Add an explicit, stable event-type taxonomy to TypedAgentEvent so that
applications can reliably distinguish agent lifecycle, model, tool, transfer,
interrupt and error events for debugging, tracing (Langfuse/Cozeloop/OTel), UI
rendering and durable event logs.

The new AgentEvent.Type field is additive and defaults to the zero value
(AgentEventUnknown), so existing consumers and persisted events are unaffected.

Type is populated at the framework's central event constructors:
- message events (model/tool, streaming or not) via typedEventFromMessage and
  EventFromAgenticMessage
- interrupt actions via TypedInterrupt/StatefulInterrupt/CompositeInterrupt
- action events (exit/transfer/break-loop) when the action is attached
- every terminal error event

Lifecycle start events (agent_start/model_start/tool_start) require new
emission points and are intentionally deferred to a follow-up (closes cloudwego#997).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant