fix: prevent duplicate user message on session recovery re-publish

The re-published last user message was persisted into session history a
second time when the agent loop processed it, duplicating the user's
input. Mark the re-published InboundMessage with SKIP_USER_PERSIST_META
so should_persist_user_message() and _save_skip_for_turn() treat it as
already-persisted.
This commit is contained in:
nanobot
2026-07-31 15:37:41 +08:00
parent 66b8743024
commit c7270b8d81
+6
View File
@@ -2151,6 +2151,12 @@ class AgentLoop:
sender_id=chat_id,
chat_id=chat_id,
content=last_user_msg["content"],
# The message already exists in session history
# (persisted before the crash); skip persisting it
# again so recovery does not duplicate it.
metadata={
turn_continuation.SKIP_USER_PERSIST_META: True
},
)
)
logger.info(