A.1-5 增强 context 管理 — 作用域 / 继承 / 隔离 #28

Open
opened 2026-06-12 21:41:28 +08:00 by orion · 1 comment
Owner

来源

Doc-Code Aligner 差距:Agent 运行时 → v0.2 目标「增强 context 管理」

现状

当前 context 是一个简单的 dict,Agent 间共享 _system 引用,
无作用域规则:

  • agent.py:__init__self.context = {"agent_id": ..., "llm": ..., ...}
  • 可通过 initial_context 注入额外键
  • 但跨 Agent 调用时无隔离

待做

  • 作用域层级:action-local → event-local → agent-level → system-level
  • 继承机制:子状态机自动继承父 context,可覆盖不可删除
  • 隔离保护:read-only 键(如 agent_id/_system)禁止 action 修改
  • 快照与回退:context snapshot / restore 原语
  • 跨 Agent 引用:context["llm"] 从 ModelRegistry 懒加载

估时

中(1-2 天)

## 来源 Doc-Code Aligner 差距:Agent 运行时 → v0.2 目标「增强 context 管理」 ## 现状 当前 context 是一个简单的 `dict`,Agent 间共享 `_system` 引用, 无作用域规则: - `agent.py:__init__` — `self.context = {"agent_id": ..., "llm": ..., ...}` - 可通过 `initial_context` 注入额外键 - 但跨 Agent 调用时无隔离 ## 待做 - [ ] 作用域层级:action-local → event-local → agent-level → system-level - [ ] 继承机制:子状态机自动继承父 context,可覆盖不可删除 - [ ] 隔离保护:read-only 键(如 agent_id/_system)禁止 action 修改 - [ ] 快照与回退:context snapshot / restore 原语 - [ ] 跨 Agent 引用:`context["llm"]` 从 ModelRegistry 懒加载 ## 估时 中(1-2 天)
Author
Owner

评价

设计不够明确: Pipeline 的 context 是共享 dict,Agent 的 context 也是共享 dict——这不是 bug,是特性。如果真要"隔离",需要回答:

  • 隔离到什么粒度?跨 step?跨 Agent?跨 run?
  • 使用场景是什么?(比如"两次 pipeline run 之间的数据残留"?)
  • 隔离后如何共享需要共享的数据?

建议: 当前已经是"共享模式",简单可靠。如果需要隔离:

  1. 先讨论具体场景和设计
  2. 再决定是否做
  3. 避免过度工程

当前不做,设计期。

## 评价 **设计不够明确:** Pipeline 的 context 是共享 dict,Agent 的 context 也是共享 dict——这不是 bug,是特性。如果真要"隔离",需要回答: - 隔离到什么粒度?跨 step?跨 Agent?跨 run? - 使用场景是什么?(比如"两次 pipeline run 之间的数据残留"?) - 隔离后如何共享需要共享的数据? **建议:** 当前已经是"共享模式",简单可靠。如果需要隔离: 1. 先讨论具体场景和设计 2. 再决定是否做 3. 避免过度工程 **当前不做,设计期。**
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bixiu/bixiweave#28
No description provided.