Skip to content

game工作流一直循环调用save_file #509

@825sun

Description

@825sun

Polish_Developer 连续几十轮调用 save_file,始终只传空字符串
arguments: {} → 工具抛 ValueError → 系统把错误写回对话 → LLM 再次调用 save_file → 继续空字符串,死循环永不结束。
【根因】
LLM 没有生成代码正文
它只输出自然语言(“I will enhance...”),没有真正写出 Python 代码;因此每次构造的 content=""。
Prompt 缺少“强制代码块”约束
原 prompt 只要求“Call save_file with path='game.py' and complete enhanced code”,没有明确告诉它“必须先写出完整代码字符串再调用”。
错误回显不足以触发自我修正
即使把空参数回写给模型,它仍选择继续空调用,而不是补全代码。
【已验证的破局思路】
A. 在 prompt 里加“硬栅栏”
明确要求:
“Before calling save_file, you MUST output the full enhanced code between triple backticks python ... .
If save_file fails, re-generate the code block and call again.”
B. 把代码生成拆成两步节点
CodeWriter:只负责输出代码字符串(用 return 而非 save_file)
Polish_Developer:拿到代码后再 save_file
失败时回到 CodeWriter 重写,循环即断。
C. 限制空参数调用次数
在 _execute_tool_batch 里对同一 tool_call_id 计数,连续 N 次空参后直接 break 并给 workflow 返回失败,让上层节点重新生成。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions