Skip to content

Commit 7497381

Browse files
authored
Merge pull request #3 from XiaoMa-PM/main
fix(miniMaster2.0): 添加 Generator 循环最大迭代限制并完善依赖声明
2 parents de2c757 + 1c36a47 commit 7497381

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

code/miniMaster2.0/main_agent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,17 @@ def call_validate_agent(prompt: str, model_name: str, client: OpenAI) -> str:
347347
# 🟡 第二层循环:Generator (任务执行与生成)
348348
generator_memory = WorkingMemory(keep_latest_n=8, max_chars=80000)
349349
gen_step = 0
350+
max_gen_iter = 20 # Generator 单任务最大迭代次数,防止验证失败时无限重试
350351

351352
while True:
352353
gen_step += 1
353354
print(f"\n 🔧 Generator 第 {gen_step} 步")
354355

356+
if gen_step > max_gen_iter:
357+
print(f" ⚠️ Generator 达到最大迭代次数 {max_gen_iter},强制结束当前任务")
358+
to_do_list.update_task_status(curr_task_name, "DONE")
359+
break # 结束第二层循环,回到第一层循环 (Plan-Agent)
360+
355361
if generator_memory.check_needs_summary():
356362
pending_memories = generator_memory.get_memories_to_summarize()
357363
print(f" 🧠 检测到记忆滑出窗口,正在进行批量压缩...")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
python-dotenv>=1.0.0
2+
openai>=1.0.0
3+
langsmith>=0.1.0

0 commit comments

Comments
 (0)