🐛 fix: 修复 prompt 模板花括号转义及 tool_call_chunk 安全访问
- prompt 中 JSON 示例的 {} 被 str.format() 误解析为模板变量,转义为 {{}}
- tool_call_chunk 改用 .get() 安全访问,避免 KeyError
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
044749e2ce
commit
2216b01dcb
@ -21,7 +21,7 @@ The filesystem backend is currently operating in: `{agent_dir_path}`
|
||||
- **Tools** (e.g., `rag_retrieve`, `read_file`, `bash`): Directly callable via tool_call interface with structured parameters.
|
||||
- **Skills** (e.g., `baidu-search`, `pdf`, `xlsx`): Multi-step workflows executed by: (1) reading SKILL.md, (2) extracting the command, (3) running it via the `bash` tool.
|
||||
|
||||
❌ WRONG: Generating a tool_call with `{"name": "baidu-search", "arguments": {...}}`
|
||||
❌ WRONG: Generating a tool_call with `{{"name": "baidu-search", "arguments": {{...}}}}`
|
||||
✅ CORRECT: Using `read_file` to read SKILL.md, then using `bash` to execute the script
|
||||
|
||||
If you see a skill name in the "Available Skills" list, it is NEVER a tool you can call directly.
|
||||
|
||||
@ -90,7 +90,7 @@ The todo list is a planning tool - use it judiciously to avoid overwhelming the
|
||||
- **Tools** (e.g., `rag_retrieve`, `read_file`, `bash`): Directly callable via tool_call interface with structured parameters.
|
||||
- **Skills** (e.g., `baidu-search`, `pdf`, `xlsx`): Multi-step workflows executed by: (1) reading SKILL.md, (2) extracting the command, (3) running it via the `bash` tool.
|
||||
|
||||
❌ WRONG: Generating a tool_call with `{"name": "baidu-search", "arguments": {...}}`
|
||||
❌ WRONG: Generating a tool_call with `{{"name": "baidu-search", "arguments": {{...}}}}`
|
||||
✅ CORRECT: Using `read_file` to read SKILL.md, then using `bash` to execute the script
|
||||
|
||||
If you see a skill name in the "Available Skills" list, it is NEVER a tool you can call directly.
|
||||
|
||||
@ -102,10 +102,12 @@ async def enhanced_generate_stream_response(
|
||||
message_tag = "TOOL_CALL"
|
||||
if config.tool_response:
|
||||
for tool_call_chunk in msg.tool_call_chunks:
|
||||
if tool_call_chunk["name"]:
|
||||
new_content = f"[{message_tag}] {tool_call_chunk['name']}\n"
|
||||
if tool_call_chunk['args']:
|
||||
new_content += tool_call_chunk['args']
|
||||
chunk_name = tool_call_chunk.get("name") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "name", None)
|
||||
chunk_args = tool_call_chunk.get("args") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "args", None)
|
||||
if chunk_name:
|
||||
new_content = f"[{message_tag}] {chunk_name}\n"
|
||||
if chunk_args:
|
||||
new_content += chunk_args
|
||||
# 处理文本内容
|
||||
elif msg.content:
|
||||
preamble_completed.set()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user