Skip to content

feat(cozeloop): add ADK agent support for tracing#705

Open
shentongmartin wants to merge 1 commit intomainfrom
feat/cozeloop_agent
Open

feat(cozeloop): add ADK agent support for tracing#705
shentongmartin wants to merge 1 commit intomainfrom
feat/cozeloop_agent

Conversation

@shentongmartin
Copy link
Contributor

Summary

Problem Solution
CozeLoop callback does not support ADK Agent tracing Added agent input/output parsing with run/resume mode support
Agent events and actions not captured in traces Implemented serialization for agent events, actions, and interrupt info
Agent context not propagated across spans Set agent_name in span baggage for context propagation

Key Insight

The ADK agent output is asynchronous - events are delivered via an iterator that needs to be consumed. The implementation handles this by processing output in a goroutine when the component is an agent, allowing the trace span to complete after all events are collected and serialized.

The serialization approach flattens complex nested structures (AgentEvent, AgentAction, InterruptInfo, InterruptCtx) into simple maps that can be stored as trace attributes, while preserving the essential debugging information like run paths, interrupt contexts, and transfer actions.

Changes

  • data_parser.go: Added parseAgentInput, parseAgentOutput, and serialization helpers for agent events
  • trace_handler.go: Added agent-specific handling in OnStart/OnEnd with baggage propagation
  • go.mod/go.sum: Updated eino to v0.8.0-alpha.14 and cozeloop-go to v0.1.20
  • adk_data_parser_test.go: Comprehensive tests for agent data parsing
  • adk_trace_handler_test.go: Tests for agent trace handler integration

概要

问题 解决方案
CozeLoop callback 不支持 ADK Agent 追踪 添加了支持 run/resume 模式的 agent 输入/输出解析
Agent 事件和动作未被记录到追踪中 实现了 agent 事件、动作和中断信息的序列化
Agent 上下文未在 span 间传递 在 span baggage 中设置 agent_name 用于上下文传递

关键洞察

ADK agent 输出是异步的 - 事件通过迭代器传递,需要被消费。实现通过在 agent 组件时使用 goroutine 处理输出,允许在所有事件收集并序列化后完成 trace span。

序列化方案将复杂的嵌套结构(AgentEvent、AgentAction、InterruptInfo、InterruptCtx)扁平化为简单的 map,可作为 trace 属性存储,同时保留了关键的调试信息,如运行路径、中断上下文和转移动作。~

@github-actions
Copy link

Need to create a new tag

The following modules have changes and may need version updates:

  • callbacks/cozeloop (Current: callbacks/cozeloop/v0.1.8)

⚠️ Please create and push new version tags for these modules after merging this PR.

@github-actions
Copy link

Need to create a new tag

The following modules have changes and may need version updates:

  • callbacks/cozeloop (Current: callbacks/cozeloop/v0.1.8)

⚠️ Please create and push new version tags for these modules after merging this PR.

- Add agent input/output parsing for cozeloop callback
- Support both run and resume modes for agent tracing
- Serialize agent events, actions, and interrupt info
- Set agent_name in span baggage for context propagation
- Handle async output parsing with goroutine for agent component
- Update eino to v0.8.0-alpha.14 and cozeloop-go to v0.1.20
- Add comprehensive unit tests for ADK integration~

Change-Id: Ic3120a9fb1f999ee8f708149416913c39bf1f53a
@github-actions
Copy link

Need to create a new tag

The following modules have changes and may need version updates:

  • callbacks/cozeloop (Current: callbacks/cozeloop/v0.1.8)

⚠️ Please create and push new version tags for these modules after merging this PR.

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.

1 participant