This document covers runtime control and structured event recording.
ControlContract is the pluggable execution control plane.
- pause or resume execution
- abort runs with explicit reasons
- create and restore checkpoints
- inject steering directives into active runs
| Method | Parameters | Notes |
|---|---|---|
pause(reason=None, agent_id=None) |
optional reason and agent | Temporary halt |
resume(agent_id=None) |
optional agent | Resume paused run |
abort(reason=None, agent_id=None) |
optional reason and agent | Permanent stop |
checkpoint(label=None) |
optional label | Returns checkpoint metadata |
restore_checkpoint(checkpoint_id) |
checkpoint ID | Roll back to checkpoint |
steer(directive, agent_id=None, priority="normal") |
directive text, optional target, priority | Mid-flight steering |
drain_steering(agent_id=None) |
optional target | Consumed before next LLM step |
pre_control_action(action, reason, agent_id)post_control_action(action, success, agent_id)
from mas.runtime.contracts import ControlContract
def interrupt_for_review(control: ControlContract):
control.pause(reason="Human approval required", agent_id="agent-123")RecorderContract is the structured event-recording boundary.
- capture hook and runtime events
- support pluggable backends such as JSONL or OpenTelemetry
- keep observability detached from business logic
| Method | Parameters | Notes |
|---|---|---|
emit(event) |
event dict | Core write operation |
flush() |
none | Flush buffered events |
close() |
none | Close resources |
query(*, kind, agent_id, since, until, call_id, extra_filter) |
all optional | Read back recorded events matching filters |
replay(from_call_id) |
optional call ID | Replay events from a point onwards |
Common fields described by the contract include:
kindtimestamptrace_idspan_idparent_span_idagent_idhook_nameplugin_nameerrormetadata
from mas.runtime.contracts import RecorderContract
def emit_tool_event(recorder: RecorderContract):
recorder.emit(
{
"kind": "hook_start",
"hook_name": "pre_tool_call",
"plugin_name": "sandbox",
"agent_id": "agent-123",
"timestamp": 0.0,
}
)ControlContract.pause()
-> runtime pauses at a safe boundary
-> RecorderContract.emit() records the intervention
ControlContract.steer()
-> runtime drains directives before the next LLM step
-> RecorderContract.emit() records the steering event