feat(cozeloop): add ADK agent support for tracing#705
Open
shentongmartin wants to merge 1 commit intomainfrom
Open
feat(cozeloop): add ADK agent support for tracing#705shentongmartin wants to merge 1 commit intomainfrom
shentongmartin wants to merge 1 commit intomainfrom
Conversation
Need to create a new tagThe following modules have changes and may need version updates:
|
03026dd to
4bbb672
Compare
Need to create a new tagThe following modules have changes and may need version updates:
|
- 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
4bbb672 to
26c93e6
Compare
Need to create a new tagThe following modules have changes and may need version updates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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: AddedparseAgentInput,parseAgentOutput, and serialization helpers for agent eventstrace_handler.go: Added agent-specific handling in OnStart/OnEnd with baggage propagationgo.mod/go.sum: Updated eino to v0.8.0-alpha.14 and cozeloop-go to v0.1.20adk_data_parser_test.go: Comprehensive tests for agent data parsingadk_trace_handler_test.go: Tests for agent trace handler integration概要
关键洞察
ADK agent 输出是异步的 - 事件通过迭代器传递,需要被消费。实现通过在 agent 组件时使用 goroutine 处理输出,允许在所有事件收集并序列化后完成 trace span。
序列化方案将复杂的嵌套结构(AgentEvent、AgentAction、InterruptInfo、InterruptCtx)扁平化为简单的 map,可作为 trace 属性存储,同时保留了关键的调试信息,如运行路径、中断上下文和转移动作。~