Skip to content

Commit 7656727

Browse files
committed
refactor(agui): replace addition mode enum with merge options for flexible event merging
This change replaces the AdditionMode enum with MergeOptions for more flexible control over how addition fields are merged with event data. The StreamStateMachine class is introduced to handle streaming state management, improving tool call handling and UUID resolution in copilotkit compatibility mode. The protocol handlers are updated to use the new merge options instead of the rigid enum-based approach. This provides better flexibility for merging additional fields while maintaining backward compatibility through the merge helper function. feat: 使用 MergeOptions 替换 AdditionMode 枚举以实现灵活的事件合并 此变更使用 MergeOptions 替换 AdditionMode 枚举,以实现对附加字段如何与事件数据合并的更灵活控制。引入了 StreamStateMachine 类来处理流状态管理,改进了在 copilotkit 兼容模式下的工具调用处理和 UUID 解析。协议处理器已更新以使用新的合并选项,而不是基于枚举的刚性方法。 这为合并附加字段提供了更好的灵活性,同时通过合并助手函数保持向后兼容性。 Change-Id: Ic84a5a9b743e7bedbc75e5938248b34348f17591 Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent 737bbc3 commit 7656727

File tree

11 files changed

+538
-526
lines changed

11 files changed

+538
-526
lines changed

agentrun/integration/langgraph/agent_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def _filter_tool_input(tool_input: Any) -> Any:
210210
# 跳过内部字段
211211
if key in _TOOL_INPUT_INTERNAL_KEYS:
212212
continue
213-
# 跳过以 __ 开头的字段(Python 内部属性
214-
if key.startswith("__"):
213+
# 跳过所有下划线前缀的内部字段(包含单下划线与双下划线
214+
if key.startswith("_"):
215215
continue
216216
filtered[key] = value
217217

agentrun/server/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@
114114
... return "Hello, world!"
115115
"""
116116

117+
from ..utils.helper import MergeOptions
117118
from .agui_normalizer import AguiEventNormalizer
118119
from .agui_protocol import AGUIProtocolHandler
119120
from .model import (
120-
AdditionMode,
121121
AgentEvent,
122122
AgentEventItem,
123123
AgentRequest,
@@ -166,7 +166,6 @@
166166
"ToolCall",
167167
# Event Types
168168
"EventType",
169-
"AdditionMode",
170169
# Type Aliases
171170
"AgentEventItem",
172171
"AgentResultItem", # 兼容别名
@@ -187,4 +186,6 @@
187186
"AGUIProtocolHandler",
188187
# Event Normalizer
189188
"AguiEventNormalizer",
189+
# Helpers
190+
"MergeOptions",
190191
]

0 commit comments

Comments
 (0)