Skip to content
Press / to search

Runtime API Schemas

Published JSON Schema artifacts for ContextOS execution contracts: RunContext, invokeAgent, agent delegation, CompiledContext, ToolEnvelope, DecisionRecord, ReplayPacket, and additive execution profiles.

Reference DesignLast reviewed: Edit on GitHub
At a glance

Reference Architecture

This page is the routing table for executable runtime schemas. Earlier versions of this page embedded compact illustrative snippets; the published /schemas/*.json artifacts below are now the validation surface.

Published schemas

ContractPurposeSchema
RunContextPer-run identity, tenant, authority, safety mode, and budget./schemas/run-context.v1.schema.json
invokeAgentEntry request envelope for stream, batch, and long-running execution./schemas/invoke-agent.v1.schema.json
AgentDelegationEnvelopeParent-issued child-run authority, scope, budget, expiry, and effect-isolation contract./schemas/agent-delegation.v1.schema.json
ContextPackVersioned deployable contract for the Context plane./schemas/context-pack.v2.schema.json
CompiledContextCompiler output: prompt, manifests, runtime controls, budget report, and context ledger./schemas/compiled-context.v1.schema.json
ToolEnvelopeToolCallEnvelope and ToolResultEnvelope for governed capability invocation and result audit./schemas/tool-envelope.v1.schema.json
DecisionRecordReplayable audit receipt emitted by governed decision checkpoints./schemas/decision-record.v1.schema.json
ReplayPacketPortable replay input for audit replay, regression replay, environment replay, and source-pressure closure./schemas/replay-packet.v1.schema.json
ExecutionContractEnvelopeAdditive run-bound selection of exact profiles, required/optional controls and release artifacts./schemas/execution-contract.v1.schema.json

Additive execution profiles

ExecutionContractEnvelope is a separate attachment bound to the run, trace and tenant by a trusted admission store. It adds no required field to the eight existing envelopes. Schema validation checks the closed structure and resource bounds: one to 16 profiles, at most 128 required controls, optional controls and release references per array, and identifiers/revisions up to 256 Unicode characters. A schema-valid unknown revision still fails semantic negotiation when the implementation cannot support it.

negotiateExecutionContract in the TypeScript reference verifies content-addressed registry definitions, expands mandatory and feature-conditional controls and compares exact support declarations. Mandatory obligations cannot be demoted to optional. Trusted admission derives all eight feature booleans from the actual workflow and runtime configuration; caller or model flags do not authenticate themselves. An accepted result is compatibility evidence. Current authority, approval, active containment, mediated data movement and effect safety require separate runtime enforcement and observations.

The new schema’s $defs validate its reference attachments directly. The root remains ExecutionContractEnvelope; it is not a union accepting an arbitrary attachment in place of an admitted run contract. There are exactly nine public schema files: eight compatible base schemas and this additive schema. The public TypeScript facade uses aliases to each owning module rather than copied field definitions.

Execution attachment entry points

Use the full schema ID followed by #/$defs/TypeName as the validator entry point. The schema includes every non-generic exported attachment from the new contract modules, including input/result objects and enum aliases. These are the principal boundaries:

TransitionResult<T> is generic in TypeScript; a serialized schema needs a concrete state. The three named transition entry points above instantiate it for run, operation and budget ledgers. ResumeValidationResult is the specialized checkpoint result with explicit non-dispatch rejection obligations.

Attachment objects are closed; finite dictionaries such as action arguments intentionally accept JSON content and still require bounded safe canonical processing. New counters are non-negative safe integers. Exact accounting declares currency and a power-of-ten quantum; legacy fractional-cent fields retain their original schemas. The schema cannot establish cross-field budget sums, attenuation, current revocation, stored approval identity or valid state transitions. The actual module validators check those semantics separately.

Register the schema’s contextos-utc string format with isContractTimestamp from the TypeScript reference. It accepts bounded valid UTC calendar labels ending in Z, preserves arbitrary fractional precision within the 256-character bound, and rejects offsets and leap-second labels pending an explicit time-scale adapter. A validator that skips unknown formats has not performed the required timestamp check. The repository’s Ajv 2020 tests register this format explicitly; legacy schemas continue to use their existing date-time format.

An attachment’s structural validity does not verify referenced bytes or authenticate its publisher. Verify canonical content digests, trust roots, current observations and trusted run/tenant/trace correlation separately. A well-formed wrong proposal, expired stored approval or unsupported revision remains schema-valid where the shape permits it and must still fail semantic admission/authorization. See Execution Contract, Control Profiles and Conformance.

New profile bindings use complete RFC 8785 canonical JSON with explicit domain separation. The helper rejects non-JSON values, accessors, cycles, malformed Unicode and reference traversal limits (64 nesting levels, 10,000 values, 1 MiB UTF-8 output). Byte-ingestion adapters must reject duplicate keys before object construction. Existing compiler/replay hash behavior is preserved. The repository provides a deterministic reference and published schemas; it does not provide a production runtime or certification.

Canonical flow

invokeAgent(request_envelope, run_context)
  -> admit(exact profiles, actual features, implementation support)
  -> compile(packs, request, run_context) -> CompiledContext
  -> loop {
       planner(CompiledContext) -> Plan
       critic.verify(Plan) -> ok | replan | reject
       executor(Plan, ToolGateway) -> ToolEnvelope[]
       critic.score(step_results) -> accept | retry | replan | escalate
       consolidate(effects, evidence) -> memory_proposals
     }
  -> DecisionRecord
  -> ReplayPacket when sampled, failed, corrected, or promoted

Field invariants

SurfaceInvariant
RunContext.trace_idCorrelates compilation and propagates through tool envelopes, decision records and replay packets; do not invent a required top-level trace field on CompiledContext.
RunContext.safety_modeFilters surfaced tools by maximum approval mode before the planner can select them.
AgentDelegationEnvelope.scopeMust be a subset of the parent run’s intents, capabilities, data ceiling, and authority.
AgentDelegationEnvelope.sub_budgetIs reserved from the parent budget; delegation cannot reset or mint capacity.
CompiledContext.context_ledger.compiled_context_hashHashes the compiled prompt, manifests, runtime controls, and budget report for replay.
CompiledContext.compiled_prompt.context_blocks[].provenanceIdentifies source, integrity, freshness, instruction treatment, inclusion reason, and content hash for every canonical compiler block.
CompiledContext.runtime_controls.context_admissionMarks data-only and untrusted blocks and requires privileged arguments to derive from verified sources or user intent.
CompiledContext.runtime_controls.evidence_gates[]Derives sufficiency from coverage, admission, and conflict state; unresolved required conflicts block commit even when each source is current and verified.
CompiledContext.budget_report.omissions[]Records each budget-excluded block with reason, token estimate, priority, and source refs.
ToolCallEnvelope.policy_decision_idBinds a capability invocation to the deterministic policy decision that allowed, blocked, or gated it.
ToolCallEnvelope.action_risk_requested / action_risk_effectiveAdditive v1 fields that separate effect, authority, reversibility, interaction, and data scope; policy resolves them independently.
ToolCallEnvelope.idempotency_keyRequired for write-class calls; retry safety still needs stable operation identity and verified provider-specific key scope/retention/recovery semantics.
ToolResultEnvelope.mutations[]Names side effects or mutation refs; replay consumes transcripts instead of re-executing live side effects.
DecisionRecord.evidence_refs[]Must resolve to evidence, tool result, policy, or artifact refs available to the replay harness.
DecisionRecord.replayCarries replay handle and hashes; it is not a substitute for the trace or tool transcripts.
ReplayPacket.side_effect_policyDeclares whether replay is transcript-only, sandboxed, or explicitly live-disallowed.

Naming rules

Naming must stay consistent across examples:

NameMeaning
R_HIGH_VALUE_REQUIRES_APPROVALA policy rule_id.
GATE_FINANCE_APPROVALAn approval gate_id referenced by a rule or tool invocation.
pol_...A runtime policy decision id emitted when policy evaluates.
tool_...A tool call id shared by call and result envelopes.
rp_...A replay packet id.

Do not record the approval gate id as a policy rule id. Do not treat model-routing records as business decision records; routing decisions can appear in DecisionRecord.lineage, but the governed business outcome is still the DecisionRecord.

ApprovalMode remains required in the v1 ToolEnvelope for compatibility. ActionRisk is optional in v1 so existing consumers continue to validate; new adapters should emit both. Requiring the native vector in a future major envelope remains a candidate migration decision until telemetry shows that active capabilities have a conservative projection and consumers have a bounded upgrade path.

The provenance, context-admission, evidence-gate, and structured-omission fields are likewise additive in compiled-context.v1.schema.json: legacy producer payloads still validate, while the canonical reference compiler always emits them. Consumers should treat their absence as legacy/unknown, never as trusted or complete context.

Relationship to docs