You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: RequireUserConfirmEvent is published before agent_state is persisted — a crash in the window loses the durable ASKING #3621
When a permission gate suspends tool calls (pending non-empty), ReActAgent's acting path publishes RequireUserConfirmEvent to event subscribers in-stream (the Flux ends in .doOnNext(this::publishEvent)), while the ASKING transition is only persisted by saveStateToSessionafter the call completes.
Order today (agentscope-core, ReActAgent → actingStream):
updateToolCallStates(...) marks ToolCallState.ASKING in the in-memory context
persistPendingRequestReplyId(...) records the reply identity in Msg metadata
RequireUserConfirmEvent + RequestStopEvent(PERMISSION_ASKING) are emitted — subscribers (SSE transports, dashboards) receive the approval prompt immediately
Only later does the call tail run saveStateToSession → agent_state save
If the process dies between steps 3 and 4 — a sub-second window on local disk, but real under load or a remote state store — the approval prompt is already user-visible and durable in consumer-side transcripts, while the persisted agent_state contains no ASKING.
Why it matters
A host that restart-recovers pending approvals reads ASKING tool calls from agent_state. After such a crash:
The consumer-side transcript/audit already records the approval prompt (a user may even have clicked "approve" on a live frame).
The persisted runtime state has no suspended tool call — there is no resume owner.
The host must fail closed ("runtime lost") for a prompt it already surfaced, which reads to the user as an approval that can never be completed.
We hit this in a real acceptance run: killing the host immediately after the REQUIRE_USER_CONFIRM SSE frame arrives intermittently left agent_state.json without asking while the transcript contained the prompt row; post-restart the pending-approvals inbox still re-listed it, but continuation had to fail closed.
Same family as #3619 (fresh-runtime denied ConfirmResult not consumed): ASK-state persistence ordering vs. its visible surface.
Requested change
Make the suspension durable before it becomes observable — either:
persist agent_state (or at least the ASKING transition + reply identity) before RequireUserConfirmEvent is published, or
publish RequireUserConfirmEvent only after the suspension-state save completes (a durable-then-publish ordering for PERMISSION_ASKING stops).
Alternatively, an explicit hook where a host can force a checkpoint at suspension time (related to the mid-turn checkpoint seam requested in #3620) would also close the hole.
Activity
xihongshichaojidan8 commentedon Oct 21, 2026
我在当前 main(
997c60ac)上验证了这个时序窗口:收到RequireUserConfirmEvent时,新建 Agent 尚无法恢复待授权工具;原调用结束后则可以。旧状态存储和原生 Session Log 两条路径结果一致,目前验证的是事件顺序,尚未做实际进程崩溃测试。我想尝试一个限定范围的修复:在权限暂停边界,先持久化 ASKING 状态和 replyId;原生日志同时提交待确认请求,再对外发布授权提示。不引入通用 checkpoint API。请问是否已有相关工作,以及这个修复边界是否合适?
fix(core): 在发布授权请求前持久化暂停状态 (agentscope-ai#3699)