Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
a4fee42
feat(server): 实现 AG-UI 协议和生命周期钩子系统
OhYee Dec 9, 2025
9fa5b61
feat(langchain|langgraph): add AGUI protocol support with async gener…
OhYee Dec 10, 2025
ad1f684
refactor(langgraph): clean up agent converter code formatting and com…
OhYee Dec 10, 2025
1102413
refactor(server): migrate from lifecycle hooks to standardized AgentR…
OhYee Dec 12, 2025
1100905
feat(langgraph): add safe JSON serialization and internal field filte…
OhYee Dec 14, 2025
b5ac402
feat(langgraph): extract original tool_call_id from runtime for consi…
OhYee Dec 14, 2025
ca1bf33
feat(langgraph|langchain): introduce AgentRunConverter for consistent…
OhYee Dec 15, 2025
144cdd7
feat(agui): introduce AG-UI event normalizer and enhance tool call ev…
OhYee Dec 15, 2025
3da214c
refactor(langchain): reorder imports in langgraph agent converter
OhYee Dec 15, 2025
7d31cc7
test(server): update test assertions to handle dynamic response fields
OhYee Dec 15, 2025
3d4a8cd
feat(agui): integrate ag-ui-protocol for standardized event handling
OhYee Dec 15, 2025
fcdedc8
refactor(server): migrate from AgentResult to AgentEvent for protocol…
OhYee Dec 15, 2025
568557b
feat(agui): add error event handling and improve protocol event seque…
OhYee Dec 16, 2025
2a04b26
refactor(langgraph): migrate to AgentRunConverter class and enhance e…
OhYee Dec 16, 2025
bb49df7
style(tests): format AgentRequest initialization and list comprehensions
OhYee Dec 16, 2025
737bbc3
feat(agui): add streaming tool output and HITL support with comprehen…
OhYee Dec 17, 2025
7656727
refactor(agui): replace addition mode enum with merge options for fle…
OhYee Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,34 @@ async def deploy_multiple_agents():

# 运行
agents = asyncio.run(deploy_multiple_agents())

### 8. 变更后的类型检查要求

所有由 AI(或自动化 agent)提交或修改的代码变更,必须在提交/合并前后执行静态类型检查,并在变更记录中包含检查结果摘要:

- **运行命令**:使用项目根目录的 mypy 配置运行:

```bash
mypy --config-file mypy.ini .
```

- **必需项**:AI 在每次修改代码并准备提交时,必须:
- 运行上述类型检查命令并等待完成;
- 若检查通过,在提交消息或 PR 描述中写入简短摘要(例如:"类型检查通过,检查文件数 N");
- 若检查失败,AI 应在 PR 描述中列出前 30 条错误(或最关键的若干条),并给出优先修复建议或自动修复方案。

- **CI 行为**:项目 CI 可根据仓库策略决定是否将类型检查失败作为阻断条件;AI 应遵从仓库当前 CI 策略并在 PR 中说明检查结果。

此要求旨在保证类型安全随代码变更持续得到验证,减少回归并提高编辑器与 Copilot 的诊断可靠性。
```

### 9. 运行命令约定

请使用 `uv run ...` 执行所有 Python 相关命令,避免直接调用系统的 `python`。例如:

- `uv run mypy --config-file mypy.ini .`
- `uv run python examples/quick_start.py`

## 常见问题

### Q: Agent Runtime 启动失败怎么办?
Expand Down
3 changes: 0 additions & 3 deletions agentrun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@
# Server
from agentrun.server import (
AgentRequest,
AgentResponse,
AgentResult,
AgentRunServer,
AgentStreamIterator,
AgentStreamResponse,
AsyncInvokeAgentHandler,
InvokeAgentHandler,
Message,
Expand Down
23 changes: 22 additions & 1 deletion agentrun/integration/langchain/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
"""LangChain 集成模块,提供 AgentRun 模型与沙箱的 LangChain 适配。 / LangChain 集成 Module"""
"""LangChain 集成模块

使用 AgentRunConverter 将 LangChain 事件转换为 AG-UI 协议事件:

>>> from agentrun.integration.langchain import AgentRunConverter
>>>
>>> async def invoke_agent(request: AgentRequest):
... converter = AgentRunConverter()
... async for event in agent.astream_events(input_data, version="v2"):
... for item in converter.convert(event):
... yield item

支持多种调用方式:
- agent.astream_events(input, version="v2") - 支持 token by token
- agent.stream(input, stream_mode="updates") - 按节点输出
- agent.astream(input, stream_mode="updates") - 异步按节点输出
"""

from agentrun.integration.langgraph.agent_converter import (
AgentRunConverter,
) # 向后兼容

from .builtin import model, sandbox_toolset, toolset

__all__ = [
"AgentRunConverter",
"model",
"toolset",
"sandbox_toolset",
Expand Down
4 changes: 2 additions & 2 deletions agentrun/integration/langchain/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def __init__(self):

def wrap_model(self, common_model: Any) -> Any:
"""包装 CommonModel 为 LangChain BaseChatModel / LangChain Model Adapter"""
from httpx import AsyncClient
from langchain_openai import ChatOpenAI

info = common_model.get_model_info() # 确保模型可用
Expand All @@ -32,6 +31,7 @@ def wrap_model(self, common_model: Any) -> Any:
api_key=info.api_key,
model=info.model,
base_url=info.base_url,
async_client=AsyncClient(headers=info.headers),
default_headers=info.headers,
stream_usage=True,
streaming=True, # 启用流式输出以支持 token by token
)
28 changes: 25 additions & 3 deletions agentrun/integration/langgraph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
"""LangGraph 集成模块。 / LangGraph 集成 Module
"""LangGraph 集成模块

提供 AgentRun 模型与沙箱工具的 LangGraph 适配入口。 / 提供 AgentRun 模型with沙箱工具的 LangGraph 适配入口。
LangGraph 与 LangChain 兼容,因此直接复用 LangChain 的转换逻辑。 / LangGraph with LangChain 兼容,因此直接复用 LangChain 的转换逻辑。
使用 AgentRunConverter 将 LangGraph 事件转换为 AG-UI 协议事件:

>>> from agentrun.integration.langgraph import AgentRunConverter
>>>
>>> async def invoke_agent(request: AgentRequest):
... converter = AgentRunConverter()
... async for event in agent.astream_events(input_data, version="v2"):
... for item in converter.convert(event):
... yield item

或使用静态方法(无状态):

>>> from agentrun.integration.langgraph import AgentRunConverter
>>>
>>> async for event in agent.astream_events(input_data, version="v2"):
... for item in AgentRunConverter.to_agui_events(event):
... yield item

支持多种调用方式:
- agent.astream_events(input, version="v2") - 支持 token by token
- agent.stream(input, stream_mode="updates") - 按节点输出
- agent.astream(input, stream_mode="updates") - 异步按节点输出
"""

from .agent_converter import AgentRunConverter
from .builtin import model, sandbox_toolset, toolset

__all__ = [
"AgentRunConverter",
"model",
"toolset",
"sandbox_toolset",
Expand Down
Loading