symfonic.agent.prompts.stratigraphic_layers¶
stratigraphic_layers ¶
L1/L2 template rendering for prompt_layer_mode='stratigraphic'.
The legacy hms_system.txt template interleaves session-stable content
(role, data sovereignty, domain directives, memory architecture, tool
manifest, reasoning directives, extraction obligation, activation-log
rules) with per-turn volatile content (timestamp, active tools, memory
context, prospective tasks, hydrated/RAG context). That interleaving is
fine for legacy single-string mode but fatal for prompt caching: any
volatile token anywhere in the cached prefix invalidates the cache every
turn.
Stratigraphic mode therefore renders two separate bundled templates:
hms_system_l1.txt-- session-stable only. Becomes the L1 cached layer. No timestamp, no memory context, no hydrated context, no active tools, no prospective tasks.hms_system_l2.txt-- per-turn volatile only. Becomes the L2 uncached layer: timestamp, active tools, memory context, prospective tasks, hydrated/RAG context.
Legacy mode is untouched -- it still renders hms_system.txt via
HMSSystemPromptSection byte-for-byte. These templates are additive
and only loaded on the stratigraphic path.
Rendering reuses system_prompt._substitute so placeholder semantics
(UPPER_SNAKE keys, lower_snake fallback, leave-unresolved-then-raise)
match the legacy section exactly.
render_l1_body ¶
Render the session-stable L1 layer from hms_system_l1.txt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
dict[str, object]
|
The same placeholder mapping the legacy HMS section
consumes. Only the stable keys are referenced here
( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The fully substituted L1 body string. |
Source code in src/symfonic/agent/prompts/stratigraphic_layers.py
render_l2_body ¶
Render the per-turn volatile L2 layer from hms_system_l2.txt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
dict[str, object]
|
The same placeholder mapping the legacy HMS section
consumes. Only the volatile keys are referenced here
( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The fully substituted L2 body string. |