AAnvio
Runtimes & Model Routing

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's spec.model block 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 appends local if it isn't already present, so a chain like claude-code → cursor effectively becomes claude-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-20250514

Model resolution when local is reached

Once execution reaches local, model selection is handled by ModelRouter.chat():

  1. If spec.model.override.provider is set, that provider is used directly, skipping routing.
  2. Otherwise a route is chosen — explicit spec.model.routing, a skill's routing hint, or the default strategy — and walkFallbackChain() tries the route's primary provider, then its fallback list, retrying on 429/timeout/502/503.

See Model Router for the full routing and fallback behavior, and Configuration for the model provider API key environment variables.

Edit on GitHub

Last updated on

On this page