-
Notifications
You must be signed in to change notification settings - Fork 710
feat: Agent callbacks and Multi-Agent definition for adk #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
8061819 to
58ffba4
Compare
📊 Coverage Report: |
|
Does this PR resolve/relate to #513? |
Yes, this pr, combined with further prs in eino-ext, will resolve the issues here. |
818b8c4 to
52ba21c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #590 +/- ##
==========================================
+ Coverage 80.36% 80.65% +0.29%
==========================================
Files 124 126 +2
Lines 11906 12176 +270
==========================================
+ Hits 9568 9821 +253
- Misses 1607 1613 +6
- Partials 731 742 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5019423 to
0f2c0cf
Compare
|
|
||
| // BypassIterator creates a goroutine that simply passes events from the input iterator to the output generator. | ||
| // This is useful when you need to do something without modifying events. | ||
| func BypassIterator(iter *AsyncIterator[*AgentEvent], gen *AsyncGenerator[*AgentEvent]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要大写吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要的吧,这个也是实现方可能用到的方法,内部反而目前没有使用。
当前不提供 utils 我觉得也 ok。
adk/agent_middleware.go
Outdated
| Messages []Message | ||
| } | ||
|
|
||
| type EntranceType string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RunType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我再考虑下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InvocationType?
adk/agent_middleware.go
Outdated
|
|
||
| // internal properties, read only | ||
| agentName string | ||
| entrance EntranceType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指的是当前这个 Agent 是 Run/Resume ,还是 Runner 入口是 Run/Resume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前者,不该有后者这个概念吧,Agent 不感知 Runner
| continue | ||
| } | ||
| dedup[mw.Name] = struct{}{} | ||
| helper.beforeAgentFns = append(helper.beforeAgentFns, mw.BeforeAgent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mw.BeforeAgents, mw.OnEvents 判空?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bydesign,BeforeAgents 第 n 个立刻返回时,前 n-1 个 OnEvents 要执行,设置空的 func 是为了 padding index,判空由运行时处理
| if termIter != nil { | ||
| return termIter | ||
| } | ||
| // TODO: set back input in runCtx ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要,这个是 mw 实现方需要用到的方法
What type of PR is this?
feat
Check the PR title.
<type>(optional scope): <description>(Optional) Translate the PR title into Chinese.
feat: 为 ADK 引入 Agent 与 Runner 的 Callback 能力
(Optional) More detailed description for this PR (en / zh).
en:
AgentMiddleware:BeforeAgentandOnEventsAgentMiddlewareCheckerinterface. If an agent implementsAgentMiddlewareCheckerand enables agent middlewares internally, hooks run inside the agent; otherwise, agent middlewares are executed by the flowAgent.flowAgent/ChatModelAgent/workflowAgentRun/Resume adapt to middleware aspect execution, with partial refactoring ofChatModelAgentto adapt to runtime middleware injection and execution.Plan-ExecuteandSupervisorAgentglobalAgentMiddlewaresto inject the same middleware at the outermost layer of all agent runtimes from a global perspective.Multi-Agentstructure, at the same conceptual level asChatModelAgent/WorkflowAgents, to solve the problem that Agent operations are at a flat level and difficult to observe inTransferAgentscenarios.flowAgentadapts toMulti-AgentoperationSupervisor Agentconstructor returnsMulti-AgentWithGraphCallbacksAgentRunOption, which provides eino graph/chain callback injection inside an agent (mainly forChatModelAgent).NewAsyncOnSingleEventHandler,NewSyncOnSingleEventHandler,BypassIterator) for event processing.zh:
AgentMiddleware中新增切面:BeforeAgent和OnEventsAgentMiddlewareChecker接口用于检查 Agent 是否支持内部运行AgentMiddleware。如果支持,AgentMiddleware将在 Agent 内部运行(由 Agent 自行实现运行逻辑);否则将由 flowAgent 在 Agent 外部运行。globalAgentMiddlewares,以全局角度向所有 agent 运行时最外侧注入相同的中间件Multi-Agent结构,概念层级与ChatModelAgent/WorkflowAgents一致,用于解决TransferAgent情况下各 Agent 运行处于平铺的层级难以进行观测的问题。flowAgent对Multi-Agent运行进行适配Supervisor Agent构造方法返回Multi-AgentWithGraphCallbacksAgentRunOption,提供向 Agent 内部的 graph/chain 运行 eino callback 的能力(主要面向 ChatModelAgent)NewAsyncOnSingleEventHandler,NewSyncOnSingleEventHandler,BypassIterator)(Optional) Which issue(s) this PR fixes:
Relates to #513.
To fully resolve the issue here, further adaption in eino-ext is required.
(optional) The PR that updates user documentation:
N/A