Commit 5b8e9e00 by sunqi02

feat: clear intent_session on actionable/casual/ignore; keep on incomplete

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent bd3d6a57
...@@ -140,6 +140,12 @@ class MessageGate: ...@@ -140,6 +140,12 @@ class MessageGate:
# 按 msg_id 移除本批次 # 按 msg_id 移除本批次
ids = [m["msg_id"] for m in pending if "msg_id" in m] ids = [m["msg_id"] for m in pending if "msg_id" in m]
buffer.remove_by_msg_ids(ids) buffer.remove_by_msg_ids(ids)
# 清空 intent_session 并持久化
data = store.get(session_id) or {}
data["intent_session"] = ""
store.set(session_id, data)
self.session_service.save_to_db(session_id)
return return
if decision.intent == "casual": if decision.intent == "casual":
...@@ -344,6 +350,12 @@ class MessageGate: ...@@ -344,6 +350,12 @@ class MessageGate:
mem = SessionMemory(session_id, store) mem = SessionMemory(session_id, store)
mem.add("user", merged_text) mem.add("user", merged_text)
mem.add("assistant", decision.reply, agent_code=self.main_agent_key) mem.add("assistant", decision.reply, agent_code=self.main_agent_key)
# 清空 intent_session
data = store.get(session_id) or {}
data["intent_session"] = ""
store.set(session_id, data)
self.session_service.save_to_db(session_id) self.session_service.save_to_db(session_id)
await self.post_reply_hook.execute({ await self.post_reply_hook.execute({
"agent_name": self.main_agent_key, "agent_name": self.main_agent_key,
...@@ -399,6 +411,13 @@ class MessageGate: ...@@ -399,6 +411,13 @@ class MessageGate:
logger.warning("[MessageGate] session=%s actionable 但无 query,跳过", session_id) logger.warning("[MessageGate] session=%s actionable 但无 query,跳过", session_id)
return return
# 清空 intent_session(AgentHub 内部的 save_to_db 会顺带写库)
from app.infrastructure.session_store import SessionStore
store = SessionStore()
data = store.get(session_id) or {}
data["intent_session"] = ""
store.set(session_id, data)
# 提取 file_url(兼容 image 和 file 类型) # 提取 file_url(兼容 image 和 file 类型)
file_url = None file_url = None
for m in pending: for m in pending:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!