A circuit breaker for AI coding agents: catches doom loops in Claude Code, Codex CLI and custom agent loops, with optional judgments from TypeSafe jev or a local Laya model.
pip install unwedge==0.1.0 Copy PIP instructions
Wedged is old developer slang for a process that is stuck and cannot go on without help; unwedge spots a wedged agent, nudges it, and tells you when a nudge is not enough.
Türkçe · Claude Code · Codex · Providers · How it works · Benchmark
Agents fail in a characteristic way: stuck at turn 9, still retrying at turn 60. max_turns, token caps and timeouts protect the budget, not the behaviour, so they fire after the money is spent. unwedge watches the behaviour:
T6 edit 199:205 (+19 lines) -> edit REJECTED, not applied: F821 undefined name S=0.97 P0=0.13 T7 edit 199:205 (+19 lines) -> edit REJECTED, not applied: F821 undefined name S=0.97 P0=0.18 T8 edit 199:205 (+19 lines) -> edit REJECTED, not applied: F821 undefined name S=0.97 P0=0.19 <<< hint [UNWEDGE] You have run this command 4 times with the same result. Change something before running it again, or step back and re-read the error. T11 ... <<< hint T14 ... <<< escalate A real SWE-agent session from the benchmark, replayed with live jev judgments (S = stall, P0 = probability of no progress). The agent's edit was rejected 31 times in a row, and 94% of the session's spend came after unwedge's first hint. Full replay.
uv tool install git+https://github.com/umithavare/unwedge # PyPI (soon): uv tool install unwedge unwedge scan # replay your recent Claude Code and Codex sessions and flag loops; free, local unwedge doctor # check settings and the provider Claude Code
/plugin marketplace add umithavare/unwedge /plugin install unwedge@unwedge The plugin runs in the background (no added latency) and asks for its mode and provider when you enable it. Details, manual settings.json setup and stop mode: docs/claude-code.md.
Codex CLI (0.124+): add to ~/.codex/hooks.json, then approve it in /hooks:
{ "hooks": { "PostToolUse": [{ "hooks": [{ "type": "command", "command": "unwedge hook", "timeout": 15 }] }] } } More, including the plugin marketplace: docs/codex.md.
from unwedge import Guard, GuardConfig, make_provider from unwedge.adapters.generic import turn_from_command provider = make_provider("none") # or "jev", "laya" guard = Guard(goal=task, provider=provider, config=GuardConfig.for_provider(provider, shadow=False)) outcome = guard.on_turn(turn_from_command(index, command, output)) if outcome.hint_text: next_message += outcome.hint_text See docs/python-api.md.
Choose with UNWEDGE_PROVIDER or the plugin option. Setup for each: docs/providers.md.
We replayed 218 public SWE-agent sessions (69 solved, 99 that failed after exhausting their context budget, 50 that submitted a wrong patch) through unwedge, with every threshold fixed before looking at the data. "Caught" means a doomed session got a hint or escalation before its last turn; a false alarm is the same thing in a session that went on to succeed.
Method, cross-validated numbers, latency, cost, an edge-firewall finding and the caveats (one agent, one model family, 69 successes): docs/benchmark.md. Everything is reproducible from benchmarks/.
Tool output is scrubbed of common secrets and clipped before it is stored (~/.unwedge, deleted after 7 days) or sent to a provider. With none or laya nothing leaves your machine. unwedge is a cost and liveness guard, not a security control. See SECURITY.md.
Alpha (0.1). The hook handler follows the documented Claude Code and Codex hook payloads and is covered by tests (Linux, macOS and Windows in CI). In a local Claude Code run the hooks fired and recorded the session; the rest of the flow was tested by feeding recorded hook payloads to unwedge hook. The Codex integration has not yet been run against a live Codex CLI. Transcript replay (scan, replay) reads internal formats and is best-effort. Thresholds were set before looking at the data and have not been tuned for Laya.
Issues and pull requests are welcome; see CONTRIBUTING.md.
Apache-2.0. TypeSafe and jev are products of TypeSafe AI. Laya is by Convai Innovations; laya-mlx is an independent MLX port. The benchmark samples the public nebius/SWE-agent-trajectories dataset, which is not redistributed here. This project is independent and not affiliated with any of them.
ai-agents circuit-breaker claude-code codex doom-loop hooks jev laya llm-cost typed-decisions
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.




