Kitsune Blocks Your Coding Agent, Then Hands It a Map
A finite state machine that enforces agent behavior at the tool layer, where prompts cannot be ignored. The idea is sharper than the code, and the code is worth reading anyway.
- Kitsune enforces agent behavior at the tool layer with a finite state machine, so a blocked call cannot be talked past by the model.
- Every denial returns a map (current phase, available tools, available transitions) that lets the agent recover in one step instead of thrashing.
- The per-phase whitelist works as advertised, while the turn, edit, and command limits in the README are declared but never enforced.
- The gap between the promise and the engine is a maturity problem, not a deception problem: the idea is stronger than the current implementation.
The Call That Does Not Go Through
An agent in the PLAN phase decides it has seen enough and reaches for the editor. It calls edit("src/app.py"). Kitsune refuses. Not with an exception, not with a bare "permission denied," but with a structured object that tells the agent exactly where it stands.
{
"allowed": False,
"reason": "Tool 'edit' is not allowed in phase 'plan'",
"current_phase": "plan",
"next_phase": None,
"available_tools": ["read", "grep", "glob"],
"available_transitions": ["READY"],
"message": "\U0001F98A [Kitsune] Blocked: 'edit' is not available in PLAN.\n"
"Available tools: read, grep, glob.\n"
"To advance: call kitsune_transition with trigger: READY",
}
The return is not a boolean. It is a small report: whether the call is allowed, why, which phase the session is in, which tools are open right now, and which triggers will move it forward. The README's check description still reads check(phase, tool, workflow) -> bool, which is out of date. The real function takes a context argument and returns this dict. That shift, from a yes or no to a map, is the whole design.
The Denial Is the Feature
Every denial path in engine.py ends the same way. It appends a hint to the message: "To advance: call kitsune_transition with trigger: READY, ...". A blocked agent is told what it can do now and the exact trigger that unlocks the next step.
A bare denial is a wall. The agent, having no information, tends to retry variations of the same call, burn turns, and drift. Kitsune's denial is a waypoint. The agent reads the available transitions, calls kitsune_transition with the right trigger, and continues. The redirect costs one tool call instead of a guessing loop.
This is the part nobody leads with, and it is the most careful piece of agent UX in the repo. Enforcement is easy to get wrong in the direction of hostility. Kitsune chose to be helpful about it.
Four Steps, Then Allow
When a tool call arrives, engine.check() runs a fixed sequence. The order is the policy.
- Tool whitelist.
tool.lower()is compared against the phase's tools, lowercased. Matching is case-insensitive. - Phase-wide guards. Every
Guardon the phase is evaluated against the session context. - Per-tool guards.
phase.tool_guardsis keyed by tool name, again matched case-insensitively. - Default allow. If nothing above objects, the call goes through.
Step four is the surprising one. The engine does not decide what is safe. It decides what the workflow author has forbidden. The burden sits with whoever wrote the YAML, not with the runtime. That inversion is the reason the tool is small, and the reason a sloppy workflow is a sloppy guardrail.
The bridge between runtime state and these rules is build_context. It packs turn_count, every counter (keyed by tool name, so edit_count appears after the first edit), files_touched_count, the files_touched list, and the raw args into one dict. Guards read from it by field name.
There is a limitation worth knowing. eval_guard calls context.get(guard.field), so it does not walk dotted paths. A guard cannot reach into args.path directly; the author has to flatten what they need into the context first. The README's "Bash discernment" and "Edit limits" ideas would both have to work around this.
Also in eval_guard: a missing numeric field is coerced to 0, so edit_count < 20 passes on a fresh session with no setup. Convenient, and a footgun. A typo in a field name silently becomes zero, and the guard passes.
What the README Promises and the Engine Delivers
The README sells two headline guardrails: turn limits and edit limits. The code does not enforce either one as written.
| README claim | Code reality | Evidence |
|---|---|---|
| Turn limits (<code>max_turns: 8</code>) | Field commented out in <code>Phase</code>; Pydantic drops unknown YAML keys silently | <code>schema.py</code>, <code>engine.py</code> |
| Edit limits (<code>max_edits: 20</code>) | <code>edit_count</code> counter exists, no workflow-level cap wired to it | <code>gateway.py</code>, <code>schema.py</code> |
| Bash discernment (<code>commands: [pytest, ...]</code>) | <code>commands</code> declared on <code>Phase</code>, never read by <code>engine.py</code> | <code>engine.py</code> |
| Approval gates (<code>requires_approval</code>) | Field exists, no enforcement path | <code>schema.py</code> |
| Tool whitelisting per phase | Works. Case-insensitive, checked first | <code>engine.py</code> |
The mechanism is that Pydantic ignores unknown fields by default. The README's example YAML sets max_turns: 8 and max_edits: 20, but those fields are commented out in the Phase model, so the parser drops them without a warning. Turn counting does exist (increment_turn, turn_count), but the workflow-level cap is not wired to anything visible.
commands is declared on Phase and never read by engine.py. requires_approval, blocked_env, and env_overrides exist in the schema and have no enforcement path. The README's own example would not do what it claims.
The important row is the last one. Per-phase tool whitelisting works, exactly as described, case-insensitively, checked first. The core mechanism is real. The gap is in the advertised extras, and it reads like a project that shipped the hard part and left the easy parts as promises.
There is also comment drift. schema.py and the README both reference Turso, while db.py talks to Postgres through asyncpg and a POSTGRES_URL. The DDL uses TIMESTAMPTZ and CREATE INDEX IF NOT EXISTS, which are Postgres idioms. The data layer almost certainly migrated, and the comments did not follow. The README calls the dashboard a "Vanilla JS SPA." It is Vue 3.
Two Ways to Guardrail an Agent
There are two places to put a rule for an agent. In the prompt, or in the tool layer. They are not equivalent.
| Prompt-level instruction | Tool-layer enforcement |
|---|---|
| The model can ignore it, soften it, or reinterpret it | The call returns False and never executes |
| Enforcement is probabilistic | Enforcement is deterministic |
A prompt is a suggestion the model weighs against everything else in its context. It can be softened, reinterpreted, or simply forgotten after enough turns. A function that returns False cannot be argued with. The call does not execute, full stop.
This is why Kitsune's approach is structurally stronger, and why it is a category rather than a product. Anything that sits between the agent and its tools and returns a verdict can do this. The interesting design question is not whether to enforce. It is what you return when you do. Kitsune's answer is the map.
A Solo Project With a Sharp Idea
What is verifiable about the project is its shape. It is a Python 3.12 backend (FastAPI plus FastMCP) with a TypeScript plugin for opencode, a Vue 3 dashboard, Redis for session state, Postgres for persistence, and Clerk for auth. The commit history is dominated by a single author.
- Backend: Python 3.12, FastAPI, FastMCP, Pydantic v2, asyncpg,
redis.asyncio - Plugin: TypeScript,
@opencode-ai/plugin, Zod 4 - Dashboard: Vue 3, Vite, Tailwind, Clerk
- Storage: Redis sessions with a 1-hour TTL, Postgres persistence
- Auth: Clerk session JWTs for the dashboard, hashed API keys for the plugin and MCP clients
The Redis TTL is worth flagging. Sessions are stored with setex(..., 3600, ...), and every save resets the clock. An active session stays alive. An agent that pauses for more than an hour loses its FSM state, and its next tool call fails with "session not found or expired." The Session model carries an expires_at field that is set but never read, because Redis owns expiry.
On the author: the web research turned up no interviews, announcements, or talks tied to this repository. Searches mostly surface four unrelated projects that share the name Kitsune. So the honest statement is that the project speaks for itself through its code, and the code is worth reading.





