mirror of
https://github.com/shareAI-lab/learn-claude-code.git
synced 2026-05-20 18:03:40 +00:00
Update s04_subagent.py
解决在实际运行过程中会出现 block[type=text]的 text 为空导致空转的情况
This commit is contained in:
parent
4b95969a03
commit
a0d2af6712
1 changed files with 5 additions and 0 deletions
|
|
@ -165,6 +165,11 @@ def agent_loop(messages: list):
|
|||
output = handler(**block.input) if handler else f"Unknown tool: {block.name}"
|
||||
print(f" {str(output)[:200]}")
|
||||
results.append({"type": "tool_result", "tool_use_id": block.id, "content": str(output)})
|
||||
elif block.type == "text":
|
||||
if block.text.strip():
|
||||
results.append(block)
|
||||
if not results:
|
||||
return
|
||||
messages.append({"role": "user", "content": results})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue