Context Service for agent authors
The Konstera Context Service (ADR-037) is the tenant's semantic plane — authoritative definitions of business terms, named reusable playbooks, business entities with identity strategies, and eval signals from the harness.
Agents don't configure any of this. The tenant admin authors it in the portal.
Agents read from it via ctx.semantic.* so their reasoning is grounded in
tenant-authoritative definitions rather than hard-coded assumptions.
This page is the agent-author's view. For how the Context Service is authored in the portal, see the "Agent context" chapter in the user guide.
What's in the Context Service#
Four kinds of record:
Business term definitions. Example: a tenant defines
refund_window_days = 30 with the definition "window from delivery during
which a customer may request a full refund". An agent reading this knows to
treat tickets older than 30 days differently without hardcoding 30.
Named reusable playbooks with ordered steps. Example:
evaluate_refund_eligibility is a deterministic 6-step playbook. The tenant
authors the playbook; an agent runs it via a skill runner.
Business entities (customer, order, sku) with identity strategies (primary + fallback identifiers), key attributes (enums, numeric ranges, datetime windows), and relationships to other entities.
Cluster-level pass rates from the harness. Example: the most recent eval
run shows refund-eligible cluster at 95% pass rate, 20 samples. An
autopilot gate reads this and only self-approves on clusters above a
configured threshold.
The evaluate_refund_eligibility skill's six steps:
And the ontology example: the customer entity carries identity.primary = email +
identity.fallbacks = [loyalty_id, phone]. The agent reads this and
iterates identifiers in try-order to resolve a customer regardless of which
vendor is bound.
When to use it#
Use the Context Service when the agent's behaviour needs to vary by tenant in ways the operator should control without a code change:
| Goal | Read | What the agent does with it |
|---|---|---|
| Grounding LLM prompts in tenant-authoritative definitions | glossary_lookup | System-prompt preamble |
| Resolving entities across heterogeneous vendor bindings | ontology_lookup | Identity strategy iteration |
| Running authored playbooks | skills_get | Agent-side skill runner |
| Autopilot gating based on recent eval performance | cluster_pass_rate | Self-approve threshold |
Don't use it for:
| Not for | Use instead |
|---|---|
| Static configuration | The manifest's config block, which the tenant edits per-instance in the portal |
| Per-invocation state (cursor positions, memoisation, etc.) | ctx.state |
| Secrets (API keys, OAuth tokens) | ctx.credentials |
The surface#
Full method reference in Kernel MCP services and the SDK docstrings. Here's the shape at a glance:
# Glossary
term = await ctx.semantic.glossary_lookup("refund_window_days")
if term:
system_prompt = f"Policy: {term.name} = {term.definition}"
all_terms = await ctx.semantic.glossary_list(domain="cs")
# Skills
skill = await ctx.semantic.skills_get("evaluate_refund_eligibility")
if skill:
for step in skill.steps:
await run_step(step, ctx) # agent-side skill runner
# Ontology
entity = await ctx.semantic.ontology_lookup("customer")
if entity:
primary = entity.properties["identity"]["primary"]
customer = await ctx.capability.call(
primary["capability"],
**{primary["field"]: inbound.email},
)
# Eval signals
rate = await ctx.semantic.cluster_pass_rate(agent_package_id, cluster_tag)
if rate and rate.pass_rate >= 0.9 and rate.total >= 10:
# Safe to autopilot — this cluster has mature test coverage
...
Feature-disabled handling (ADR-039)#
The Context Service is a tenant-togglable feature. On tenants where it's
disabled, every ctx.semantic.* call returns an empty value rather than raising:
| Call kind | Returns when disabled |
|---|---|
| Lookups | None |
| Lists / maps | [] / {} |
Agents should branch on data availability rather than special-casing feature-disabled:
# Right: branch on data availability
term = await ctx.semantic.glossary_lookup("refund_window_days")
if term:
threshold_days = int(term.canonical_unit) if term.canonical_unit else 30
else:
threshold_days = 30 # fallback hardcoded default
# Wrong: assume the Context Service is always on
threshold_days = int((await ctx.semantic.glossary_lookup(...)).canonical_unit)
Declaring context requirements in the manifest (v3.1)#
The manifest's contextRequirements block (new in v3.1 per ADR-038) lists
what context the agent reads. Install-time validation catches typos and
missing-term scenarios before the agent ever runs:
"contextRequirements": {
"glossary": [
{ "term": "refund_window_days", "required": false }
],
"skills": [
{ "name": "evaluate_refund_eligibility", "required": true }
],
"ontologyEntities": [
{ "entity": "customer", "required": true },
{ "entity": "order", "required": false }
]
}
| Flag | At install | In your code |
|---|---|---|
required: true | Install fails if the tenant hasn't authored this record | — |
required: false | Optional | Agent None-checks at runtime |
Omit the block entirely if the agent doesn't use the Context Service.
Full schema: /docs/manifest-schema#contextrequirements.
Reproducibility note#
When your agent reasons based on a glossary term, skill, or ontology entity,
record the version in your output. The Context Service writes are versioned
(v1, v2, …); replays should use ctx.semantic.glossary_lookup_by_id(id)
(Python v0.6.0, TypeScript v0.4.0, .NET v0.3.0) so the agent sees the exact
record that was active at the original invocation. The method returns None
if the tenant's kernel hasn't yet enabled the context_glossary_lookup_by_id
tool — fall back to ctx.semantic.glossary_lookup(name) for live-state reads
in that case.
glossary_lookup_by_id(id)Pattern mirrors ctx.rule.get() / ctx.rule.get_by_id() (see
rule service): fetch by name for "current state", persist
the ID + version for replay.
See also#
How tenants populate the Context Service (SQL assistant, dbt).
The 24 glossary + 24 ontology + 2 skills shipped out of the box.
Thin-semantic model: identity strategies, key_attributes, relationships.
Full method reference with examples.
Declaring what you read.
Cluster-aware autopilot gating pattern.