fix(python-sdk): make the minimal profile an explicit allowlist

Give the SDK JSON-RPC server a per-root tool filter and let deployments mark the configured persona as the complete system prompt. The checked-in minimal overlay now names only bash and str_replace_editor, so later global tools and unrelated guidance from dsh-base cannot appear implicitly.

Keep the shared SDK host services and packaged Web capability intact. Only workspace instructions, compaction, and the conflicting one-shot Bash row remain disabled. Unit coverage pins the configuration paths, and a real dsh profile smoke proves the assembled prompt and exact two-tool request.
This commit is contained in:
Tianyi Cui
2026-08-24 17:28:28 +08:00
parent d801f262d8
commit c2ad69344f
32 changed files with 327 additions and 93 deletions
+2 -2
View File
@@ -19,12 +19,12 @@ python examples/python-sdk-agent/minimal.py \
兼容代理使用 `DEEPSEEK_BASE_URL`,默认模型使用 `DSH_MODEL`deployment persona 使用 `DSH_SYSTEM_PROMPT``--model``--profile` 会覆盖脚本默认值。所选 home 保存生成的 profile,并在 `sessions/` 下保存 Zstandard 会话日志;脚本绝不会隐式读取 `~/.dsh`
[`minimal.patch.yml`](minimal.patch.yml) 是随附 SDK profile 上的有序 overlay。它保留 SDK 应用 bundle,但将模型可见行为收窄为
[`minimal.patch.yml`](minimal.patch.yml) 是随附 SDK profile 上的有序 overlay。其根 agent 工具 allow 列表只暴露
- agent 所有的持久 `bash`
- 支持 `view``create``str_replace``insert``str_replace_editor`
该 patch 会省略 Harness 身份与运行时上下文消息、本地指令发现、skill、compaction,以及 plangoaltaskwebsubagentworkflow 工具和 profile 的单次 Bash。它插入本地 PTY 与持久 Bash provider,并 editor 输出上限设为 16,000 字符。
Allow 列表会排除当前及以后出现的其他所有全局工具,无需为每个基础配置项添加 disable。完整部署 persona 会抑制无关工具的引导段;运行时上下文消息、本地指令发现、compaction 与存在名称冲突的单次 Bash 配置项会分别停用。该 overlay 会插入本地 PTY 与持久 Bash provider,并 editor 输出上限设为 16,000 字符。其他 SDK profile 服务仍保持挂载,包括持久化、策略、settings、credentials 与 provider。
此变体刻意只支持 POSIX。其持久 PTY 与 editor 可以修改运行时进程可访问的任何路径,因此只应在一次性 checkout 或容器中使用。