Conversation
引入 ZMQ inproc 消息总线,将 Agent 从一次性请求处理改为常驻 daemon 进程, 支持 DEALER/ROUTER 点对点通信和 PUB/SUB 事件广播。 新增模块 (backend/agentpal/zmq_bus/): - protocol.py: Envelope 消息信封 + MessageType 枚举 + msgpack 序列化 - daemon.py: AgentDaemon 基类 (DEALER + PUB + asyncio.Queue FIFO) - pa_daemon.py: PersonalAssistantDaemon (per-session 常驻) - sub_daemon.py: SubAgentDaemon (按需创建,任务完成后保活) - cron_daemon.py: CronDaemon (全局单例,定时任务结果通知) - manager.py: AgentDaemonManager (ROUTER 路由 + XPUB/XSUB 事件代理 + 生命周期管理) - event_subscriber.py: EventSubscriber (SUB socket async iterator,SSE 桥接) 修改: - main.py: lifespan 中启动/停止 AgentDaemonManager - config.py: 添加 zmq_router_addr/zmq_events_addr 等配置项 - agent.py: /chat 和 /dispatch 端点支持 ZMQ 桥接模式(自动回退) - message_bus.py: hybrid 模式 — DB 审计 + ZMQ 实时投递 - pyproject.toml: 添加 pyzmq>=26.0.0, msgpack>=1.0.0 - test_e2e.py: 修复 networkidle 超时(改用 domcontentloaded) 测试: 43 个 ZMQ 专项测试 (26 unit + 17 integration) 全部通过 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
backend/agentpal/zmq_bus/),将 Agent 从一次性 HTTP 请求处理改为常驻 daemon 进程/chat、/dispatch)自动检测 ZMQ 可用性,优先 ZMQ 桥接,不可用时回退到直接模式架构
新增文件 (8 个模块 + 6 个测试)
zmq_bus/protocol.pyzmq_bus/daemon.pyzmq_bus/pa_daemon.pyzmq_bus/sub_daemon.pyzmq_bus/cron_daemon.pyzmq_bus/manager.pyzmq_bus/event_subscriber.pytests/unit/test_zmq_*.pytests/integration/test_zmq_*.py修改文件
main.pyconfig.pyzmq_router_addr、zmq_events_addr、idle timeout 配置agent.py/chat/dispatch端点 ZMQ 桥接模式 + 自动回退message_bus.pypyproject.tomlpyzmq>=26.0.0、msgpack>=1.0.0test_e2e.pynetworkidle超时(SSE/WS 长连接导致),改用domcontentloadedTest plan
networkidle修复后)🤖 Generated with Claude Code