Skip to content
Konstera
Docs · Context Service
Konstera documentation.

Getting started, SDK quickstart, manifest reference, kernel MCP services, deploy guide and FAQ — everything you need to build and run agents on Konstera.

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.

FlowWho writes, who reads Interactive — click a block

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:

Glossary

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.

Skills

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.

Ontology entities

Business entities (customer, order, sku) with identity strategies (primary + fallback identifiers), key attributes (enums, numeric ranges, datetime windows), and relationships to other entities.

Eval signals

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:

Flow
1Fetch customer
2Fetch order
3Check window
4Compute refund amount
5Check exceptions
6Emit decision

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.

SequenceResolving a customer through the ontology — no per-vendor branches in your code
Your agentctx.semanticctx.capability1ontology_lookup("customer")2primary: email · fallbacks: loyalty_id, phone3call the primary's capability with the email4customer — or nothingno match → try fallbacks in order

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:

GoalReadWhat the agent does with it
Grounding LLM prompts in tenant-authoritative definitionsglossary_lookupSystem-prompt preamble
Resolving entities across heterogeneous vendor bindingsontology_lookupIdentity strategy iteration
Running authored playbooksskills_getAgent-side skill runner
Autopilot gating based on recent eval performancecluster_pass_rateSelf-approve threshold

Don't use it for:

Not forUse instead
Static configurationThe 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:

Python
# 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 kindReturns when disabled
LookupsNone
Lists / maps[] / {}

Agents should branch on data availability rather than special-casing feature-disabled:

Python
# 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:

JSON
"contextRequirements": {
  "glossary": [
    { "term": "refund_window_days", "required": false }
  ],
  "skills": [
    { "name": "evaluate_refund_eligibility", "required": true }
  ],
  "ontologyEntities": [
    { "entity": "customer", "required": true },
    { "entity": "order", "required": false }
  ]
}
FlagAt installIn your code
required: trueInstall fails if the tenant hasn't authored this record—
required: falseOptionalAgent 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.

Flow Interactive — click a block
1Fetch by namecurrent stateGo to step
2Persist ID + versionin your output
3Replay by IDglossary_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#