[Bug]: Graceful-shutdown "duplicate input" dedup unconditionally drops the next user message for interactive clients; no opt-out
Describe the bug
At the start of doCallInner (ReActAgent.java#L1821-L1832):
if (shutdownManager.checkAndClearShutdownInterruptedForState(state)) {
log.info("Detected shutdown-interrupted session for agent {}, discarding duplicate input", getName());
msgs = List.of();
}
During shutdown, ActiveRequestContext.saveState() sets the flag and persists it (ActiveRequestContext.java#L81). The next call on that session then discards its input unconditionally. This assumes the client is automatically retrying the same prompt.
That assumption does not hold for interactive clients such as web chat, IM bots or A2A peers. They do not auto-retry. After a restart, the user's first new message in an interrupted session is silently discarded whatever it says, and the agent "resumes" the old turn instead. From the user's point of view, the message they just sent was ignored.
Before #2712 this check read the wrong state object and never fired. Since 2.0.3 it fires. GracefulShutdownConfig only exposes shutdownTimeout and partialReasoningPolicy, so it cannot be turned off.
To Reproduce
- Start a call on session S and shut the application down while the call is in flight. The interrupted state is persisted.
- Restart and send a different message on session S.
- The log shows "discarding duplicate input". The new message never reaches the context.
Expected behavior
A new message from the user is never discarded. At most, an exact re-send of the interrupted input is deduplicated.
Suggested fix
- Make the dedup configurable in
GracefulShutdownConfig(opt-in, or at least opt-out), and/or - only discard when the incoming input actually matches the interrupted turn's input (by message id, or by content), instead of discarding it unconditionally.
We currently work around this by clearing shutdownInterrupted in our state-store wrapper when loading the state.
Environment
- AgentScope-Java Version: 2.0.4 (also on main @035487e)
- Java Version: 25
- OS: any
Hi, I can take a look at this.
Confirmed on main (ede45eb) with JsonFileAgentStateStore and a fake model: after loading an interrupted session, a different prompt never reaches the model or the saved state.
There is already a test requiring retry input to be dropped, so changing the default directly may break existing behavior. Would a small opt-out that preserves the current default be acceptable, or would you prefer matching a persisted request ID?
Tested with mvn -T1 -pl agentscope-core -am test -Dtest=ReActAgentPerSessionStateTest (23 passed).
感谢复现和认领!
我倾向于按持久化的输入做匹配,而且这和现有那条重试测试并不冲突:框架自己的重试重发的是同一批 Msg 对象,消息 id 与被中断那一轮的输入一致,去重照样生效;变的只是内容不同的新消息不再被吞掉——这正是交互式客户端遇到的实际问题。
具体建议:
ActiveRequestContext.saveState()把会话标记为 shutdown-interrupted 时,顺带把这一轮输入消息的 id 持久化进状态;doCallInner里只有当传入输入的 id 与持久化的 id 一致时才丢弃,无论是否丢弃都清掉标记;- id 缺失时退回按内容比较可以作为补充,但仅靠 id 已经覆盖了重试场景。
GracefulShutdownConfig 里加一个关闭开关作为附加项没问题;但如果只加开关,默认行为仍然会吞掉 Web / IM / A2A 用户重启后发的第一条消息。
回归测试建议在现有重试测试旁边补一条:中断 → 重启 → 发一条不同的提问 → 断言它到达了模型并进入保存的状态。
PR 提了我可以帮忙 review。