feat(dispatcher): Eino 采纳 Phase B —— ReAct 智能体 + MCP 工具自主调用
agent 节点带 autonomous:true 时走 ReAct(flow/agent/react),模型在
推理-工具循环里自行决定调哪些 MCP 工具,而非只跑画死的工具节点。
- 新增 eino/react_agent.go:mcpTool 把 MCP 工具(NATS)适配成
components/tool.InvokableTool;agentTools 暴露 wiki_search +
recall_user_memory(context 参数 user_id 服务端注入,不暴露给模型);
runReactAgent 流式回流答复,工具调用经适配器落 ExecEvent 轨迹。
- LLM 接口 + *llm.Pool 增 ToolCallingModel()(openai 组件实现
model.ToolCallingChatModel);fakeLLM 同步桩(返回 nil → 降级普通对话)。
- graph.go:agent 节点按 autonomous 开关分流 ReAct / 普通;自主 agent
不预注入画像(让其经 recall_user_memory 工具按需自取)。
关键修复:默认 StreamToolCallChecker 只看首个流片段,deepseek 常先吐
文本再给 tool call 致漏判 → 改 streamHasToolCall 扫整段流(命中率 ~0→7/7)。
验收:自主工具调用 7/7 命中,args={} 证明注入生效,完整闭环跑通;
make test-go 全绿。已知 eval 看不到工具结果会误判 agent(Phase C 修)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,14 @@ func (p *Pool) model() model.BaseChatModel {
|
||||
// Ready 报告是否已配置可用后端(且 ChatModel 构建成功)。
|
||||
func (p *Pool) Ready() bool { return p.model() != nil }
|
||||
|
||||
// ToolCallingModel 返回支持函数调用的模型(用于 ReAct agent);未就绪 / 不支持则 nil。
|
||||
func (p *Pool) ToolCallingModel() model.ToolCallingChatModel {
|
||||
if tcm, ok := p.model().(model.ToolCallingChatModel); ok {
|
||||
return tcm
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ModelName 返回当前激活的对话模型名(未配置则空)—— 供服务状态面板展示。
|
||||
func (p *Pool) ModelName() string {
|
||||
if cfg := p.config(); cfg != nil {
|
||||
|
||||
Reference in New Issue
Block a user