Go to file
caoqianming 7d6109b932 feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30)
触发条件已满足(diag_tool_repeat.py 实测 document_search 122 次地毯搜 /
mp_search 562 次占主上下文大头)。形态 = 一个工具 delegate(instruction):
复用现成 AgentLoop 起空上下文子循环,只注只读/落盘检索白名单,硬轮数上限 20,
固定降 flash 档,跑完只把文字结论返主循环。主循环视角 = 一次普通 tool call
(零并行/零状态共享/深度 1 禁递归)。

对标 Claude Code / Agent SDK subagent:照抄 fresh-context / allowlist 工具 /
只返回最终消息 / maxTurns;有意砍掉并行与嵌套(§6 拒编排),采纳 per-subagent
模型 override 思路(降 flash)。

实现:
- core/delegate.py(新):DELEGATE_ALLOWED 白名单 + FilteredExecutor(包父
  executor 只暴露白名单∩已注册,backend 无关、delegate 不入表天然禁递归)+
  run_delegate(懒加载 AgentLoop 避 litellm 导入/循环 import)
- tools/delegate.py(新):DelegateTool schema 载体,execute 防御性 no-op
- core/loop.py:_run_delegate + _execute_tool_call 内建拦截(拦在 executor 前,
  要读活的 self.llm/caps/executor)+ usage_kind(记账 kind 区分)+
  delegate_model_factory(降档失败降级父模型)+ 内存态子循环禁折叠守卫
  (防 persist_fold 按主 task_id 污染主上下文状态)
- core/session.py:persist=False 内存态(复用主 task_id 计费归主 task、
  消息不入库不污染主流不撞 idx)
- core/agent_builder.py:注册工具 + _delegate_model 工厂(载 deepseek_v4.flash)

落地决策:① 白名单给"落盘检索"(document_download/mp_get_*)写口、不给
write/edit/run_python/shell;② 不引 Redis 抗重启(run 本进程绑定,值钱抓取数据
已落 FS,真要抗重启走 §8.12 bg-proc);③ 未收敛显式标注不当完成。

前端零结构改动(既有工具卡 spinner+跳秒覆盖不冻屏),只加 toolActivityLabel 的
delegate case。skills/brief 加 delegate 引导。tests/test_delegate.py +8
(FilteredExecutor 过滤/拒穿透/交集 + 白名单不变量 + Session persist);loop 全
路径要 litellm 本机跑不了靠生产手验(同 salvage)。DESIGN §8.11 标 。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-15 14:43:04 +08:00
config fix(sandbox): pids-limit 256→1024 修容器内 mermaid 渲染必崩(bump 0.58.2) 2026-07-11 09:02:45 +08:00
core feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
db/migrations feat(context): §8.8 Phase 2 长会话中段折叠摘要 + 头部压缩指示环(bump 0.54.1) 2026-07-09 12:39:31 +08:00
deploy feat(sandbox): 镜像补 file 命令(bump 0.58.12) 2026-07-13 08:50:55 +08:00
docs docs: 操作说明书精简版表格微调 + 新增「科研AI双智能体·汇报PPT大纲」+ bump 0.24.4 2026-06-24 14:57:57 +08:00
prompts/system docs(prompt): system prompt 加通用 context 纪律,堵大块输出滚雪球(bump 0.32.5) 2026-06-29 14:56:44 +08:00
rendering feat(rendering): 平台渲染层 rendering/ 统一三 skill docx + chromium md→pdf + bump 0.21.0 2026-06-23 13:07:19 +08:00
scripts fix(exec): run_python script_path 宿主预检+前缀容错+code 落盘回退(bump 0.58.22) 2026-07-13 16:41:43 +08:00
skills feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
tests feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
tools feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
web feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
.gitattributes Add .gitattributes: force LF for shell + Dockerfile 2026-05-26 10:45:17 +08:00
.gitignore feat: 忽略vscodecounter 2026-07-07 15:38:55 +08:00
CHANGELOG.md fix(web): 对话正文文件锚点两处回归——含·的 pptx 丢 chip + 链接点击整页404(bump 0.58.29) 2026-07-15 13:40:12 +08:00
CLAUDE.md feat(changelog): 用户版更新日志 CHANGELOG.md + /v1/changelog + 点版本号弹层(bump 0.55.0) 2026-07-09 16:49:26 +08:00
DESIGN.md feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
DOCUMENT_SEARCH_API.md feat(skill): documents skill 接内部材料学科知识库(document_search API) 2026-05-21 15:31:21 +08:00
EMBED.md feat(wecom): 企业微信应用主页免登进 embed 控制台(bump 0.44.0) 2026-07-07 10:09:52 +08:00
PROGRESS.md feat(delegate): §8.11 最小子循环——上下文隔离的检索子助手(bump 0.58.30) 2026-07-15 14:43:04 +08:00
RUN.md feat(ops+web): run 级错误持久提示+失败聚集+provider 致命错误即时告警(bump 0.58.21) 2026-07-13 14:06:29 +08:00
SCIENTIFIC_SKILLS.md skills: 加 pymatgen / stats_ml / plot_pub(建材院无机材料场景) 2026-05-28 11:33:59 +08:00
SKILL_LIST.md feat(prompt): 结构图 mermaid vs 生图改 ask_user 让用户点选(bump 0.58.15) 2026-07-13 10:18:48 +08:00
WW_verify_THssshZfneJwIG5Y.txt chore(wecom): 加企业微信可信域名校验文件 WW_verify_THssshZfneJwIG5Y.txt(放 repo 根)+ bump 0.26.7 2026-06-25 10:25:06 +08:00
alembic.ini core(§7 B Step 1): Storage 基建 — SQLAlchemy ORM + alembic + db CLI 2026-05-14 10:41:44 +08:00
main.py feat(web): main.py web 支持 --ssl-certfile/--ssl-keyfile(uvicorn 原生 TLS,免 nginx)+ bump 0.26.8 2026-06-25 10:43:18 +08:00
requirements.txt feat(sandbox): 补 olefile/xlrd/extract-msg 老格式解析依赖(bump 0.58.23) 2026-07-15 08:16:18 +08:00