myagent-ai 1.15.44 → 1.15.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/main_agent.py +4 -30
- package/package.json +1 -1
package/agents/main_agent.py
CHANGED
|
@@ -1249,36 +1249,10 @@ class MainAgent(BaseAgent):
|
|
|
1249
1249
|
)
|
|
1250
1250
|
break
|
|
1251
1251
|
|
|
1252
|
-
# finish=false:
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
_current_round = _v2_reasoning_collected[_reasoning_len_before_round:]
|
|
1257
|
-
if _current_round:
|
|
1258
|
-
final_text = "\n".join(_current_round)
|
|
1259
|
-
if current_task_plan:
|
|
1260
|
-
final_text += f"\n\n{current_task_plan}"
|
|
1261
|
-
elif _v2_reasoning_collected:
|
|
1262
|
-
final_text = "\n".join(_v2_reasoning_collected)
|
|
1263
|
-
if current_task_plan:
|
|
1264
|
-
final_text += f"\n\n{current_task_plan}"
|
|
1265
|
-
else:
|
|
1266
|
-
final_text = "已完成所有操作。"
|
|
1267
|
-
if current_task_plan:
|
|
1268
|
-
final_text += f"\n\n任务计划:\n{current_task_plan}"
|
|
1269
|
-
context.working_memory["final_response"] = final_text
|
|
1270
|
-
# [v1.15.8] 跳过已发送的 reasoning 文本,避免 TTS 重复播报
|
|
1271
|
-
if not _emitted_reasoning_this_iter:
|
|
1272
|
-
await self._emit_v2_event("v2_reasoning", {"content": truncate_str(final_text, 3000)}, stream_callback)
|
|
1273
|
-
if self.memory:
|
|
1274
|
-
self.memory.add_session(
|
|
1275
|
-
session_id=context.session_id,
|
|
1276
|
-
role="assistant",
|
|
1277
|
-
content=final_text,
|
|
1278
|
-
)
|
|
1279
|
-
break
|
|
1280
|
-
|
|
1281
|
-
logger.info(f"[{task_id}] finish=false 且 need_callback=true,回调 LLM...")
|
|
1252
|
+
# finish=false: 必须继续回调 LLM,无论工具 callback 设置如何
|
|
1253
|
+
# callback 只控制工具结果是否喂回 LLM,不控制循环是否继续
|
|
1254
|
+
# 只有 finish=true 才应该终止循环
|
|
1255
|
+
logger.info(f"[{task_id}] finish=false,继续回调 LLM...")
|
|
1282
1256
|
|
|
1283
1257
|
# 回调前,保存当前轮次的 LLM 输出到会话记忆
|
|
1284
1258
|
# 这样每轮工具调用都有对应的 assistant 消息记录
|