fix(ai写作): 继续从checkpoint续跑(修resume_is_map) + 刷新=重置不重连
后端 worker(runtime/runs/worker.py): 空 command(无 resume/update/goto)不再构造
Command()(会因无挂起 interrupt 抛 'resume_is_map' 未绑定错误),改为 astream(None)
让 Pregel 续跑 checkpoint 里挂起的当前阶段节点。有 resume/update/goto 时(4个干预卡)
仍走 Command,行为不变。前端"继续"发空 command:{} 即从当前阶段续跑、不回 intent。
按用户要求把"断网/刷新自动重连续跑"整套移除(刷新=重置即可):
- 删 sessionStorage 持久化 + reconnectTargetRef + 恢复/持久化 effect + host rehydrate
- 删 buildRehydrateSnapshot/rehydrate action(保留 clear_streaming)
- 提交去掉 onDisconnect:'continue'/streamResumable;reconnectOnMount 改 false
- 卸载不再自动后台挂起;刷新断 SSE 后端默认 cancel 取消 run,页面回 idle
手动暂停/继续保留:暂停=stream.stop(),继续=clear_streaming+空command 从checkpoint续。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9f462beec5
commit
8385d1913a
4 files changed
+30
-157
No files matched your search
@@ -282,13 +282,25 @@ async def run_agent(
|
||||
# 起新一轮。Pregel 检查到 Command 会从最近 checkpoint 处恢复,而不是重头跑。
|
||||
stream_input: Any = graph_input
|
||||
if command is not None:
|
||||
from langgraph.types import Command as _LGCommand
|
||||
# 有 resume/update/goto(如 AI 写作 4 个干预卡的 Command(resume=user_input))→
|
||||
# 构造 langgraph.types.Command,Pregel 从 interrupt 处恢复。
|
||||
# **空 command(无任何指令)= "从最近 checkpoint 继续执行挂起的任务"**:AI 写作
|
||||
# "暂停后继续" —— 暂停时硬取消了活跃节点(非 interrupt),continue 要让该阶段节点
|
||||
# 从 checkpoint 续跑。此时必须用 **None 输入**让 Pregel resume pending tasks;
|
||||
# 既不能用 graph_input={}(空 dict 被当新一轮输入 → 从图入口 intent 重跑),也不能
|
||||
# 构造 Command()(没有挂起的 interrupt 可消费,LangGraph 内部会抛
|
||||
# "cannot access local variable 'resume_is_map'")。
|
||||
has_directive = any(command.get(k) is not None for k in ("resume", "update", "goto"))
|
||||
if has_directive:
|
||||
from langgraph.types import Command as _LGCommand
|
||||
|
||||
stream_input = _LGCommand(
|
||||
resume=command.get("resume"),
|
||||
update=command.get("update"),
|
||||
goto=command.get("goto"),
|
||||
)
|
||||
stream_input = _LGCommand(
|
||||
resume=command.get("resume"),
|
||||
update=command.get("update"),
|
||||
goto=command.get("goto"),
|
||||
)
|
||||
else:
|
||||
stream_input = None
|
||||
|
||||
if len(lg_modes) == 1 and not stream_subgraphs:
|
||||
# Single mode, no subgraphs: astream yields raw chunks
|
||||
|
||||
Reference in new issue
Block a user