loki fix
Autonomously diagnose crashes from a run, synthesize a surgical code patch, apply it with a .loki.bak backup, and verify it via repro_test.py.
Usage
bash
loki fix [run_id] [--apply] [--yes] [--verify / --no-verify] [--model <model>]
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
| [run_id] | string | latest | Positional run ID in .loki/runs/ (e.g. run_20261022_120000). Defaults to the most recent run. |
| --apply, -a | bool | false | Synthesize a surgical code patch (CodeHealer), create a <file>.loki.bak backup, apply the patch to the local source file, and verify the fix. |
| --yes, -y | bool | false | Automatically confirm applying the patch without an interactive prompt (requires --apply). |
| --verify / --no-verify | bool | true | Run .loki/runs/<run_id>/repro_test.py after applying the patch to verify the crash is resolved; automatically rolls back from .loki.bak if the crash still reproduces. |
| --model, -m | string | config / active profile | LiteLLM model override for diagnosis and patch synthesis (e.g. openai/gpt-4o, anthropic/claude-3-5-sonnet-latest, ollama/llama3). |
Examples
bash
# Terminal diagnosis only (prints Root Cause Analysis & Proposed Code Fix)loki fixloki fix run_20261022_120000# Interactive patch synthesis, .loki.bak backup, apply & deterministic verificationloki fix --apply# Non-interactive batch healing with a specific AI modelloki fix --apply --yes --model anthropic/claude-3-5-sonnet-latest# Apply patch without running repro_test.py verificationloki fix --apply --no-verify
