MultiRun

Models

Run, Step, Budget, Checkpoint, Policy, Agent — Pydantic models.

Models

All models are Pydantic BaseModel subclasses. Import from multirun.models.

from multirun.models import Run, Step, Budget, Checkpoint, Policy, Agent, AgentConfig

Run

RunStatus

class RunStatus(str, Enum):
    PENDING = "pending"
    RUNNING = "running"
    COMPLETED = "completed"
    FAILED = "failed"
    CANCELLED = "cancelled"
    PAUSED = "paused"        # checkpointed, waiting for replay

Run

Represents a single agent execution.

FieldTypeDefaultDescription
idstrauto UUIDServer-assigned run ID
namestr""Run name (e.g. "research_agent")
statusRunStatusPENDINGCurrent status
parent_idstr | NoneNoneParent run ID for sub-runs
stepslist[Step][]Steps in this run
current_step_idstr | NoneNoneCurrently executing step
checkpointslist[CheckpointMeta][]Checkpoint metadata
latest_checkpoint_idstr | NoneNoneMost recent checkpoint
budgetBudget | NoneNoneBudget constraints
tokens_usedint0Total tokens consumed
cost_usdfloat0.0Total cost
policyPolicy | NoneNonePolicy rules
metadatadict[str, object]{}User-defined metadata
created_atdatetimenow (UTC)Creation timestamp
started_atdatetime | NoneNoneWhen execution started
completed_atdatetime | NoneNoneWhen execution ended
resultbytes | NoneNoneSerialized return value
errorstr | NoneNoneError message if failed

RunPatch

Partial update model. Only non-None fields are applied.

patch = RunPatch(status=RunStatus.COMPLETED, tokens_used=5000)

Step

StepKind

class StepKind(str, Enum):
    FUNCTION = "function"
    LLM_CALL = "llm_call"
    TOOL_CALL = "tool_call"
    SUB_AGENT = "sub_agent"
    DECISION = "decision"
    CHECKPOINT = "checkpoint"

StepStatus

class StepStatus(str, Enum):
    PENDING = "pending"
    RUNNING = "running"
    COMPLETED = "completed"
    FAILED = "failed"
    SKIPPED = "skipped"      # during replay

Step

Atomic unit of execution within a run.

FieldTypeDefaultDescription
idstrauto UUIDStep ID
run_idstr""Parent run ID
agent_idstr""Parent agent ID
namestr""Step name
kindStepKindFUNCTIONType of step
statusStepStatusPENDINGCurrent status
parent_step_idstr | NoneNoneFor nested steps
input_hashstr""SHA-256 of serialized input (replay key)
input_databytes | NoneNoneSerialized input
output_databytes | NoneNoneSerialized output
policy_decisionstr | NoneNoneproceed, wait, fallback, abort
tokens_usedint0Tokens consumed
cost_usdfloat0.0Cost
latency_msint0Execution time
started_atdatetime | NoneNoneStart time
completed_atdatetime | NoneNoneEnd time
errorstr | NoneNoneError if failed
attemptint1Current retry attempt

Budget

Resource constraints for a run. All fields are optional — only set limits are enforced.

budget = Budget(
    max_tokens=100_000,
    max_cost_usd=1.0,
    max_steps=50,
    max_duration_seconds=300,
    max_sub_agents=5,
)
FieldTypeDescription
max_tokensint | NoneMaximum total tokens
max_cost_usdfloat | NoneMaximum total cost in USD
max_stepsint | NoneMaximum number of steps
max_duration_secondsint | NoneMaximum wall-clock time
max_sub_agentsint | NoneMaximum sub-agents

Methods

  • is_exceeded(run) -> bool — check if any limit is exceeded
  • get_exceeded_reason(run) -> str | None — human-readable reason

BudgetStatus

Current budget consumption snapshot.

FieldTypeDescription
tokens_used / tokens_remainingint / int | NoneToken usage
cost_used_usd / cost_remaining_usdfloat / float | NoneCost usage
steps_used / steps_remainingint / int | NoneStep usage
percentage_usedfloatOverall usage percentage
is_exceededboolWhether any limit is exceeded

Checkpoint

Checkpoint

Full checkpoint data for replay.

FieldTypeDescription
idstrCheckpoint ID
run_idstrParent run
agent_idstrParent agent
step_idstrCheckpoint after this step
namestrCheckpoint name
state_databytesSerialized state blob
state_formatstrSerializer used (cloudpickle, pickle, json)
contextdictJSON-serializable replay context
environmentdictJSON-serializable environment info
created_atdatetimeCreation time
size_bytesintSize of state_data

CheckpointMeta

Lightweight metadata (no binary data). Used in Run.checkpoints list.

FieldTypeDescription
idstrCheckpoint ID
run_idstrParent run
agent_idstrParent agent
step_idstrAfter this step
namestrCheckpoint name
created_atdatetime | NoneCreation time
size_bytesintState size

Policy

PolicyDecision

class PolicyDecision(str, Enum):
    PROCEED = "proceed"
    WAIT = "wait"
    FALLBACK = "fallback"
    ABORT = "abort"

Policy

Collection of policy rules. All fields are optional.

from multirun.models import Policy
from multirun.models.policy import RetryRule, RateLimitRule, CircuitBreakerRule

policy = Policy(
    retry=RetryRule(max_attempts=3, backoff=BackoffStrategy.EXPONENTIAL),
    rate_limit=RateLimitRule(requests_per_minute=60),
    circuit_breaker=CircuitBreakerRule(failure_threshold=5, recovery_time_seconds=60),
)
FieldTypeDescription
budgetBudgetRule | NoneBudget policy
rate_limitRateLimitRule | NoneRate limiting
retryRetryRule | NoneRetry policy
circuit_breakerCircuitBreakerRule | NoneCircuit breaker
graceful_degradationGracefulDegradationRule | NoneFallback to cheaper model

Policy rule types

  • BudgetRulemax_tokens, max_cost_usd
  • RateLimitRulerequests_per_minute, model
  • RetryRulemax_attempts, backoff (BackoffStrategy), base_delay_seconds, max_delay_seconds
  • CircuitBreakerRulefailure_threshold, recovery_time_seconds
  • GracefulDegradationRulefallback_model, trigger (DegradationTrigger), threshold

Agent

AgentStatus

class AgentStatus(str, Enum):
    PENDING = "pending"
    RUNNING = "running"
    COMPLETED = "completed"
    FAILED = "failed"
    CANCELLED = "cancelled"

Agent

Runtime agent instance within a run.

FieldTypeDescription
idstrAgent ID
run_idstrParent run
agent_config_idstr | NoneReference to AgentConfig
namestrAgent name
statusAgentStatusCurrent status
tokens_usedintAggregated from steps
cost_usdfloatAggregated from steps
started_at / completed_atdatetime | NoneTiming
errorstr | NoneError if failed
metadatadict | NoneUser-defined metadata

AgentConfig

Workspace-level reusable agent template.

FieldTypeDescription
idstrConfig ID
workspace_idstrOwning workspace
namestrTemplate name
descriptionstr | NoneDescription
configdictOpaque config (model, tools, prompt, etc.)
default_budgetBudget | NoneDefault budget for this agent type
created_at / updated_atdatetimeTimestamps

On this page