Appearance
Context Assembly
文件与 Symbol
| Symbol | Runtime 输入 | Model-visible 输出 |
|---|---|---|
createSystemPromptAssembly() | 一组 dependency owners | Context assembler |
getSystemPrompt() | base/profile/identity/timezone/memory/workflow/channel/MCP/box/computer | system prompt sections |
getMemorySection() | agent/user/project memory + snapshot | memory section |
getTimeZoneSection() | request context | timezone section |
getUserIdentitySection() | request context | identity section |
getAutomationsSection() | automation store | automation section |
getWorkflowsSection() | workflow store | workflow section |
getChannelsSection() | connector manifests + connections | channel section |
getAgentDirectorySection() | agents/groups | agent directory section |
prepareAgentProfilePromptSnapshot() | profile + compaction epoch | stable snapshot |
getSystemPrompt() 的真实形状
text
base prompt
+ spotlight
+ agent profile
+ user identity
+ multitask / policy sections
+ timezone
+ memory
+ automations
+ workflows
+ channels
+ agent directory
+ MCP custom instructions / discovery
+ remote box
+ computer section
↓
sections.join("\n\n")这说明 Context Assembly 不是“拼聊天历史”,而是 Runtime-owned information projection。某项信息存在于 Runtime,不代表它必然进入当前 Model Request。
Snapshot / Compaction 相关
prepareAgentProfilePromptSnapshot() 与 memory snapshot 都带有 compaction epoch 语义。阅读时重点看:为什么动态状态需要先冻结成当前 Turn 的稳定视图,而不是 ModelClient 临调用时到处读 mutable state。
本地定位
bash
rg -n "createSystemPromptAssembly|getSystemPrompt|getMemorySection|getTimeZoneSection|getWorkflowsSection|getChannelsSection|prepareAgentProfilePromptSnapshot" source/host/runner/system-prompt-assembly.ts固定源码
关联知识文章
- Context 如何组装:Assembly Pipeline 与 Token Budget — Context Assembly 不是拼字符串,而是 Runtime Projection;
createSystemPromptAssembly()→getSystemPrompt()→getMemorySection()