修改mcp协议

This commit is contained in:
朱潮 2026-05-19 18:54:37 +08:00
parent 2a243202c9
commit 7615bd36ca

View File

@ -93,6 +93,7 @@ async def enhanced_generate_stream_response(
chunk_id = 0
message_tag = ""
current_tool_name = ""
current_is_ui_tool = False
last_answer_first_char_duration_ms = None
waiting_for_answer_first_char = False
agent, checkpointer, sandbox = await init_agent(config)
@ -114,9 +115,12 @@ async def enhanced_generate_stream_response(
chunk_args = tool_call_chunk.get("args") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "args", None)
if chunk_name:
current_tool_name = chunk_name
current_is_ui_tool = False
# Always output ui:// protocol tool calls even when tool_response is disabled
is_ui_tool = isinstance(chunk_args, str) and '"ui://' in (chunk_args or '')
if config.tool_response or is_ui_tool:
# Detect ui:// in chunk args; once detected, all subsequent chunks for this tool are UI
if isinstance(chunk_args, str) and '"ui://' in chunk_args:
current_is_ui_tool = True
if config.tool_response or current_is_ui_tool:
if chunk_name:
new_content = f"[{message_tag}] {chunk_name}\n"
if chunk_args: