Local Runtime
The default runtime provider — delegates directly to Anvio's own agent loop and model providers, no vendor CLI required.
3 min read
local is the default runtime (spec.runtime.default: local in workspace/anvio.yaml) and the only one that is always configured — it has no external dependency, no OAuth, no CLI binary to install.
Implementation
LocalRuntimeProvider (packages/runtimes/src/local/local-runtime.ts) is a thin adapter over Anvio's own AgentRuntime:
export class LocalRuntimeProvider implements RuntimeProvider {
readonly runtimeId = 'local' as const;
constructor(private readonly agentRuntime: AgentRuntime) {}
capabilities(): RuntimeCapabilities {
return {
supportsTools: true,
supportsStreaming: true,
supportsSubagents: true,
supportsMcp: true,
supportedLanguages: ['typescript', 'python', 'go', 'shell'],
};
}
isConfigured(): boolean {
return true;
}
async run(request: RuntimeRequest): Promise<RuntimeResult> {
const result = await this.agentRuntime.run(request.session, request.agent, request.input);
return { ...result, runtimeId: this.runtimeId };
}
async *stream(request: RuntimeRequest): AsyncIterable<RuntimeStreamEvent> {
yield* this.agentRuntime.stream(request.session, request.agent, request.input);
}
}It has the widest capability set of any runtime provider: tools, streaming, subagent delegation, and MCP are all supported, because it runs through Anvio's full agent loop rather than shelling out to an external CLI.
What "the agent loop" means here
When the local runtime runs a request, it is Anvio's own state machine driving execution:
idle → assembling_context → calling_model → [tool_executing]* → awaiting_approval → storing_memory → completed | failed- Context assembly — persona, memory recall, skill context, conversation history.
- Model call — dispatched through
ModelRouter(see Model Router) using the agent'sspec.modelblock or a named route. - Tool executing — zero or more rounds of built-in/MCP tool calls (see Built-in Tools).
- Awaiting approval — pauses if a tool requires human sign-off; resumes via
runtime.resume(session, agent, decision). - Storing memory — persists relevant context back to the configured memory provider.
This loop is channel-agnostic — it never imports channel-specific code; all outbound communication (progress, completion, approval prompts) flows through events into the Channel Hub.
When it's used
- As the default for any agent that doesn't set
spec.runtime.provider. - As the final fallback at the end of every runtime chain —
buildAgentRuntimeChain()always appendslocalif it isn't already present, so a chain likeclaude-code → cursoreffectively becomesclaude-code → cursor → local. - Explicitly, when an agent wants direct model-provider control (cost/latency routing, specific model pinning) instead of a vendor coding-agent CLI.
# workspace/agents/architect.yaml — explicit local runtime with model override
spec:
runtime:
provider: local
model:
provider: anthropic
model: claude-sonnet-4-20250514Model resolution when local is reached
Once execution reaches local, model selection is handled by ModelRouter.chat():
- If
spec.model.override.provideris set, that provider is used directly, skipping routing. - Otherwise a route is chosen — explicit
spec.model.routing, a skill's routing hint, or the default strategy — andwalkFallbackChain()tries the route's primary provider, then its fallback list, retrying on429/timeout/502/503.
See Model Router for the full routing and fallback behavior, and Configuration for the model provider API key environment variables.
Last updated on