* fix(cat): preserve tool progress and recover before execution * refactor(cat): keep tool turn reporting in its state
3.0 KiB
Cat and Loki agent reliability handoff
This runbook records the September 2026 reliability work and how to verify it. It concerns the chat agents at /dashboard/cat and /loki, not project dispatch or deployment of user sites.
What changed
Loki's tool loop can take up to six rounds when each round adds useful work. It stops repeated tool calls and keeps its fact and grounding limits. The change is in bitbaum/loki PR #865, with the deterministic gate in scripts/test/agent-tool-loop.ts.
Cat's router now receives recent dialogue, so follow-up requests can refer to earlier turns. A provider failure before execution can move to the next configured model using that model's endpoint and key. Once a tool starts, the turn is never replayed on another provider: a write may have happened even if its response was lost. A single deadline bounds the phase. Completed tool results and their web evidence survive a later failure, while an unfinished call is marked unconfirmed in both the answer context and the visible tool chip. The code is in src/services/cat/tool-use.ts, tool-turn-state.ts, and tool-routing-fallback.ts.
Local gates
- Loki:
pnpm run verifyandnpx tsx scripts/test/agent-tool-loop.tsinbitbaum/loki. - Cat:
pnpm run verify; focused tests are__tests__/unit/cat/tool-turn-reliability.test.ts,tool-routing-fallback.test.ts, andtool-use-bare-url.test.ts. - Keep the endpoint, model and credential together when changing provider resolution. Never retry a turn after a tool has started, especially an action tool.
Production walk
- Confirm the served Loki commit at
https://loki.orangecat.ch/api/health; PR #865 merged as4b9542c14e468246e6965a5a545e86d97b2c6213. An authenticatedPOST /api/lokimust return a real answer withvia,toolsUsed,rounds,retrieved, andgrounding. A question that cannot be verified should say so. HTTP health alone does not exercise the agent. - Confirm OrangeCat's exact served SHA from
/opt/orangecat/app/.releaseon the box and compare it with the merged commit.https://orangecat.ch/api/healthproves service health, not the release SHA. - Run the production Cat judgment harness from the box with
CAT_EVAL_NOTIFY=0so a manual probe does not file an operator notification:node /opt/orangecat/scripts/eval-cat.mjswith the app's runtime environment loaded. It uses isolated test conversations, cleans them up, and reports entity choice, explanation, and duplicate drafts. The script is the source of truth for its inputs and thresholds. - In an authenticated Cat chat, test a follow-up that depends on the prior turn, then a tool request. Verify a visible tool result or an honest unfinished state. A production fallback probe needs an actual provider failure; do not infer it worked from a healthy primary-provider turn. Check the SSE
tool_call,prefill_proposal, and finaldoneframes.
If a check fails, keep the exact prompt, response status, served SHA, and tool events in the handoff. A green CI run or a merged PR does not establish the production behavior.