Inference and routing

Choose, run, override, and evaluate models safely.

MARS is local-first by default: it detects hardware, selects an eligible local bundle, starts llama-server as a managed subprocess, and routes roles to fast, reasoning, or coding tiers. Operators can also use real OpenAI-compatible endpoints, Ollama, or supported cloud provider routes through explicit configuration. For setup flags, downloads, PATH, and local machine state, open the Install And Setup Reference.

Local-first, configurable: MARS defaults to local inference, but hosted or cloud model routes are explicit configuration choices. Use security and governance to evaluate data boundaries before changing model routes.

Local-First Inference

The default model path keeps inference on the user's machine. The Go binary stays CGO-free; llama.cpp runs as a supervised subprocess with model files stored outside the repo. Local model artifacts are large, so MARS downloads and verifies them under the user cache instead of committing them. For the full filesystem ownership map, use the Files And State Reference.

llama.cpp boundary

MARS manages llama-server as a separate process. That keeps packaging simple and gives the runtime a stable HTTP contract.

Artifact storage

GGUF model files live under ~/.mars/models/. Managed binaries live under ~/.mars/bin/.

Verification before use

Corrupt or partial downloads must not be loaded silently. Setup verifies required model files before marking a bundle ready.

Long local timeouts

Complex local coding turns can take minutes on large models. MARS uses longer local client timeouts and avoids retrying prompt-context errors that cannot succeed.

Local Bundles And Performance Profiles

A local bundle maps the fast, reasoning, and coding tiers to model artifacts that fit the detected machine. The performance profile controls how aggressive that choice should be.

ChoiceMeaningUser guidance
autoHighest-ranked eligible local bundle for detected hardware.Recommended default for most users.
local-cpu-q3Conservative CPU-capable local bundle.Use for development, dry runs, and low-memory machines.
local-balanced-q4Balanced local bundle for practical autonomous work.Recommended for Apple Silicon and unified-memory systems below very large RAM sizes.
local-quality-q8Higher-quality local bundle with larger quantized models.Use only when VRAM or unified memory can absorb the model comfortably.
performance_profile: autoDetect and cap profile where needed.Apple Silicon below 96 GiB tends to cap high/multi hardware to balanced.
performance_profile: speedFavor smaller local models.Useful when generation latency matters more than quality.
performance_profile: qualityUse detected hardware profile as-is.Use on dedicated GPUs or large-memory machines after setup verifies files.

See eligible bundles

mars models eligible
mars models eligible --json
mars models list --eligible --json

Inspect registry defaults

mars models list
mars models list --provider registry --json

Setup And Download

mars setup prepares local inference. It creates the MARS user directory, writes config, detects hardware, installs llama-server artifacts, downloads model files when requested, and verifies the active local bundle before runtime.

Recommended source install path

make install
mars setup
mars doctor

Ordinary setup requires no GitHub credential; use --github only for optional integration.

Force local inference and download

mars setup \
  --inference local \
  --local-bundle auto \
  --download \
  --yes \
  --json

Use JSON and --yes for deterministic setup automation.

Defer model setup

mars setup --inference defer --skip-download
mars run engineer --repo ~/my-project --dry-run

Dry-run inspection does not need a live model endpoint.

Routing Precedence

Role manifests declare intent with model: fast, model: reasoning, or model: coding. Runtime routing uses explicit overrides first, then manifest tiers, then role-name defaults, then a coding fallback. This prevents planning roles from accidentally using the heaviest coding tier when the manifest requested a lighter tier.

  1. Repo model override

    .harness/model-overrides.yaml can override one tier or one role.

  2. Manifest tier

    The role's model field wins when it names fast, reasoning, or coding.

  3. Role-name default

    Known role names can route to an established tier when no explicit tier is present.

  4. Coding fallback

    If nothing else matches, MARS falls back to the coding tier.

Endpoint override: mars start --model-endpoint <url> is an escape hatch for a real OpenAI-compatible endpoint. It skips local model-file preflight and does not start local llama-server processes.

Repo-Owned Overrides

Overrides are deliberate target-repo configuration. They are useful when a project needs a different model for one tier, one role, or a remote provider route. They should be committed and reviewed like other harness changes.

Override a tier to Ollama

mars models override \
  --repo ~/my-project \
  --tier coding \
  --provider ollama \
  --model qwen3.6:27b \
  --reason "Evaluate local coding candidate"

Override one role to a local endpoint

mars models override \
  --repo ~/my-project \
  --role engineer \
  --provider openai-compatible \
  --endpoint http://127.0.0.1:8088/v1 \
  --model repo-coder \
  --reason "Use dedicated coding server"

Override a tier to a cloud provider

mars models override \
  --repo ~/my-project \
  --tier reasoning \
  --routing cloud \
  --provider anthropic \
  --model claude-sonnet-family \
  --api-key-env ANTHROPIC_API_KEY \
  --reason "Temporary high-quality review route"

Store the environment variable name, not the secret value.

Cloud Providers And OpenAI-Compatible Routes

Cloud routing is explicit. MARS stores provider metadata and api_key_env names in repo-owned config; it does not accept raw provider keys in flags, committed files, logs, traces, telemetry, JSON output, or errors. Enabling a cloud route sends selected assembled context, model messages, tool schemas, tool arguments, and tool results to that provider under its terms.

ProviderDefault endpointCredential envUser note
OpenAIhttps://api.openai.com/v1OPENAI_API_KEYSupported provider route with OpenAI-compatible chat behavior.
Anthropichttps://api.anthropic.com/v1ANTHROPIC_API_KEYUses Anthropic message adapter behind the provider route.
Geminihttps://generativelanguage.googleapis.com/v1beta/openaiGEMINI_API_KEYUses Google's OpenAI-compatible endpoint.
MistralProvider catalog route.MISTRAL_API_KEYOptional cloud provider route.
DeepSeekhttps://api.deepseek.com/v1DEEPSEEK_API_KEYOpenAI-compatible chat route.
xAIProvider catalog route.XAI_API_KEYOptional cloud provider route.
GroqProvider catalog route.GROQ_API_KEYOptional cloud provider route.
CohereProvider catalog route.COHERE_API_KEYOptional cloud provider route.
OpenAI-compatibleUser supplied.User supplied.Use for local gateways, private endpoints, or compatible model servers.

Credentials

Credentials are machine-local. A target repo can document which env names it expects, but secret values stay in the user environment or an ignored local file. The Authentication And Credentials Reference maps provider keys, private release auth, and integration secrets.

Use environment variables directly

export ANTHROPIC_API_KEY=...
mars models evaluate \
  --provider anthropic \
  --model claude-sonnet-family \
  --api-key-env ANTHROPIC_API_KEY

Do not paste secret values into repo files, logs, traces, docs, tickets, or chat.

Write ignored local env file

mars models credentials write-local-env \
  --repo ~/my-project \
  --api-key-env ANTHROPIC_API_KEY \
  --yes \
  --json

This reads the secret from the process environment, writes ignored .harness/.env.local with owner-only permissions, and updates the committed example with env names only.

Ollama

Ollama is a broad catalog and explicit swap provider, not an automatic default-promotion path. Operators can list local Ollama models, evaluate any model by name, and configure an explicit tier or role override when they accept responsibility for that route.

List local Ollama models

mars models list --provider ollama
mars models list --provider ollama --json

Ollama defaults to http://127.0.0.1:11434/v1 for OpenAI-compatible calls.

Evaluate an Ollama candidate

mars models evaluate \
  --provider ollama \
  --model qwen3.6:27b \
  --json

Make an explicit Ollama override

mars models override \
  --repo ~/my-project \
  --tier coding \
  --provider ollama \
  --model qwen3.6:27b

Model Evaluation

MARS treats new models as candidates until they pass harness-specific benchmark evidence. Newer or larger models do not become defaults because of model-card claims. A promotion must preserve tool-call reliability, structured JSON behavior, repo-ticket reasoning, speed, memory practicality, immutable artifact metadata, and checksum reproducibility.

Print the current evaluation plan

mars models evaluate
mars models evaluate --json

Without endpoint and model flags, the command prints the refresh plan, candidates, benchmark cases, and promotion rules.

Run a live endpoint benchmark

mars models evaluate \
  --endpoint http://127.0.0.1:8088/v1 \
  --model repo-coder \
  --provider openai-compatible \
  --repo ~/my-project \
  --save-report \
  --json

Reports are stored under docs/generated/model-evaluations/ by default when saving is enabled.

Record promotion metadata

mars models evaluate \
  --endpoint http://127.0.0.1:8088/v1 \
  --model repo-coder \
  --revision immutable-artifact-id \
  --sha256 SHA256_VALUE \
  --source https://example.invalid/model-card

Default promotion requires immutable revision and SHA256 metadata, not only a passing live run.

Runtime Operations

NeedCommandNotes
Check machine and repo health.mars doctor --repo ~/my-project --jsonReports config, model, database, auth, repo, and operating-model health.
Bypass local llama-server.mars start --repo ~/my-project --model-endpoint URLUse only a real OpenAI-compatible endpoint. Fake endpoints are not live evidence.
Change local bundle.mars setup --local-bundle auto --downloadSetup verifies required files for the active profile before accepting the marker.
Reduce memory pressure.Use performance_profile: speed or a smaller override.Apple Silicon generation can be memory-bandwidth bound even when CPU looks idle.
Diagnose port conflicts.Use alternate --addr, --dashboard-addr, or --model-endpoint.Inference port conflicts are classified with remediation rather than retried blindly.

Troubleshooting

SymptomMeaningUser action
Missing local model for a tier.The active role requires a model file not present under ~/.mars/models/.Run mars setup, lower the local bundle/profile, or bypass local inference with mars start --repo /path/to/repo --model-endpoint http://127.0.0.1:8080/v1 or mars run engineer --repo /path/to/repo --model-endpoint http://127.0.0.1:8080/v1.
Prompt exceeds context.The request cannot fit the served context window.Reduce routed context, choose a tier with a larger context, or fix the source of context bloat.
Ollama override fails.The named Ollama model is not installed or Ollama is unreachable.Install/pull the model in Ollama, start Ollama, or remove the override.
Cloud route fails auth.The configured api_key_env is missing in the process environment or local env file.Export the env var or run mars models credentials write-local-env.
Local generation is slow but CPU is low.Metal/GPU and memory bandwidth may be the limiting resource.Use balanced/speed profiles, smaller quantization, or fewer parallel slots.
Model tests pass but defaults should not change yet.Evaluation evidence is not the same as default promotion.Record report, compare to current defaults, add immutable revision and SHA256, then make a deliberate registry change.