Agent App registered as an MCP server: every tools/call fails
还没有人认领这个 Issue。
评估
调研方向
Start in api/core/mcp/server/streamable_http.py and trace handle_mcp_request, process_mapping_response, and extract_structured_output for AppMode.AGENT. Compare the Agent App stream in AgentAppRunner._publish_terminal_answer with legacy agent-chat events, then verify tools/call returns the persisted answer, structuredContent, and errors for failed runs without changing existing agent-chat results.
由索引模型根据 Issue 内容生成。
描述
What happens
An Agent App (AppMode.AGENT, the app type backed by an Agent Soul) can be published as an MCP server from the console. tools/list works and returns the tool, but every tools/call fails. The client receives:
{"jsonrpc": "2.0", "id": 1, "error": {"code": -32602, "message": "Agent App only supports streaming mode"}}
Steps to reproduce
- Create and publish an Agent App.
- Register it as an MCP server. The console endpoint (
api/controllers/console/app/mcp_server.py) has no app-mode filter, so Agent Apps are accepted. - Call the tool from any MCP client.
Where it comes from
api/core/mcp/server/streamable_http.py never requests a streaming run for this mode:
streaming=app.mode == AppMode.AGENT_CHAT,
Agent Apps reject blocking generation (api/core/app/apps/agent_app/app_generator.py:89), so the call stops there.
Streaming mode alone is not enough
The stream parser only accumulates agent_thought events. Agent Apps publish their answer on the chat message channel instead (AgentAppRunner._publish_terminal_answer -> publish_text_answer -> QueueLLMChunkEvent), so just enabling streaming produces a successful tool result with an empty answer, which is worse than a visible error. Two details matter for whoever picks this up:
- Agent App
agent_messageevents carry in-progress stream text that can differ from the terminal answer, and theiragent_thoughtrows hold reasoning, so neither channel is the answer. - Legacy agent-chat sends the same text through both
agent_thoughtandagent_message. Accumulating both by event name doubles every existing agent-chat answer.
extract_structured_output and process_mapping_response in the same file also have no AppMode.AGENT arm: the former returns None (so 2025-06-18 clients get no structuredContent), the latter raises ValueError: Invalid app mode: agent.
Executed evidence
Probing the module's public entry points on main (fea6b6e9), no server needed:
1) process_mapping_response(app, {'answer': ...})
-> ValueError: Invalid app mode: agent
2) extract_structured_output(app, {'answer': 'hi'}, 'hi')
-> None
3) answer extracted from a real Agent App stream
-> answer=''
4) AgentAppGenerator.generate(streaming=False)
-> AgentAppGeneratorError: Agent App only supports streaming mode
5) tools/call through handle_mcp_request
-> {'jsonrpc': '2.0', 'id': 1, 'error': {'code': -32602, 'message': 'Agent App only supports streaming mode'}}
Probe 3 feeds the real SSE shape the app emits (agent_message deltas plus a terminal message chunk) and shows the answer would be empty even once streaming is enabled.
Expected behavior
tools/call returns the answer the app itself persists for the message, plus structuredContent for 2025-06-18 clients. A failed run should reach the client as an error rather than as an empty successful result.
- 主要语言
- TypeScript
- 星标
- 157k
- 派生
- 24.7k
- 平均合并
- 22 小时 32 分钟
- 30 天内合并 PR
- 611
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
langgenius/dify 的其他 Issue
-
Annotation Reply: a stored score threshold of 0.0 is silently replaced with 1, disabling the feature 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42639 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 70/100
langgenius/dify#42468 · 1 条评论 · 1 个 reaction ·
-
🐞 bug
难度 2/5 1-3 小时 新手友好度 86/100
langgenius/dify#42446 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42355 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42350 · 1 条评论 · 1 个 reaction ·
相似的 Issue
-
calcite-components needs triage refactor
难度 2/5 1-3 小时 新手友好度 75/100
Esri/calcite-design-system#15203 ·
-
难度 2/5 1-3 小时 新手友好度 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 78/100
Automattic/studio#4908 ·
-
难度 2/5 1-3 小时 新手友好度 90/100