Skip to content
Niki v0.11.0: TUI redesign, Go rewrite, and platform hardening.Read the release notes
niki
Esc
↑↓navigate↵open⌘Jpreview
On this page

Failovers & JSON Repair

Resilient model fallbacks, rate limit retries, and automatic schema repair.

Failover Chains & Automatic JSON Repair

Production agent pipelines must withstand upstream API outages, transient rate limits (HTTP 429), and syntax errors in LLM JSON generation.


Fallback Failover Chains

You can define an ordered list of fallback provider slugs per agent role in niki.toml. Each slug must also have a [providers.<slug>] entry. Transient errors such as rate limits, timeouts, and connection failures try the next provider:

[agents.planner]
provider  = "anthropic"
model     = "claude-sonnet-4-20250514"
fallbacks = ["openrouter", "openai"]

Automatic JSON Repair

Agents frequently return markdown-wrapped JSON code fences (```json), trailing commas, or unescaped quotes.

NIKI includes deterministic string-based JSON repair and validation:

  1. Strips markdown fences and extracts JSON from surrounding prose.
  2. Normalizes trailing commas, quotes, control characters, and common Python literals.
  3. Makes a best-effort bracket-closure repair, then validates against the artifact schema.
  4. Re-prompts the agent with validation errors when local repair is insufficient.

Was this page helpful?