Skip to main content

Module prompt

Module prompt 

Source
Expand description

The system-prompt template — the one place the agent’s standing context is assembled, and the surface an operator overrides.

The grammar is deliberately tiny: interpolation plus two block forms.

{{ expr }}                      interpolate
{{#if expr}} … {{else}} … {{/if}}
{{#each expr}} … {{/each}}      `this` is the element, `@index` its position
{{! comment }}

Everything hard about expressions — field access, comparisons, macros, functions — is delegated to CEL, which agentd already ships. Resolution is path first, CEL second: {{instance}} and {{#each services}} are bare lookups that work in any build, and only a real expression (take(services, 16), size(peers) > 0) needs --features cel. That keeps the default template — and most custom ones — working without the feature, and a CEL-needing template is refused at CONFIG LOAD with the feature message rather than mis-rendering at turn time.

§Why the default template is ordered the way it is

Providers cache on the literal prefix of a request (Anthropic’s prompt caching, OpenAI’s automatic prefix caching). A block that changes between turns invalidates the cache for everything after it, so the default template is ordered from most stable to most volatile: persona and instruction (change only on reload), then configuration-derived sections (workflows, services, streams, templates), then live state (peers with their instance children, parked signals, memory keys). Put volatile content last in a custom template for the same reason.

Structs§

Template
A compiled template. Parsing is done once (at config load); rendering is per turn.