-
Notifications
You must be signed in to change notification settings - Fork 1
System Prompt
Edge adaptation of the upstream system prompt assembly pipeline.
Upstream reference: System Prompt
The system prompt subsystem (ctx.systemPrompt) manages a cooperative assembly pipeline where multiple plugins contribute ordered sections that combine into the final system prompt sent to the model.
-
Section registry — plugins register named sections with a numeric order. Convention:
-100for harness identity,0for deployment persona,100–199for tool guidance. -
Assembly waterfall —
assemble()gathers global and scoped providers, sorts by order, resolves dynamic text, and produces the final prompt. -
Persona — the deployment-level identity section at order
0, set via plugin config. - Change notifications — emitted when any provider changes, triggering re-assembly for the next turn.
SystemPrompt is installed as-is. The section registry, assembly waterfall, change notifications, and tool schema integration are entirely upstream code.
Edge provides its own persona string at order 0:
You are dsh-edge, a coding agent running in a Cloudflare Worker.
Use the bash tool when you need to inspect or modify workspace files,
then answer with the result. Each session has a persistent working
directory that the bash tool defaults to.
The shell is just-bash, not Linux: native binaries and background
processes are unavailable.
This tells the model three critical things about the Edge environment: (1) it's a Cloudflare Worker, (2) the workspace is persistent across turns, (3) the shell is just-bash with no native binaries. Without this, the model would attempt apt-get, pip install, or other Linux commands that don't exist in the Edge runtime.
Upstream tool plugins inject their own sections on top of the persona via the standard ctx.systemPrompt.section() API:
| Section | Order | Plugin | Content|
tool:read |
100 | ToolFs | Use read tool, not cat. Results include line numbers. |
|---|---|---|---|
tool:write |
101 | ToolFs | Use write to create/replace files. Read first. |
| --- | --- | --- | --- |
tool:edit |
102 | ToolFs | Use edit for targeted changes. old_string must be unique. |
| --- | --- | --- | --- |
tool:web_search |
110 | ToolWeb | Search guidance. Adapts text based on fetch availability. |
| --- | --- | --- | --- |
tool:goal |
114 | ToolGoal | Goal creation policy, round limits, blocked threshold. |
Edge does not modify any of these sections. They register themselves when their plugins are installed and unregister when plugins are disposed.
- Section registry, ordering, and assembly waterfall
- Tool schema integration and
knownNamesvisibility filtering - Change notification and re-assembly triggers
- Compression integration (snapshots only record when content differs)
- All upstream tool guidance sections
The assembled system prompt consumes a fixed token budget on every turn. Edge's persona is short (~60 tokens). Each tool section adds 20–50 tokens. With all current plugins (bash, read, write, edit, web_search, goal), the total system prompt is approximately 300–400 tokens — well within DeepSeek's context window.
Assembly runs once per turn start, sorting registered sections and resolving dynamic text. With ~6 sections, this is sub-millisecond. The result is cached until a provider changes.
| Component | Category | Edge Code|
| SystemPrompt plugin | One ctx.plugin() call |
|
|---|---|---|
| EDGE_SYSTEM_PROMPT persona | 5-line string in agent.ts
|
|
| --- | --- | --- |
| Tool guidance sections | Auto-registered by upstream plugins |
Key observation: Edge's only customization is a 5-line persona string that describes the Cloudflare runtime environment. Everything else — section ordering, assembly pipeline, tool guidance, change notifications — is upstream code. The persona is the smallest possible adapter: it tells the model what's different about this deployment without reimplementing any prompt logic.
Update persona for 0.7.x capabilities. (#106) The current persona only mentions bash and workspace. It should describe file tools (read/write/edit), goal tracking, and web search. While these tools register their own sections via ctx.systemPrompt.section(), the persona overview at order 0 gives outdated advice ("Use the bash tool when you need to inspect or modify workspace files").
上游系统提示词组装管线在 Edge 中的适配。
上游参考:System Prompt
系统提示词子系统(ctx.systemPrompt)管理一个协作组装管线,多个插件贡献有序的段落,合并为发送给模型的最终系统提示词。
-
段落注册表 — 插件注册命名段落,带数字排序。约定:
-100为 harness 身份,0为部署 persona,100–199为工具指导。 -
组装瀑布 —
assemble()收集全局和作用域提供者,按顺序排列,解析动态文本,生成最终提示词。 -
Persona — 部署级身份段落,排序
0,通过插件配置设置。 - 变更通知 — 任何提供者变更时发出,触发下一轮的重新组装。
SystemPrompt 原封安装。段落注册表、组装瀑布、变更通知和工具 schema 集成完全是上游代码。
Edge 提供自己的 persona 字符串(排序 0):
You are dsh-edge, a coding agent running in a Cloudflare Worker.
Use the bash tool when you need to inspect or modify workspace files,
then answer with the result. Each session has a persistent working
directory that the bash tool defaults to.
The shell is just-bash, not Linux: native binaries and background
processes are unavailable.
这告诉模型三件关于 Edge 环境的关键信息:(1) 运行在 Cloudflare Worker 上,(2) workspace 跨 turn 持久,(3) shell 是 just-bash,没有原生二进制。没有这个,模型会尝试 apt-get、pip install 等 Edge 运行时不存在的 Linux 命令。
上游工具插件通过标准 ctx.systemPrompt.section() API 在 persona 之上注入自己的段落:
| 段落 | 排序 | 插件 | 内容|
tool:read |
100 | ToolFs | 用 read 工具,不用 cat。结果含行号。 |
|---|---|---|---|
tool:write |
101 | ToolFs | 用 write 创建/替换文件。先读取。 |
| --- | --- | --- | --- |
tool:edit |
102 | ToolFs | 用 edit 做定向修改。old_string 必须唯一。 |
| --- | --- | --- | --- |
tool:web_search |
110 | ToolWeb | 搜索指导。根据 fetch 可用性调整文本。 |
| --- | --- | --- | --- |
tool:goal |
114 | ToolGoal | 目标创建策略、轮次限制、阻塞阈值。 |
Edge 不修改这些段落。它们在插件安装时自动注册,插件卸载时自动取消。
- 段落注册表、排序和组装瀑布
- 工具 schema 集成和
knownNames可见性过滤 - 变更通知和重新组装触发
- 压缩集成(快照仅在内容变化时记录)
- 所有上游工具指导段落
组装后的系统提示词在每轮消耗固定的 token 预算。Edge persona 很短(约 60 token)。每个工具段落增加 20–50 token。当前所有插件(bash、read、write、edit、web_search、goal)的总系统提示词约 300–400 token——远在 DeepSeek 上下文窗口之内。
组装在每轮开始时运行一次,排序已注册段落并解析动态文本。约 6 个段落,亚毫秒完成。结果缓存直到提供者变更。
| 组件 | 分类 | Edge 代码|
| SystemPrompt 插件 | 一行 ctx.plugin() 调用 |
|
|---|---|---|
| EDGE_SYSTEM_PROMPT persona |
agent.ts 中的 5 行字符串 |
|
| --- | --- | --- |
| 工具指导段落 | 上游插件自动注册 |
关键观察:Edge 唯一的定制是一个 5 行的 persona 字符串,描述了 Cloudflare 运行时环境。其他一切——段落排序、组装管线、工具指导、变更通知——都是上游代码。persona 是最小的适配件:告诉模型这个部署有什么不同,不重新实现任何提示词逻辑。
更新 persona 以反映 0.7.x 能力。(#106)当前 persona 只提到了 bash 和 workspace,应该描述文件工具(read/write/edit)、目标追踪和 web 搜索。虽然这些工具通过 ctx.systemPrompt.section() 注册了自己的策略段,但 order 0 的 persona 概述给出了过时的建议("Use the bash tool when you need to inspect or modify workspace files")。
- Home
- Architecture
- Core & Scope
- Session & Persistence
- Model & Context
-
Execution & Tools
- Tools
- Bash
- Subprocess 🚫
- PTY Session 🚫
- Background Jobs 🚫
- Filesystem
- LSP Navigation 🚫
- Code Runtime 🚫
-
Web Access
⚠️ -
Skills
⚠️ - Workflow 🚫
- Subagent 🚫
-
Policy & Interaction
- Goal
- Approval 🚫
- Permission Presets 🚫
-
Sandbox
⚠️ - Plan Mode 🚫
- User Interaction 🚫
- Commands 🚫
- Schedule 🚫
- Message Feedback 🚫
- Platform & Access
- Development
- 首页
- 架构
- 核心与作用域
- 会话与持久化
- 模型与上下文
- 执行与工具
- 策略与交互
- 平台与接入
- 开发