Skip to content
预计 1 分钟右侧目录可快速定位

Context Assembly ​

文件与 Symbol ​

SymbolRuntime 输入Model-visible 输出
createSystemPromptAssembly()一组 dependency ownersContext assembler
getSystemPrompt()base/profile/identity/timezone/memory/workflow/channel/MCP/box/computersystem prompt sections
getMemorySection()agent/user/project memory + snapshotmemory section
getTimeZoneSection()request contexttimezone section
getUserIdentitySection()request contextidentity section
getAutomationsSection()automation storeautomation section
getWorkflowsSection()workflow storeworkflow section
getChannelsSection()connector manifests + connectionschannel section
getAgentDirectorySection()agents/groupsagent directory section
prepareAgentProfilePromptSnapshot()profile + compaction epochstable 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

固定源码 ​

关联知识文章 ​

AI Engineering · Agent · Harness · Backend Systems