fix(graph): subagent overallState history#4306
Open
mengnankkkk wants to merge 2 commits intoalibaba:mainfrom
Open
fix(graph): subagent overallState history#4306mengnankkkk wants to merge 2 commits intoalibaba:mainfrom
mengnankkkk wants to merge 2 commits intoalibaba:mainfrom
Conversation
|
@mengnankkkk 按照当前的实现方式,是不是另外添加一个接口: public interface DeltaAwareKeyStrategy extends KeyStrategy {
Object computeDelta(Object currentValue, Object newValue);
}然后再在 NodeExecutor 中判断 instanceof 更合适?这样子可以把逻辑分到具体的 strategy 中实现,也便于后续扩展。 |
|
另外还有一个问题,如 文档 | 使用编译的子图作为并行节点 所示: StateGraph workflow = new StateGraph(keyStrategyFactory)
.addNode("A", makeNode("A"))
.addNode("A1", node_async(state -> subgraphA1.invoke(state.data()).orElseThrow().data()))
.addNode("A2", makeNode("A2"))
// 通过以下方式并行的子图无法处理 delta 的情况
.addNode("A3", node_async(state -> subgraphA3.invoke(state.data()).orElseThrow().data()))
.addNode("B", makeNode("B"))
.addEdge("A", "A1")
.addEdge("A", "A2")
.addEdge("A", "A3")
.addEdge("A1", "B")
.addEdge("A2", "B")
.addEdge("A3", "B")
.addEdge(START, "A")
.addEdge("B", END);通过适配器模式进行子图的并行运行时,当前的处理方法可能无法覆盖这种情况。 |
|
注意到问题的根本原因是子图的返回是全量数据,而非增量数据。 所以,是不是可以转变一下思路,不从最终的结果反推 delta,而是一开始就在 OverallState 中记录 delta 呢?
如果大家认为“内建 Delta 视图”的方案可行,我很乐意分担这部分的开发工作。不管是作为当前 PR 的补充提交,还是等这个 PR 合并后,我再拉一个独立的重构 PR 都可以。 期待各位的专业意见! |
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.
Describe what this PR does / why we need it
因为子图和主图共享的是一个overallState 所以,子图返回的是完整的状态,这部分父图已经有了!所以应该是增量添加,不是全量添加,这样就解决了对应的重复问题了
Does this pull request fix one issue?
Close #4305
Describe how you did it
Describe how to verify it
Special notes for reviews