Merge branch ‘master’ of gitlink.org.cn:miangder/yzmxdzntxzddkxtxztcdygxjyjz
┌──────────────────────────────────────────────────────────────────┐ │ main.py (Entry Point) │ ├──────────────────────────────────────────────────────────────────┤ │ orchestrator.py (LangGraph + LangChain) │ │ ┌──────────┬──────────┬──────────┬──────────────────┐ │ │ │ Planner │Retriever │ Executor │ Summarizer │ │ │ │ Agent │ Agent │ Agent │ Agent │ │ │ │ │ ↑ reuse │ │ │ │ │ │ │ shortcut│ │ │ │ │ └──────────┴──────────┴──────────┴──────────────────┘ │ ├──────────────────────────────────────────────────────────────────┤ │ protocol/ state_transfer/ memory/ │ │ ├─ messages.py ├─ embedding.py ├─ shared_memory.py│ │ ├─ scheduler.py ├─ vector_pool.py (+) ├─ reuse_controller│ │ └─ binary_serializer(+)| SharedVectorPool │ .py (+) │ │ Protobuf wire format numpy memmap pool │ ├──────────────────────────────────────────────────────────────────┤ │ proto/ (+) evaluation/ │ │ └─ agent_protocol.proto├─ metrics.py │ │ Message schema ├─ reporter.py │ │ └─ dashboard.py (+) │ │ shared_state/ (+) Runtime CLI Dashboard │ │ └─ vec_*.npy │ └──────────────────────────────────────────────────────────────────┘ (+) = New in v2.0
取代了需要进行Token切分和解析的JSON文本消息:
JSON: {"action":"search","parameters":{"query":"..."}} → Token切分→解析 Protobuf: 0A 06 73 65 61 72 63 68 12 ... →二进制→直接解析
proto/agent_protocol.proto
BinaryProtocolSerializer
不同于在消息中内联传递庞大的嵌入(Embedding)数组,系统将向量写入共享的 numpy memmap 池中,并通过引用进行交换:
智能体 A: vec = embed(output) → pool.put(vec) → 返回 "vec_a1b2c3.npy" → 发送: {"state_ref": "vec_a1b2c3.npy"} ← O(1) 开销 智能体 B: 接收 "vec_a1b2c3.npy" → pool.get(ref) → 通过 mmap 加载 ← 零拷贝
这直接回应了此类系统所强调的重点:
系统不会总是执行完整的智能体流水线,而是会先检查现有记忆是否能满足当前任务:
Planner → [复用检查: 置信度 > 0.85?] ├─ 是 → 跳过 Retriever,直接使用缓存结果 │ 节省: -1 次智能体调用, -800 tokens, -2s 延迟 └─ 否 → 正常流水线: Retriever → Executor → Summarizer
MemoryReuseController 会追踪:
MemoryReuseController
实时 CLI 可视化,展示以下内容:
test/ ├── README.md ├── requirements.txt ├── config.py ├── main.py ├── orchestrator.py ├── proto/ # (+) Protobuf 模式定义 (Schema) │ └── agent_protocol.proto ├── protocol/ │ ├── messages.py # Pydantic 消息类型 │ ├── scheduler.py # 消息路由与智能体注册 │ ├── binary_serializer.py # (+) Pydantic ↔ Protobuf 桥接 │ └── agent_protocol_pb2.py # (+) 生成的 Protobuf 代码 ├── agents/ │ ├── base_agent.py │ ├── planner_agent.py │ ├── retriever_agent.py │ ├── executor_agent.py │ └── summarizer_agent.py ├── state_transfer/ │ ├── embedding.py # Embedding 引擎与状态传输 │ └── vector_pool.py # (+) 共享向量池 (numpy memmap) ├── memory/ │ ├── shared_memory.py # ChromaDB 持久化记忆 │ └── reuse_controller.py # (+) 记忆复用快捷路径 ├── evaluation/ │ ├── metrics.py │ ├── reporter.py │ └── dashboard.py # (+) 运行时 CLI 仪表盘 ├── tasks/ │ └── task_sets.py └── shared_state/ # (+) 运行时向量池存储 └── vec_*.npy
Bash
pip install -r requirements.txt
export OPENAI_API_KEY="your-api-key" export OPENAI_BASE_URL="https://api.openai.com/v1" # 可选 export LLM_MODEL="gpt-4o-mini" # 可选
python main.py
系统将执行三个阶段:
OPENAI_API_KEY
OPENAI_BASE_URL
[https://api.openai.com/v1](https://api.openai.com/v1)
LLM_MODEL
gpt-4o-mini
EMBEDDING_MODEL
all-MiniLM-L6-v2
在汇报演示中重点强调这些表述:
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
Agent 基础设施运行时:低开销多智能体协作系统Agent
Key Innovations (vs. baseline)
Architecture
核心设计
1. 二进制协议通信 (Protobuf)
取代了需要进行Token切分和解析的JSON文本消息:
proto/agent_protocol.proto中BinaryProtocolSerializer桥接 Pydantic ↔ Protobuf2.共享向量池(状态交换)
不同于在消息中内联传递庞大的嵌入(Embedding)数组,系统将向量写入共享的 numpy memmap 池中,并通过引用进行交换:
这直接回应了此类系统所强调的重点:
3. 记忆复用快捷路径
系统不会总是执行完整的智能体流水线,而是会先检查现有记忆是否能满足当前任务:
MemoryReuseController会追踪:4. 运行时仪表盘
实时 CLI 可视化,展示以下内容:
目录结构
快速上手
1. 安装依赖
Bash
2. 配置环境
Bash
3. 运行实验
Bash
系统将执行三个阶段:
评估指标
环境变量
OPENAI_API_KEYOPENAI_BASE_URL[https://api.openai.com/v1](https://api.openai.com/v1)LLM_MODELgpt-4o-miniEMBEDDING_MODELall-MiniLM-L6-v2核心术语(供答辩/评审使用)
在汇报演示中重点强调这些表述: