Agent runtime routing

An agent run has two separate choices:

  1. Which runtime thinks and acts?
  2. Which device executes the work?

The runtime can be OSA, Codex, Claude Code, Pi, Hermes, Gemini CLI, OpenCode, or a custom agent harness. The device can be a sandbox, computer, or local device.

MIOSA Agent = runtime, model, instructions, tools, policy
MIOSA Device = sandbox, computer, or local machine where actions happen

Routing contract

type RuntimeRoute = {
  runtime: "osa" | "codex" | "claude-code" | "pi" | "hermes" | "gemini-cli" | "opencode" | "custom";
  model?: string;
  deviceType: "sandbox" | "computer" | "local";
  deviceId: string;
  cwd?: string;
  prompt: string;
  tools: string[];
  connectors: string[];
  approvalPolicy: "auto" | "confirm-risky" | "manual";
};

The runtime receives:

  • prompt
  • system instructions
  • device tool handles
  • connector handles
  • allowed environment variables
  • approval policy
  • budget envelope

The device executes:

  • file operations
  • commands
  • browser actions
  • screenshots
  • preview servers
  • artifact generation
  • deployment prep

Runtime choices

RuntimeUse it forNotes
OSAMIOSA-native general agent, white-label flows, managed productsDefault platform runtime
CodexCode-heavy sandbox work, repo edits, tests, CLI-native dev workflowsBest for software engineering loops
Claude CodeCode and artifact workflows where Claude Code is the customer’s preferred harnessNeeds non-interactive session support
PiAgent harness experiments and AI SDK-compatible streamsUseful when customer ecosystem expects Pi
HermesSpecialized customer agent runtimeTreat as runtime adapter
Gemini CLI / OpenCode / customCustomer-provided runtimesMust satisfy MIOSA event/tool protocol

Device choices

DeviceRuntime fit
SandboxOSA, Codex, Claude Code, Hermes, custom code agents
ComputerOSA, Claude Code, browser/desktop operators, QA agents
Local deviceCustomer-controlled runtimes, private network work, local-file workflows

Recommended defaults:

  • app builders: sandbox
  • artifact generation: sandbox
  • web QA: computer
  • dashboard automation: computer
  • private enterprise task: local device
  • broad agent-company product: primary sandbox plus optional computer

Non-interactive first

Interactive TUIs are useful for humans. They should not be the only reliable execution path for a platform.

Production-grade runtime sessions should support:

  • --prompt or prompt file input
  • --detach
  • JSON output
  • reconnectable event stream
  • explicit model selection
  • clean cancel/stop
  • typed errors
  • no dependency on tmux for correctness

This is the difference between a CLI tool and a product substrate.


Runtime adapter lifecycle

The adapter is responsible for translating runtime-specific behavior into MIOSA’s common protocol.

Examples:

Runtime eventMIOSA event
Tool call startedtool.started
Shell outputcommand.output
File editfile.changed
Browser screenshotbrowser.screenshot
Artifact savedartifact.created
Human confirmation neededapproval.required
Model/tool failurerun.failed

Model availability

The runtime should never silently default to an unavailable model. The product must validate model availability before starting a session.

Recommended behavior:

  1. List available models for the runtime.
  2. Pick workspace default if valid.
  3. Fall back to runtime default if configured.
  4. Return a typed error with valid model options if unavailable.

Bad:

Unknown model "x"

Good:

{
  "code": "MODEL_UNAVAILABLE",
  "message": "claude-opus-4-7 is not available for this workspace.",
  "available_models": ["claude-sonnet-4.6", "claude-opus-4.6"],
  "recovery": "Retry with --model claude-sonnet-4.6."
}

Credential injection

Runtimes often need provider credentials. The safe model is:

  • users or admins store credentials in MIOSA
  • runtime receives scoped handles, not raw platform admin keys
  • sandboxes receive only the environment variables approved for that workspace
  • egress swaps managed placeholders only for the intended provider endpoint
  • all credential use emits audit events

Example:

workspace stores ANTHROPIC_API_KEY
  -> agent policy allows Claude Code runtime
  -> sandbox session receives scoped runtime secret
  -> runtime can call provider
  -> UI never shows raw key

For managed connectors such as Refero, GitHub, Slack, Google, or tenant APIs, prefer connector token exchange over plain environment variables.


See also

Was this page helpful?
Opening MIOSA…