Skip to main content

Crate machi_runtime

Crate machi_runtime 

Source
Expand description

Turn runtime and session host for the Machi kernel.

Maturity: core (turn, host, session, spawn); stable workflow host adapter.

Re-exports§

pub use gates::CompletionToolGate;
pub use gates::GateChain;
pub use gates::GateDecision;
pub use gates::StopGate;
pub use gates::evaluate_stop_gates;
pub use host::AgentRunResult;
pub use host::DEFAULT_MAX_CONCURRENT_CHILDREN;
pub use host::DEFAULT_MAX_SPAWN_DEPTH;
pub use host::InProcessHost;
pub use host::SessionHost;
pub use host::SpawnOpts;
pub use isolation::InProcessIsolation;
pub use isolation::IsolationBackend;
pub use isolation::IsolationEnv;
pub use isolation::isolation_error;
pub use lifecycle::LifecycleFanout;
pub use lifecycle::NoopLifecycle;
pub use lifecycle::TurnAbortReason;
pub use lifecycle::TurnLifecycleContributor;
pub use stationarity::HARD_STOP_THRESHOLD;
pub use stationarity::NUDGE_THRESHOLD;
pub use stationarity::StationarityAction;
pub use stationarity::StationarityTracker;
pub use stationarity::fingerprint_batch;
pub use stationarity::nudge_message;
pub use schema::STRUCTURED_OUTPUT_MAX_RETRIES;
pub use schema::compile_schema;
pub use schema::schema_retry_reminder;
pub use schema::validate_structured_output;
pub use session::Session;
pub use side_effects::WorkflowSideEffects;
pub use spawn_tool::SpawnAgentTool;
pub use state::ConversationState;
pub use state::VecConversationState;
pub use state::estimate_messages_tokens;
pub use turn::TurnInput;
pub use turn::TurnOptions;
pub use turn::TurnOutcome;
pub use turn::TurnRuntime;
pub use turn::estimate_conversation_tokens;
pub use workflow_host::run_workflow_configured;
pub use workflow_host::run_workflow_on_host;
pub use workflow_host::run_workflow_on_host_with_metrics;

Modules§

gates
Stop gates evaluated when the model returns a non-tool final message.
host
Session host for nested agent runs (dynamic multi-agent delegation).
isolation
Isolation backend for nested agent runs (default: in-process, no sandbox).
lifecycle
Turn lifecycle contributor port (W3.5).
metrics
Re-export observability metrics from machi_obs.
schema
JSON Schema validation for structured agent outputs.
session
Multi-turn session helper over TurnRuntime.
side_effects
In-process workflow side effects: scratch, templates, optional git diff.
spawn_tool
Model-facing spawn_agent tool for dynamic multi-agent delegation.
state
Conversation state abstractions.
stationarity
Identical tool-call stationarity protection (W3.1).
turn
TurnRuntime: host-agnostic ReAct-style loop with stop gates and compaction.
workflow_host
Adapter: machi-workflow host channel → SessionHost nested runs.

Structs§

CompactionOutcome
Result of a compaction pass.
MaxMessages
Drop oldest non-system messages until max remains.
NoopMetrics
Discards all metrics (default for tests / offline).
TokenThreshold
Drop oldest non-system messages when token_estimate exceeds max_tokens.

Constants§

METRIC_COMPACTIONS_TOTAL
Counter: compaction passes by strategy/result.
METRIC_SAMPLE_DURATION_MS
Histogram: LLM sample duration in milliseconds.
METRIC_SPAWNS_TOTAL
Counter: nested agent spawns by status.
METRIC_TOKENS_TOTAL
Counter: tokens by direction (input, output).
METRIC_TOOL_CALLS_TOTAL
Counter: tool calls by tool name and status.
METRIC_TOOL_DURATION_MS
Histogram: tool duration in milliseconds.
METRIC_TURNS_TOTAL
Counter: completed turns by status (ok, error, cancelled).
METRIC_TURN_DURATION_MS
Histogram: turn wall duration in milliseconds.
METRIC_TURN_STEPS
Histogram: steps consumed per turn.
METRIC_WORKFLOW_AGENTS_TOTAL
Counter: workflow agent slots consumed.
METRIC_WORKFLOW_RUNS_TOTAL
Counter: workflow runs by outcome.

Traits§

CompactionStrategy
Pure compaction strategy.
MetricsSink
Host-provided metrics backend.

Functions§

record_compaction
Record a compaction pass.
record_sample
Record sample duration and tokens.
record_spawn
Record a nested spawn.
record_tool_call
Record one tool call.
record_turn
Record a completed turn.
record_workflow_agents
Record workflow agent slot consumption.
record_workflow_run
Record workflow terminal outcome.
required_metric_names
Required metric name catalogue (contract tests / CI snapshots).

Type Aliases§

SharedMetrics
Shared metrics handle.