Skip to content

Control agent calls.
Verify results before release.

Motif is a contract-based runtime for Python agents. Register the operations your agent can call, then define the checks a result needs before your application delivers it.

Runtime execution model

Mediated calls and controlled releaseThe kernel evaluates an agent request before issuing a Permit for an adapter call. Journaled tool calls record intent before dispatch. Separately, the Release Gate checks required verification evidence for a proposed output. Each path emits audit events.CALL MEDIATIONAgent requestPolicy evaluationPermitMediated executionAuthorizedEffect Journaltool effect stateAUDIT TRACEoperation.authorized / verification.completed / release.decidedOUTPUT RELEASEOutput candidateVerificationReceipt / PASSRelease GateReleasedno Permit
A permitted call can run. The gate releases the output after the required verification passes.

What the runtime controls

Permit
A mediated call runs only with a single-use Permit bound to the request that was authorized.
Permit and the kernel ↗
Effect Journal
Journaled tools record intent before dispatch. Uncertain outcomes require recovery.
Effect Journal ↗
Receipt
A receipt binds a verifier verdict to the candidate and its verification context.
Verification and Receipt ↗
Release Gate
In enforcement mode the gate releases a candidate when it meets the active release policy.
Release Gate ↗
Audit
Audit events report what Motif authorized, verified, and decided.
Audit events ↗

The application chooses which calls to mediate and which verification dimensions to require. Direct SDK or HTTP calls outside the runtime remain under application control. Runtime boundaries ↗

Getting started

Run your first agent

Use a plain Python function as the model adapter. A verifier checks the proposed answer, and the runtime makes the release decision.

Python 3.12+ on Linux or macOS. Use a virtual environment for the installation.

python -m pip install motif-agent==0.2.0
python demo.py

Save the script as demo.py. It uses the development runtime and a local model stand-in.

Install and run step by step ↗
demo.py
import asyncio
import json
from collections.abc import Sequence

from motif.agent.sdk import Runtime, Snapshot, Verdict, VerificationResult, verifier


async def local_model(request: dict) -> dict:
    return {"answer": request["topic"]}


@verifier("answer.present", verifier_id="nonempty")
def nonempty(subject: Snapshot, evidence: Sequence[Snapshot]) -> VerificationResult:
    answer = json.loads(subject.content)["answer"]
    return VerificationResult(Verdict.PASS if answer.strip() else Verdict.FAIL)


async def main() -> None:
    runtime = Runtime.development(
        models={"local": local_model},
        verifiers=[nonempty],
        require=["answer.present"],
    )
    try:
        for run_id, topic in [("first-run", "refunds"), ("second-run", "")]:
            async with runtime.run(run_id) as ctx:
                candidate = await ctx.model("local", {"topic": topic})
                result = await ctx.release(candidate)
                print(result.decision, result.reason)
    finally:
        await runtime.aclose()


asyncio.run(main())
Expected outputrelease ok
block failed:answer.present

Documentation

Understand the runtime.