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:
- Strips markdown fences and extracts JSON from surrounding prose.
- Normalizes trailing commas, quotes, control characters, and common Python literals.
- Makes a best-effort bracket-closure repair, then validates against the artifact schema.
- Re-prompts the agent with validation errors when local repair is insufficient.