修改mcp协议
This commit is contained in:
parent
2a243202c9
commit
7615bd36ca
@ -93,6 +93,7 @@ async def enhanced_generate_stream_response(
|
|||||||
chunk_id = 0
|
chunk_id = 0
|
||||||
message_tag = ""
|
message_tag = ""
|
||||||
current_tool_name = ""
|
current_tool_name = ""
|
||||||
|
current_is_ui_tool = False
|
||||||
last_answer_first_char_duration_ms = None
|
last_answer_first_char_duration_ms = None
|
||||||
waiting_for_answer_first_char = False
|
waiting_for_answer_first_char = False
|
||||||
agent, checkpointer, sandbox = await init_agent(config)
|
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)
|
chunk_args = tool_call_chunk.get("args") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "args", None)
|
||||||
if chunk_name:
|
if chunk_name:
|
||||||
current_tool_name = chunk_name
|
current_tool_name = chunk_name
|
||||||
|
current_is_ui_tool = False
|
||||||
# Always output ui:// protocol tool calls even when tool_response is disabled
|
# 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 '')
|
# Detect ui:// in chunk args; once detected, all subsequent chunks for this tool are UI
|
||||||
if config.tool_response or is_ui_tool:
|
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:
|
if chunk_name:
|
||||||
new_content = f"[{message_tag}] {chunk_name}\n"
|
new_content = f"[{message_tag}] {chunk_name}\n"
|
||||||
if chunk_args:
|
if chunk_args:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user