fix: S1-S4 建议项修复 — 类型标注精确化+BaseTaskHandler标注后续PR+token预算说明
This commit is contained in:
@@ -351,7 +351,7 @@ for vp in TaskTypeRegistry.virtual_projects():
|
||||
|
||||
- 新建 `src/daemon/task_type_registry.py`:`TaskTypeHandler` Protocol + `TaskTypeRegistry`
|
||||
- 新建 `src/daemon/prompt_composer.py`:`PromptSection` Protocol + `PromptContext` + `PromptComposer`
|
||||
- 新建 `src/daemon/base_task_handler.py`:`BaseTaskHandler` 基类(VerifyResult + post_complete 统一流程 + _rollback_current_agent)
|
||||
- 新建 `src/daemon/base_task_handler.py`:`BaseTaskHandler` 基类(VerifyResult + post_complete 统一流程 + _rollback_current_agent)[将在 Step 2 PR 实现]
|
||||
- 编写单元测试验证:注册/查询、section 排序/去重/条件过滤、基类 post_complete 流程
|
||||
- **风险**:极低,纯新增文件,不改动现有代码
|
||||
|
||||
@@ -689,6 +689,8 @@ src/daemon/
|
||||
| L3 | 被动参考层 | Skills 索引注入,Agent 按需 read 全文 | OpenClaw 42 Skills + moziplus SkillRegistry | 按需 |
|
||||
| L4 | 检索层 | Agent 运行时主动检索 | wiki 知识库、NAS 文档、Web 搜索 | 按需 |
|
||||
|
||||
> **注**:表中 token 数为估算值。`prompt_composer.py` 中 `TOKEN_BUDGET_WARN=800` 是警告阈值(超出时打日志但不截断),与表中 ~1500 估算值不矛盾——800 对应单个 handler 的典型 L2 注入量,1500 对应最复杂场景(TaskHandler 全量 5 sections)的估算上限。
|
||||
|
||||
**PromptComposer 是 L2 层的拼装机制**。
|
||||
|
||||
## L1-L4 去重规则
|
||||
|
||||
@@ -81,14 +81,14 @@ class PromptComposer:
|
||||
CHARS_PER_TOKEN = 3.5 # 估算比率
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._sections: List[Any] = [] # List[PromptSection]
|
||||
self._sections: List[PromptSection] = []
|
||||
|
||||
def add(self, section: Any) -> None:
|
||||
def add(self, section: PromptSection) -> None:
|
||||
"""添加一个 section(同名覆盖)"""
|
||||
self._sections = [s for s in self._sections if s.name != section.name]
|
||||
self._sections.append(section)
|
||||
|
||||
def add_many(self, sections: List[Any]) -> None:
|
||||
def add_many(self, sections: List[PromptSection]) -> None:
|
||||
"""批量添加"""
|
||||
for s in sections:
|
||||
self.add(s)
|
||||
|
||||
Reference in New Issue
Block a user