Commit 0ff9c174 by sunqi02 Committed by 胡悦

fix: read_pending_messages 仅主Agent可用 + 使用 self.session_service.store

- 使用 self.session_service.store 替代新 SessionStore() 实例
- 在 _build_all_agent_toolkits 中排除非 steward agent

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e374559a
......@@ -468,6 +468,8 @@ class AgentHub:
if tool.group == "basic":
if agent_code == "-1" and name == "call_sub_agent":
continue
if name == "read_pending_messages" and not agent_config.is_steward:
continue
agent_tk.register_tool_function(
tool.original_func,
group_name=tool.group,
......@@ -1003,7 +1005,6 @@ class AgentHub:
def _make_read_pending_messages_tool(self):
"""Create read_pending_messages tool function."""
from app.infrastructure.session_store import SessionStore
async def read_pending_messages() -> ToolResponse:
"""读取在途任务期间到达的新消息。
......@@ -1026,8 +1027,7 @@ class AgentHub:
content=[TextBlock(type="text", text="无新消息")]
)
store = SessionStore()
data = store.get(session_id)
data = self.session_service.store.get(session_id)
if not data:
return ToolResponse(
content=[TextBlock(type="text", text="无新消息")]
......@@ -1041,7 +1041,7 @@ class AgentHub:
# 清空 intent_session
data["intent_session"] = []
store.set(session_id, data)
self.session_service.store.set(session_id, data)
# 构造返回文本
lines = [f"检测到期间有 {len(intent_msgs)} 条新消息:"]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!