DSH / Atlas
2026-09-06implementedbug-fixarchived 2026-09-30

Environment facts follow reusable prompt instructions

环境事实位于可复用提示词指令之后

The local Web URL, Harness checkout path, and session cwd differ across users and machines. Placing those facts before reusable tool instructions makes otherwise identical prompts diverge near their beginning, limiting the prefix available for same-model cache reuse. The model-name introduction identifies the agent and can remain early.

English

Problem

The local Web URL, Harness checkout path, and session cwd differ across users and machines. Placing those facts before reusable tool instructions makes otherwise identical prompts diverge near their beginning, limiting the prefix available for same-model cache reuse. The model-name introduction identifies the agent and can remain early.

Decision

The system-prompt registry keeps the fixed Harness identity first and DEPLOYMENT_PERSONA_PREFIX at 0. First-party reusable instructions through STRUCTURED_OUTPUT precede the environment suffix: HARNESS_SOURCE at 10000, WEB_SURFACE at 10100, and DEPLOYMENT_PERSONA_SUFFIX at 10200.

Global system-prompt config accepts personaPrefix and personaSuffix, both defaulting to empty. The scoped persona row requires prefix and accepts suffix, defaulting to empty. They register deployment:persona-prefix and deployment:persona-suffix through the exported PERSONA_PREFIX_SECTION and PERSONA_SUFFIX_SECTION names. An omitted or empty scoped suffix shadows the global suffix away. The shipped Web, headless, SDK, and ACP bundles and standard, PTC, and Cordis presets keep the model introduction in the prefix and place only Your working directory is {{cwd}}. in the suffix. These names specify placement, not a classification of the text; no persona parsing or OS field is added.

The prompt-variables and tool-guidance ownership note retains its identity-first persona placement, single-owner rule, strict interpolation, and tool-guidance responsibilities.

Alternatives considered

Move the entire persona late. That moves the model-name introduction away from the beginning without helping same-model reuse. Separating cwd preserves the introduction and reusable instructions together.

Move only the source path and Web URL. Leaving cwd inside the early persona still breaks the reusable prefix across workspaces.

Infer environment fragments from persona text. Parsing deployment-authored prose makes placement depend on wording. Explicit templates give shipped compositions and custom deployments direct control.

Move these facts into runtime-context messages. That changes their message role and persistence placement rather than only separating system sections.

Consequences

Byte-identical prefixes require the same model introduction, persona prefix, tools, configuration, and preceding section text. Arbitrary extension orders and assembly listeners remain authoritative; this is a first-party placement policy, not a universal stable-prefix guarantee. Provider cache sharing and hit-rate improvements are not measured or promised.

Environment and Web/source guidance follow structured-output instructions. A complete: true persona uses only the rendered prefix and ignores the suffix, suppressing every other system section without disabling tool schemas or runtime context. Source and Web facts retain their distinction between the Harness checkout, session workspace, and current working directory.

Testing

Registry tests compare reusable prefixes with the same model and changed checkout paths, URLs, and cwd values; they also cover strict interpolation and complete overrides. Loop tests pin early model identity and session-cwd interpolation. Persona tests cover scoped suffix replacement, empty shadowing, and complete personas. Recorded prompt snapshots cover emitted prompts in native-tool and generated-SDK compositions; they do not measure provider cache hits.

中文

问题

本地 Web URL、Harness checkout 路径和会话 cwd 因用户与机器而异。将这些事实放在可复用工具指令之前,会使其余内容相同的提示词在开头附近就出现差异,限制可供同模型缓存复用的前缀。模型名称介绍标识 agent(智能体),可以保留在靠前的位置。

决策

系统提示词注册表将固定 Harness 身份保留在最前,并将 DEPLOYMENT_PERSONA_PREFIX 保留在 0。截至 STRUCTURED_OUTPUT 的第一方可复用指令位于环境后缀之前:HARNESS_SOURCE 位于 10000,WEB_SURFACE 位于 10100,DEPLOYMENT_PERSONA_SUFFIX 位于 10200。

全局 system-prompt 配置接受 personaPrefix 与 personaSuffix,两者均默认为空。带作用域的 persona 行要求提供 prefix,并接受默认为空的 suffix。它们通过导出的 PERSONA_PREFIX_SECTION 与 PERSONA_SUFFIX_SECTION 名称注册 deployment:persona-prefix 与 deployment:persona-suffix。省略或为空的作用域 suffix 会遮蔽掉全局后缀。交付的 Web、headless、SDK、ACP bundle 以及 standard、PTC、Cordis preset 将模型介绍保留在前缀中,仅将 Your working directory is {{cwd}}. 放入后缀。这些名称指定位置,而不对文本分类;不添加 persona 解析或 OS 字段。

提示词变量与工具指导归属记录仍保留 identity-first 的 persona 位置、单一归属规则、严格插值和工具指导职责。

曾考虑的替代方案

将整个 persona 后移。 这会将模型名称介绍移离开头,却无助于同模型复用。分离 cwd 可以将介绍与可复用指令一起保留。

仅移动源码路径与 Web URL。 若 cwd 仍位于靠前的 persona 内,不同工作区之间的可复用前缀仍会被打断。

从 persona 文本推断环境片段。 解析部署方撰写的行文会使位置依赖措辞。显式模板让交付组合与自定义部署直接控制位置。

将这些事实移到 runtime-context 消息。 这会改变其消息角色和持久化位置,而不只是分离系统段落。

后果

字节相同的前缀要求模型介绍、persona 前缀、工具、配置和前置段落文本一致。任意扩展顺序与组装监听器仍决定最终结果;这是一项第一方位置策略,而非通用稳定前缀保证。不测量或承诺提供方共享缓存及命中率提升。

环境与 Web/源码指导位于结构化输出指令之后。complete: true persona 仅使用渲染后的前缀并忽略后缀,抑制其他所有系统段落,但不禁用工具 schema 或 runtime context。源码与 Web 事实保留 Harness checkout、会话工作区和当前工作目录之间的区分。

测试

注册表测试在模型相同、checkout 路径、URL 和 cwd 值变化时比较可复用前缀;同时覆盖严格插值与完整覆盖。循环测试固定靠前的模型身份和会话 cwd 插值。Persona 测试覆盖作用域后缀替换、空值遮蔽与完整 persona。录制的提示词快照覆盖原生工具与生成 SDK 组合发出的提示词;它们不测量提供方缓存命中。