Keep model context bounded
Handle long-running evidence, context limits, and uncertain model calls.
Use this guide when a workflow accumulates more evidence than fits in one model request. The Python SDK's ContextSession uses Membrane working memory to select bounded evidence and verify it against immutable source artifacts.
Prepare a model turn
- Preserve tool results and evidence as source artifacts.
- Declare the decision focus, required fields, evidence references, and topics.
- Select a bounded packet of supporting and opposing evidence.
- Verify source ranges and count the complete model request, including instructions, schemas, current input, and output reserve.
- Dispatch only after the full request fits; preserve the response and completion receipt.
Generated summaries help navigate records; citations must resolve to source bytes. Context selection reads existing evidence and does not dispatch domain tools or change the workflow graph.
Budget the full request
input_budget = window_tokens - output_reserve - safety_tokensSDK defaults are a 16,384-token window, 2,048 output tokens, and a 512-token safety reserve. These are policy defaults, not proof of a selected model's capacity. Configure the model's supported window and retain final gateway admission checks. Required inputs must not be silently truncated to fit.
Handle failures explicitly
| Signal | Application action |
|---|---|
NeedsPartition | Split the decision into smaller calls and carry verified results forward |
AmbiguousInvocation | A prior dispatch has no durable response; resolve the uncertainty or use an explicit new retry identity |
| Source hash or range mismatch | Reject the evidence and investigate its provenance |
| Storage, call, or deadline budget exceeded | Stop or return a workflow-defined incomplete result |
| Membrane or model unavailable | Report the dependency failure; do not fabricate an answer |
A completed event can replay its durable result. Reusing the same identity with different content fails. An uncertain model call is not automatically repeated because it may already have incurred a charge or produced an external effect.
Diagnose a runtime dependency
With the CLI installed:
mn runtime status
mn runtime doctor
mn blueprint doctor ./my-blueprintReplace ./my-blueprint with the local package path. Check the reported context service and model requirements before rerunning. See Troubleshooting.
Protect evidence
Keep the context service on the trusted runtime network and configure MN_CONTEXT_AUTH_TOKEN when bearer protection is required. Job, run, and principal identity belong to the application boundary, outside model-controlled arguments. Do not put private source text into public progress or logs.
See Python SDK for package integration and Author a blueprint for the mn.context extension.
Job Bundle Format
In MirrorNeuron, a Job Bundle is the standard deployment package for a multi-agent workflow. It defines the structure of the agent graph, the initial state, and any necessary…
Resources And Devices
MirrorNeuron supports a stronger resource model for scheduling AI workers across mixed machines. This model is inspired by Nomad's resources, device, network, and volume ideas,…