编写 Agent Slot
当 core 需要在 agent loop 中某个受治理的位置加入 authored behavior 时,使用 Agent Slot:
bootstrap在每个 session 中添加一次 session-stable context。input在 provider call 之前塑造当前 turn。output在 provider call 之后处理最终 model output。
本指南编辑一个具体 runtime core。默认 runtime layout 中,core 位于:
~/.demiurge/agents/<core_id>/
向某个 core 添加 slot 时,不要编辑 ~/.demiurge/agents/agent.yaml。这个文件是
global fallback config。具体 core 有自己的 agent.yaml 和 authored surface,例如
agent/。
开始前
检查 runtime cores 是否能加载:
uv run demiurge init --check
打开目标 core,确认它有:
agent.yaml
agent/pipelines.yaml
Core 的 runtime.surface_root 通常是 agent。Bootstrap、input 和 output slot
roots 会从这个 surface root 解析:
| Phase | Root |
|---|---|
bootstrap | agent/bootstrap/<slot_id>/ |
input | agent/input/<slot_id>/ |
output | agent/output/<slot_id>/ |
修改 agent.yaml 中的 slots.input 或 slots.output 不会移动这些 phase roots。
选择 Slot Phase
按你需要的行为选择 phase:
| 需求 | 使用 |
|---|---|
| 在 turns 之前加入 memory、identity 或 session-stable context | bootstrap |
| 在 model call 前添加 instructions、规范化 raw input、检查 attachments 或激活 skills | input |
| 在 model call 后发送 response、转换 output、发送 artifacts、写 result data 或更新 state | output |
| 暴露一个可被 model 显式调用的动作 | Authored tool,不是 slot |
| 在 slots/tools 之间共享 helper code | agent/lib/,不是 slot |
优先添加一个命名 slot 并更新 agent/pipelines.yaml。不要重写 base_input 或
base_output,除非这次更改就是要替换 seed input 或 output 行为。