Prompt Snippets
Prompt Snippets are reusable system prompt building blocks stored as versioned configuration documents. They are user-extensible and config-driven, and supply the customisable preset text for the counterweight and identity-masking features described in langchain.md → Behavioral Safety.
Quick Start
1. Create a Snippet via REST API
POST /snippetstore/snippets
Content-Type: application/json
{
"name": "cautious_mode",
"category": "governance",
"description": "Instructs the agent to verify facts before responding",
"content": "IMPORTANT: You must always verify facts before responding. If you are unsure about something, say so explicitly rather than guessing. Never fabricate information.",
"tags": ["safety", "production"],
"templateEnabled": true
}2. Use in a System Prompt
Reference the snippet in your LLM task's system prompt template:
You are a helpful customer service agent for {properties.company_name}.
{snippets.cautious_mode}
Always respond in {properties.preferred_language}.That's it. The snippet content is automatically injected at template resolution time.
How It Works
Auto-Loading
Snippets are loaded from the datastore (MongoDB or PostgreSQL) and injected into the template data map under the snippets namespace for every template render (the data map is built by the same converter for LLM tasks, outputs and HTTP calls), so {snippets.xxx} resolves like any other template variable in any of them.
Which snippets an agent sees
With workspaces off (the default) there is one shared workspace and every snippet is available to every agent.
With workspaces enforced, snippets are injected by name, automatically, so sharing a snippet would push it into other teams' prompts without their say. A render therefore gets only snippets from sources the agent's own side controls:
Snippets filed in the agent's space that the space may use (a teammate's
privatesnippet in the same space is not included).The owner's own snippets — for an agent in a personal space only. An agent in a team space does not carry its creator's private snippets or snippets granted to the creator personally: every editor in the team can change that agent's prompt and read it back.
Legacy (unowned) snippets, the pre-workspace shared namespace. They load regardless of
eddi.workspaces.legacy-visibility, like every other configuration an agent references. That policy controls the authoring surface, not the engine.
A snippet from another space is never injected, even if it is granted to the agent's team or published. To use one, copy it into the agent's space. The counterweight preset snippets (counterweight_cautious, counterweight_strict) follow the same rule, so another workspace cannot replace an agent's safety text.
If several eligible snippets share a name, the one from the earliest source above wins, and within a source the oldest snippet wins. So creating a same-named snippet later never takes over a name an agent already uses. Each ambiguous name is logged once as a warning; rename one of the snippets to make the choice explicit. Without enforcement, a duplicated name likewise resolves to the oldest snippet.
If an agent's descriptor cannot be read, the turn still gets the legacy snippets, so safety text is not silently dropped. That result is not cached. A grant, revoke, publish or ownership transfer clears the cached snippet views at once on the node that made the change; other nodes pick it up within the cache TTL below.
Caching
Snippets are cached in a Caffeine cache with a 5-minute TTL. This means:
Snippets load once from the datastore (MongoDB or PostgreSQL, whichever the deployment uses), then serve from cache
POST/PUT/DELETEon/snippetstore/snippetsinvalidate the cache synchronously, so a snippet edited through the REST API takes effect on the next LLM turnThe 5-minute TTL is the fallback for changes made outside the REST API (a direct database write, or another node)
Cache hit/miss metrics are exposed at
/q/metricsaseddi.snippets.cache.hitsandeddi.snippets.cache.misses
Name Validation
Snippet names must match the pattern [a-z0-9_]+:
cautious_mode
CautiousMode (uppercase)
safety_rules
with-dash (hyphen)
tone_formal
with.dot (dot)
rule_42
with space (space)
This ensures safe Qute dot-notation access ({snippets.name}).
Template Control
templateEnabled (default: true)
Intended to control whether the Qute template engine resolves template markers inside the snippet content. It is currently inert.
Snippet content is injected verbatim and is never template-resolved, whatever templateEnabled says. A snippet reaches a prompt as a template data value — {snippets.name} resolves to it — and Qute does not re-parse what an expression resolved to. Any {...} inside the content therefore reaches the model as literal text:
That is exactly the templateEnabled: false guarantee, and every snippet gets it for free — no unparsed-block wrapping is applied or needed. The corollary is that templateEnabled: true does not make {properties.x} inside a snippet resolve either; it too reaches the model literally. Snippets cannot be made dynamic this way — put the dynamic parts in the system prompt template itself, around the {snippets.name} reference.
The field is kept because stored configs carry it and because honouring it remains a live option; see the PromptSnippetService class javadoc for what enabling it would cost.
REST API Reference
All endpoints require eddi-admin or eddi-editor role.
GET
/snippetstore/snippets/descriptors
List snippet descriptors (paginated)
GET
/snippetstore/snippets/{id}?version=1
Read a snippet
POST
/snippetstore/snippets
Create a snippet
PUT
/snippetstore/snippets/{id}?version=1
Update a snippet
DELETE
/snippetstore/snippets/{id}?version=1
Delete a snippet (add permanent=true to remove it and its history; default false)
GET
/snippetstore/snippets/{id}/currentversion
The current version number (text/plain)
POST
/snippetstore/snippets/{id}/currentversion
303 redirect to the current version
Create and update answer 400 when name violates the [a-z0-9_]+ pattern.
Query Parameters for Descriptors
filter
""
Filter by name (substring match)
index
0
Pagination offset
limit
20
Max results
Model Reference
Example Snippets
Governance — Cautious Mode
Usage: {snippets.cautious_mode}
Persona — Formal Tone
Compliance — GDPR Notice
Routing — Escalation Rules
Composing a Full System Prompt
Snippets give you full control over prompt composition order:
The designer controls exactly where each snippet appears, enabling precise prompt engineering.
Counterweight and Identity Masking
CounterweightService and IdentityMaskingService are applied to every system prompt and are configured per LLM task via the counterweight and identityMasking blocks in langchain.md → Behavioral Safety. Counterweight preset text is itself customised by creating counterweight_cautious / counterweight_strict snippets (names use underscores because snippet names must match [a-z0-9_]+). Snippets with the older hyphenated names counterweight-cautious / counterweight-strict are still honoured if they exist in storage, but cannot be created through the REST API.
The key advantage: snippets are user-configurable without code changes, versionable, and composable.
Last updated
Was this helpful?