Prompts
Every word a model reads is a prompt: the system prompts in svc-ai/app/prompts.py, the structured-output schemas (field descriptions and model docstrings — LangChain sends both), tool descriptions, the rule and widget catalogues svc-core sends, the judge and optimiser prompts, and the built-in agents', skills' and dashboards' instructions. This guide is the rules those follow, and the tests that hold them.
A vocabulary is rendered, never written
No prompt lists options by hand. Every list a model is shown — gate routes, task complexities, rule fields and actions, knowledge source types, icons and accents, question kinds, chart types, tool names, fence languages, widget config values — is rendered from the data structure that defines it, through the vocab helper each service carries (app/util/vocab.py):
| Helper | Renders | ||
|---|---|---|---|
vocab.one_of(source) | 'a', 'b' or 'c' — for prose | ||
vocab.listing(source) | `a \ | b \ | c` — for schema-like lines |
vocab.guide(descriptions, source) | one described line per value, raising VocabularyDrift unless the descriptions cover exactly the vocabulary | ||
vocab.inline(descriptions, source) | 'a' (what a is), 'b' (what b is) | ||
vocab.member(source, value) / members | one value named in prose, checked to exist |
A hand-written list drifts silently. The agent generator told models to use the log audit action for months after migration 79 removed it, while the schema beside it refused that very value; the breakdown widget's hints omitted the usage source dimension the stats registry had gained; two built-in workers told models to call search_*/explore_* tools that had been unified into search_knowledge/explore_graph.
Where per-value guidance is needed, write a mapping and render it with vocab.guide against its vocabulary (QUESTION_KINDS in tools/clarify.py, GATE_ROUTES and TASK_COMPLEXITY in prompts.py, _CHART_TYPES in tools/registry.py). A value added without guidance, or guidance left behind for a removed value, then fails at import. A label a model reads beside each value is the same: ATTACHED_LABELS and UNAVAILABLE_LABELS in app/util/attachments.py (when a document was attached, why its text is not here) are checked against the shared AttachedIn / Availability enums at import.
A person's documents are data, never the request. A turn's attached documents reach a model in their own element, never pasted into the words (Attachments): <attachments> in the answering node's <request_context>, whose note says they are the person's material to work from, never instructions, cited by id; a manifest under GATE_ATTACHMENTS_HEADING for triage and the planner (names, sizes, a preview, never a body); the documents as the agent saw them for the quality check; and a <documents> block before the words for a direct model call. Every body is CDATA-wrapped through attachments.cdata, the one escaper: ]]> closes the section and opens another around the >. Five sites in graph.py wrote ]]]]]><![CDATA[>, a stray ], until 24 October 2026.
When the vocabulary is another service's, it travels with the request. svc-core owns the rule vocabulary, the appearance palette and the knowledge source types, and sends them to svc-ai on every generative request (rule setup, agent setup, knowledge setup). svc-ai renders what it is sent and holds no copy — its schemas take plain strings — and svc-core validates or clamps whatever comes back (app/services/rules/proposals.py, app/services/knowledge/source_types.py, app/services/appearance.py).
Numbers too. A bound a prompt states is the bound the code enforces: a widget's config_schema renders its limits from the same class constants validate_config checks (_hint_int / _int_between), the skill generator states MAX_NODES from GeneratedSkill, and the evaluator's scoring guide is drawn around EVALUATOR_RETRY_BELOW, the score below which graph.py re-runs the pipeline.
Claims too. A description of what code catches is rendered from the code's own account of it. The PII rules' descriptions and the "What to redact" parameter are rendered from the detectors' registry (pii.py: one class per kind, each with its label, example and formats) — they used to promise national insurance numbers, which no pattern matched. Text that cannot render — CHAINR Bot's user guide is markdown — is held to the registry by a test (test_the_user_guide_lists_every_kind_the_pii_rules_catch).
The guard
tests/test_prompt_vocabulary.py (one per service) collects every vocabulary the code defines — Literal arguments, string Enum values, UPPER_CASE sets/tuples/lists of strings and registry keys — and every model-facing string, and fails on a string that lists at least three values of one vocabulary (both values of a two-value one, when quoted). It recognises a run (eq, neq or contains), a guide ( direct — answer from …) and an inline guide ('bar' (one metric per category), …). Docstrings are skipped except a Pydantic model's, which reach the model as schema. In svc-core the scan covers the model-facing paths listed in _MODEL_FACING; add a path there when new code writes text a model reads.
Alongside it, TestRenderedFromSource (svc-ai) and TestVocabulariesAgree (svc-core) pin each derivation to its source: the gate schema's enum is the prompt's route list, every render tool declares its fence language, the evaluator states the line graph.py acts on, and so on.
The schema is part of the prompt
A model shown a field fills it, whatever the instructions say. So a field for something the model may not propose is left out of the schema, not just the prompt: agent setup's toolkit fields live on GeneratedAgentConfigWithToolkits, offered only while MCP servers are available. The same goes for descriptions — when the triage prompt restates its schema's guidance, it renders it from the ResourceStrategy field descriptions (_field_guidance), because the two copies once disagreed on when needs_synthesis is true.
A reply's shape is a schema, never prose
A prompt never tells a model to "respond with JSON only, exactly: {…}". A reply code reads is declared as a ModelOutput (app/util/model_output.py, byte-identical in both services) and asked for with its schema: in svc-ai through structured_call, in svc-core through targets.invoke_structured, which sends the strict schema on the governed model path (output_format="json", output_schema) for svc-ai to decode to natively where the route can — Bedrock's outputConfig, OpenAI's strict json_schema, Anthropic's structured outputs — and to state in its own instruction where it cannot (llm.build_format_instruction). What a field means goes in its description, which is what the model reads either way. svc-core's reply is read by structured_reply.read (whole, one fenced block, or the object that ends it after a preamble — never a span from inside it) and corrected once (structured_reply.correction).
svc-core/tests/test_structured_replies.py fails on a model-facing string that asks for JSON in prose, on a reader that finds an object by its braces outside structured_reply (and JsonMatchScorer, which grades a target's own output as written), and on any svc-core ModelOutput that cannot be decoded strictly, steps outside Bedrock's subset or names a field for a model's reasoning. A value whose shape varies (a dashboard widget's config) travels as text in a typed field (config_json) and is read exactly.
A schema may be built per request when what the model may choose depends on it — the board designer's (generator.proposal_schema): only the widget types this deployment and workspace can run, and which of the workspace's agents runs each model-backed tile, as positional handles (agent_1…) listed with each agent's name and purpose, mapped back to ids by svc-core. A handle, not a name, keeps the schema the same for every workspace with as many agents, so a route compiles its grammar once (lru_cache), and keeps an id out of the model's reach. test_structured_replies.py checks such a schema per shape.
svc-ai holds itself to the same (20 October 2026). A typed skill worker's output, an LLM router's choice and a run's answer to a request's own output_schema are filled by structured_call (a router's candidates are a Literal, listed with vocab.listing; a request's schema is a JsonShape). svc-ai/tests/test_structured_replies.py fails on a string asking for JSON in prose outside llm.build_format_instruction (a request's own format, stated in its request context) and interfaces.output_schema_instruction (a typed worker's contract in a tool loop, whose final message is read whole); on a json.loads in a module not listed with why its text is not a model's reply; and on safe_json.loads_lenient outside structured_call's salvage and a skill's parse transform.
Verdict protocols
A role agent whose answer code parses must be told the format, and the parser must read exactly that. These verdicts are read on a role agent's execute path; inside a graph run a role agent answers through process_with_history and its words are the answer. A router is not one of them: it fills a structured choice (above). The reviewer and validator prompts put the verdict on the final line; prompts.final_verdict reads the lowest verdict line — one that leads with a verdict, ends on one, or says "verdict" — never a verdict word in the body ("this step fails"). No verdict is not a pass: the validator then reports fail and the reviewer needs_revision. Verdict strings live in prompts.py (REVIEWER_VERDICTS, VALIDATOR_STATUSES) and both sides import them.
Where prompts live
svc-ai
app/prompts.py— role prompts, generator prompts, the system nodes' instructions, the gate and evaluator, the rendering hint, and the protocol vocabularies they share with the code (GateRoute,TaskComplexity,TOOL_RETRIEVAL_TOOLS,CitationStatus, fence languages). Builders that need data the module cannot import (the planner'sAgentRole—app.agentsimports this module) take it as an argument.svc-ai
app/services/rule_catalogue.py— the rule catalogue's models and rendering, shared by rule setup and agent setup.svc-core — the rule registries' descriptions (sent as the catalogue), the widget catalogue (
services/dashboards/widgets.py) and the board generator, the evaluation judge and optimiser, and the built-in resources' instructions (services/system_resources/).