unwedge 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. unwedge-0.1.0/.agents/plugins/marketplace.json +20 -0
  2. unwedge-0.1.0/.claude-plugin/marketplace.json +21 -0
  3. unwedge-0.1.0/.gitignore +27 -0
  4. unwedge-0.1.0/CHANGELOG.md +20 -0
  5. unwedge-0.1.0/CONTRIBUTING.md +36 -0
  6. unwedge-0.1.0/LICENSE +202 -0
  7. unwedge-0.1.0/NOTICE +12 -0
  8. unwedge-0.1.0/PKG-INFO +212 -0
  9. unwedge-0.1.0/README.md +173 -0
  10. unwedge-0.1.0/README.tr.md +180 -0
  11. unwedge-0.1.0/SECURITY.md +25 -0
  12. unwedge-0.1.0/benchmarks/analyze.py +321 -0
  13. unwedge-0.1.0/benchmarks/common.py +56 -0
  14. unwedge-0.1.0/benchmarks/compare.py +48 -0
  15. unwedge-0.1.0/benchmarks/diagnostics.py +117 -0
  16. unwedge-0.1.0/benchmarks/families.py +203 -0
  17. unwedge-0.1.0/benchmarks/features.py +146 -0
  18. unwedge-0.1.0/benchmarks/fetch_trajectories.py +126 -0
  19. unwedge-0.1.0/benchmarks/null_spread.py +62 -0
  20. unwedge-0.1.0/benchmarks/plots.py +100 -0
  21. unwedge-0.1.0/benchmarks/redteam.py +92 -0
  22. unwedge-0.1.0/benchmarks/replay_demo.py +75 -0
  23. unwedge-0.1.0/benchmarks/run_battery.py +134 -0
  24. unwedge-0.1.0/docs/benchmark.md +245 -0
  25. unwedge-0.1.0/docs/claude-code.md +105 -0
  26. unwedge-0.1.0/docs/codex.md +77 -0
  27. unwedge-0.1.0/docs/configuration.md +62 -0
  28. unwedge-0.1.0/docs/how-it-works.md +84 -0
  29. unwedge-0.1.0/docs/providers.md +106 -0
  30. unwedge-0.1.0/docs/publishing.md +64 -0
  31. unwedge-0.1.0/docs/python-api.md +78 -0
  32. unwedge-0.1.0/plugins/claude-code/.claude-plugin/plugin.json +55 -0
  33. unwedge-0.1.0/plugins/claude-code/hooks/hooks.json +17 -0
  34. unwedge-0.1.0/plugins/codex/hooks/hooks.json +13 -0
  35. unwedge-0.1.0/plugins/codex/plugin.json +14 -0
  36. unwedge-0.1.0/pyproject.toml +65 -0
  37. unwedge-0.1.0/src/unwedge/__init__.py +23 -0
  38. unwedge-0.1.0/src/unwedge/__main__.py +3 -0
  39. unwedge-0.1.0/src/unwedge/adapters/__init__.py +1 -0
  40. unwedge-0.1.0/src/unwedge/adapters/claude_code.py +172 -0
  41. unwedge-0.1.0/src/unwedge/adapters/codex.py +117 -0
  42. unwedge-0.1.0/src/unwedge/adapters/generic.py +19 -0
  43. unwedge-0.1.0/src/unwedge/adapters/sweagent.py +113 -0
  44. unwedge-0.1.0/src/unwedge/answers.py +24 -0
  45. unwedge-0.1.0/src/unwedge/cli.py +194 -0
  46. unwedge-0.1.0/src/unwedge/code_signals.py +128 -0
  47. unwedge-0.1.0/src/unwedge/compactor.py +147 -0
  48. unwedge-0.1.0/src/unwedge/config.py +79 -0
  49. unwedge-0.1.0/src/unwedge/guard.py +210 -0
  50. unwedge-0.1.0/src/unwedge/hooks.py +161 -0
  51. unwedge-0.1.0/src/unwedge/normalize.py +148 -0
  52. unwedge-0.1.0/src/unwedge/policy.py +186 -0
  53. unwedge-0.1.0/src/unwedge/providers/__init__.py +88 -0
  54. unwedge-0.1.0/src/unwedge/providers/base.py +82 -0
  55. unwedge-0.1.0/src/unwedge/providers/http.py +122 -0
  56. unwedge-0.1.0/src/unwedge/providers/laya_local.py +109 -0
  57. unwedge-0.1.0/src/unwedge/providers/systemone_http.py +108 -0
  58. unwedge-0.1.0/src/unwedge/questions.py +406 -0
  59. unwedge-0.1.0/src/unwedge/replay.py +90 -0
  60. unwedge-0.1.0/src/unwedge/report.py +84 -0
  61. unwedge-0.1.0/src/unwedge/scrub.py +42 -0
  62. unwedge-0.1.0/src/unwedge/server.py +120 -0
  63. unwedge-0.1.0/src/unwedge/store.py +176 -0
  64. unwedge-0.1.0/src/unwedge/turns.py +45 -0
  65. unwedge-0.1.0/tests/conftest.py +23 -0
  66. unwedge-0.1.0/tests/fakes.py +53 -0
  67. unwedge-0.1.0/tests/test_adapter_signals_compactor.py +150 -0
  68. unwedge-0.1.0/tests/test_agent_adapters.py +132 -0
  69. unwedge-0.1.0/tests/test_analysis_features.py +88 -0
  70. unwedge-0.1.0/tests/test_config_store.py +108 -0
  71. unwedge-0.1.0/tests/test_guard.py +152 -0
  72. unwedge-0.1.0/tests/test_hooks_cli.py +172 -0
  73. unwedge-0.1.0/tests/test_normalize_scrub.py +136 -0
  74. unwedge-0.1.0/tests/test_packaging.py +43 -0
  75. unwedge-0.1.0/tests/test_policy.py +133 -0
  76. unwedge-0.1.0/tests/test_providers.py +282 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "unwedge",
3
+ "plugins": [
4
+ {
5
+ "name": "unwedge",
6
+ "source": {
7
+ "source": "local",
8
+ "path": "./plugins/codex"
9
+ },
10
+ "policy": {
11
+ "installation": "AVAILABLE",
12
+ "authentication": "ON_INSTALL"
13
+ },
14
+ "category": "Productivity",
15
+ "interface": {
16
+ "displayName": "unwedge circuit breaker"
17
+ }
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "unwedge",
3
+ "owner": {
4
+ "name": "umithavare",
5
+ "url": "https://github.com/umithavare"
6
+ },
7
+ "metadata": {
8
+ "description": "unwedge: a circuit breaker for AI agent doom loops.",
9
+ "version": "0.1.0"
10
+ },
11
+ "plugins": [
12
+ {
13
+ "name": "unwedge",
14
+ "source": "./plugins/claude-code",
15
+ "description": "Spots doom loops (repeated failing commands, rereading, stalled progress) and logs them or hints Claude. Needs the unwedge CLI: uv tool install unwedge.",
16
+ "version": "0.1.0",
17
+ "license": "Apache-2.0",
18
+ "keywords": ["doom-loop", "circuit-breaker", "cost", "hooks"]
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,27 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .mypy_cache/
11
+ htmlcov/
12
+ .coverage
13
+
14
+ # benchmark data (re-fetch with benchmarks/fetch_trajectories.py) and raw per-turn outputs
15
+ benchmarks/data/
16
+ benchmarks/results/*.jsonl
17
+ benchmarks/results/*.log
18
+
19
+ # local model weights and servers
20
+ models/
21
+ .laya/
22
+
23
+ # editors / OS
24
+ .idea/
25
+ .vscode/
26
+ .DS_Store
27
+ Thumbs.db
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-09-23
4
+
5
+ First public version.
6
+
7
+ - Guard with a code tier (repeats, result fingerprints, error signatures, streaks) and an optional
8
+ typed-decision provider; code-first policy with hysteresis, cooldowns and hint-before-stop.
9
+ Two hints, then an escalation that repeats at most every eight turns; the provider only picks
10
+ which hint, never how strong the intervention is.
11
+ - Providers: TypeSafe jev (hosted), Laya via `laya-serve` or `unwedge serve` (local, open weights,
12
+ laya-mlx on Apple silicon), in-process Laya for the Python API, or none. Zero-dependency HTTP
13
+ client; every provider failure fails open.
14
+ - Claude Code plugin and marketplace (background hooks; hint and stop modes).
15
+ - Codex CLI support through `hooks.json`; experimental Codex plugin marketplace.
16
+ - `unwedge hook | scan | replay | report | serve | doctor`.
17
+ - A tool result that talks to the reader (a "gate" firing) vetoes the provider's judgments for
18
+ that window and is logged; code-tier alarms still act, and nothing is sent to the agent.
19
+ - Benchmark on 218 public SWE-agent trajectories (code only vs jev, plus paired Laya
20
+ comparisons), with reproducible scripts.
@@ -0,0 +1,36 @@
1
+ # Contributing
2
+
3
+ Thanks for helping. unwedge is small on purpose: a zero-dependency core, one hook command, and a
4
+ benchmark that keeps us honest.
5
+
6
+ ## Setup
7
+
8
+ ```bash
9
+ git clone https://github.com/umithavare/unwedge && cd unwedge
10
+ python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
11
+ pip install -e ".[dev,bench]"
12
+ ruff check src tests benchmarks && pytest -q
13
+ ```
14
+
15
+ ## Ground rules
16
+
17
+ - **The core stays dependency-free.** It runs in a hook process on every tool call.
18
+ - **The guard never breaks the agent.** Provider or hook failures fail open; add a test when you
19
+ touch that path.
20
+ - **Code counts, models judge.** Anything code can compute exactly (repeats, counts, time,
21
+ budgets) stays in code. Providers only answer questions code cannot.
22
+ - **Nothing from tool output reaches the agent.** Hints are human-written; providers only select one.
23
+ - **Numbers come from the benchmark.** If you change the policy, questions or digest, rerun
24
+ `benchmarks/analyze.py` and update the README tables with what it prints, good or bad.
25
+
26
+ ## Adding a harness
27
+
28
+ Write an adapter that turns the harness's tool-call payload into a `Turn`
29
+ (`src/unwedge/adapters/`), teach `hooks.detect_harness` to recognize it, and add tests with
30
+ real payload samples.
31
+
32
+ ## Adding a provider
33
+
34
+ Implement the `Provider` protocol (`src/unwedge/providers/base.py`) or expose a
35
+ `POST /v1/systemone` endpoint and use the `laya` provider with `LAYA_URL`. Add a `Profile` that
36
+ matches the model's context size (full or compact battery).
unwedge-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
unwedge-0.1.0/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ unwedge (unwedge)
2
+ Copyright 2026 umithavare
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ The benchmark samples trajectories from the public Hugging Face dataset
7
+ nebius/SWE-agent-trajectories; the data is downloaded by benchmarks/fetch_trajectories.py
8
+ and is not redistributed in this repository.
9
+
10
+ TypeSafe and jev are products of TypeSafe AI. Laya is by Convai Innovations; laya-mlx is an
11
+ independent MLX port. This project is independent and not affiliated with or endorsed by any
12
+ of them.
unwedge-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.5
2
+ Name: unwedge
3
+ Version: 0.1.0
4
+ Summary: 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.
5
+ Project-URL: Homepage, https://github.com/umithavare/unwedge
6
+ Project-URL: Documentation, https://github.com/umithavare/unwedge/tree/main/docs
7
+ Project-URL: Issues, https://github.com/umithavare/unwedge/issues
8
+ Author: umithavare
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: ai-agents,circuit-breaker,claude-code,codex,doom-loop,hooks,jev,laya,llm-cost,typed-decisions
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development :: Quality Assurance
24
+ Requires-Python: >=3.10
25
+ Provides-Extra: bench
26
+ Requires-Dist: httpx>=0.27; extra == 'bench'
27
+ Requires-Dist: matplotlib>=3.7; extra == 'bench'
28
+ Requires-Dist: numpy>=1.24; extra == 'bench'
29
+ Requires-Dist: scikit-learn>=1.3; extra == 'bench'
30
+ Provides-Extra: dev
31
+ Requires-Dist: numpy>=1.24; extra == 'dev'
32
+ Requires-Dist: pytest>=8; extra == 'dev'
33
+ Requires-Dist: ruff>=0.6; extra == 'dev'
34
+ Provides-Extra: laya
35
+ Requires-Dist: laya>=0.3.11; extra == 'laya'
36
+ Provides-Extra: laya-mlx
37
+ Requires-Dist: laya-mlx>=0.2; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'laya-mlx'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # unwedge
41
+
42
+ **A circuit breaker for AI coding agents.** unwedge notices when Claude Code, Codex CLI or your
43
+ own agent loop is stuck (the same failing command again, the same error ignored, no progress
44
+ toward the task) and says so before the loop burns your budget.
45
+
46
+ *Wedged* is old developer slang for a process that is stuck and cannot go on without help;
47
+ unwedge spots a wedged agent, nudges it, and tells you when a nudge is not enough.
48
+
49
+ [![ci](https://github.com/umithavare/unwedge/actions/workflows/ci.yml/badge.svg)](https://github.com/umithavare/unwedge/actions/workflows/ci.yml)
50
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
51
+ ![python](https://img.shields.io/badge/python-3.10%2B-blue.svg)
52
+
53
+ [Türkçe](README.tr.md) · [Claude Code](docs/claude-code.md) · [Codex](docs/codex.md) ·
54
+ [Providers](docs/providers.md) · [How it works](docs/how-it-works.md) · [Benchmark](docs/benchmark.md)
55
+
56
+ ---
57
+
58
+ Agents fail in a characteristic way: stuck at turn 9, still retrying at turn 60. `max_turns`,
59
+ token caps and timeouts protect the budget, not the behaviour, so they fire after the money is
60
+ spent. unwedge watches the behaviour:
61
+
62
+ ```text
63
+ T6 edit 199:205 (+19 lines) -> edit REJECTED, not applied: F821 undefined name S=0.97 P0=0.13
64
+ T7 edit 199:205 (+19 lines) -> edit REJECTED, not applied: F821 undefined name S=0.97 P0=0.18
65
+ T8 edit 199:205 (+19 lines) -> edit REJECTED, not applied: F821 undefined name S=0.97 P0=0.19 <<< hint
66
+ [UNWEDGE] You have run this command 4 times with the same result. Change something before
67
+ running it again, or step back and re-read the error.
68
+ T11 ... <<< hint
69
+ T14 ... <<< escalate
70
+ ```
71
+
72
+ *A real SWE-agent session from the benchmark, replayed with live jev judgments (S = stall,
73
+ P0 = probability of no progress). The agent's edit was rejected 31 times in a row, and 94% of
74
+ the session's spend came after unwedge's first hint.
75
+ [Full replay](benchmarks/results/replay_larpix.txt).*
76
+
77
+ ## What it does
78
+
79
+ - **Records every tool call** through a hook and computes loop signals in code: repeated actions
80
+ with nothing changed in between, repeated results, repeated error signatures, streaks. Free and local.
81
+ - **Optionally asks a typed-decision model** the questions code cannot answer, relative to *this*
82
+ session's task: is the agent still getting closer, is the work already done, is it drifting.
83
+ Providers: [TypeSafe jev](https://docs.typesafe.ai) (hosted) or
84
+ [Laya](https://github.com/NandhaKishorM/laya) (open weights, runs locally;
85
+ [laya-mlx](https://github.com/mizorewww/laya-mlx) on Apple silicon). Models only return
86
+ probabilities; they never write text to your agent.
87
+ - **Acts according to its mode:** `shadow` only records; `hint` adds a short, human-written hint to
88
+ the agent's context; `stop` (opt-in) can end a session that keeps looping after two hints.
89
+ - **Never breaks the agent:** every provider or hook problem fails open.
90
+
91
+ ## Quick start
92
+
93
+ ```bash
94
+ uv tool install git+https://github.com/umithavare/unwedge # PyPI (soon): uv tool install unwedge
95
+ unwedge scan # replay your recent Claude Code and Codex sessions and flag loops; free, local
96
+ unwedge doctor # check settings and the provider
97
+ ```
98
+
99
+ **Claude Code**
100
+
101
+ ```text
102
+ /plugin marketplace add umithavare/unwedge
103
+ /plugin install unwedge@unwedge
104
+ ```
105
+
106
+ The plugin runs in the background (no added latency) and asks for its mode and provider when you
107
+ enable it. Details, manual `settings.json` setup and stop mode: [docs/claude-code.md](docs/claude-code.md).
108
+
109
+ **Codex CLI** (0.124+): add to `~/.codex/hooks.json`, then approve it in `/hooks`:
110
+
111
+ ```json
112
+ { "hooks": { "PostToolUse": [{ "hooks": [{ "type": "command", "command": "unwedge hook", "timeout": 15 }] }] } }
113
+ ```
114
+
115
+ More, including the plugin marketplace: [docs/codex.md](docs/codex.md).
116
+
117
+ **Your own agent loop**
118
+
119
+ ```python
120
+ from unwedge import Guard, GuardConfig, make_provider
121
+ from unwedge.adapters.generic import turn_from_command
122
+
123
+ provider = make_provider("none") # or "jev", "laya"
124
+ guard = Guard(goal=task, provider=provider, config=GuardConfig.for_provider(provider, shadow=False))
125
+ outcome = guard.on_turn(turn_from_command(index, command, output))
126
+ if outcome.hint_text:
127
+ next_message += outcome.hint_text
128
+ ```
129
+
130
+ See [docs/python-api.md](docs/python-api.md).
131
+
132
+ ## Providers
133
+
134
+ | | `none` (default) | `jev` | `laya` |
135
+ |---|---|---|---|
136
+ | runs | locally, code only | TypeSafe API (US) | your machine (`laya-serve` or `unwedge serve`) |
137
+ | cost per judged turn | free | ~$0.0001 | free |
138
+ | latency per judged turn | none | p50 0.32 s, p99 0.64 s | p50 2.4 s (`multilingual`) to 4.1 s (`english`) on an 8-thread CPU; GPU and Apple silicon not measured |
139
+ | gain over code alone in our benchmark | – | +5 points of doomed sessions caught | none measured (see below) |
140
+ | data leaves the machine | no | yes (a scrubbed digest) | no |
141
+
142
+ Choose with `UNWEDGE_PROVIDER` or the plugin option. Setup for each: [docs/providers.md](docs/providers.md).
143
+
144
+ ## Does it work?
145
+
146
+ We replayed 218 public SWE-agent sessions (69 solved, 99 that failed after exhausting their
147
+ context budget, 50 that submitted a wrong patch) through unwedge, with every threshold fixed
148
+ before looking at the data. "Caught" means a doomed session got a hint or escalation before its
149
+ last turn; a false alarm is the same thing in a session that went on to succeed.
150
+
151
+ | policy (nothing tuned) | doomed sessions caught | successful sessions told they look stuck | successful sessions with any message | doomed-session spend after the first alarm |
152
+ |---|---|---|---|---|
153
+ | code only (`provider=none`) | 60% | 7.2% (5 of 69) | 7.2% | 47% |
154
+ | **code + jev, as shipped** | **65%** | **7.2% (5 of 69)** | **15.9%** | **55%** |
155
+ | jev only | 26% | 1.4% (1 of 69) | 10.1% | 27% |
156
+ | original design: jev overrides code | 30% | 2.9% (2 of 69) | 11.6% | 31% |
157
+
158
+ What we learned, plainly:
159
+
160
+ - **Code does most of the work.** jev adds a modest gain on top: +5 points of catches and
161
+ +8 points of recoverable spend, with the same false-alarm rate. Its other contribution is a
162
+ one-time "the task may already be done; verify it and finish" note, which went to 9% of
163
+ successful sessions and to none of the failed ones. Letting the model *override* code halves
164
+ what is caught, so the shipped policy puts code first.
165
+ - **No setting is precise enough to stop sessions automatically.** Even with thresholds tuned by
166
+ cross-validation, every detector (plain `max_turns` included) interrupted 1.4-5% of sessions
167
+ that would have succeeded. That is why hints are the default and stop mode is opt-in.
168
+ - **jev reads windows well but predicts outcomes weakly.** Its stall judgment separates the
169
+ groups (median 0.70 in doomed sessions, 0.28 in successful ones), yet it rated most windows of
170
+ doomed sessions as still making some progress.
171
+ - **Laya, as configured here, adds nothing yet.** On paired subsets of the same sessions, neither
172
+ checkpoint separated stuck from healthy sessions, so code + Laya performed exactly like code
173
+ alone. The integration works; its value for this task is not established.
174
+ [Details](docs/benchmark.md#laya).
175
+
176
+ Method, cross-validated numbers, latency, cost, an edge-firewall finding and the caveats (one
177
+ agent, one model family, 69 successes): [docs/benchmark.md](docs/benchmark.md). Everything is
178
+ reproducible from [`benchmarks/`](benchmarks).
179
+
180
+ ## How it works
181
+
182
+ Code signals on every turn → a provider only on suspicious turns (plus a periodic sample) → a
183
+ pure-function policy with hysteresis, cooldowns and hint-before-stop → a hook response. The
184
+ provider sees a small, secret-scrubbed digest of the session, sized to its context window.
185
+ [docs/how-it-works.md](docs/how-it-works.md) · [docs/configuration.md](docs/configuration.md)
186
+
187
+ ## Privacy and security
188
+
189
+ Tool output is scrubbed of common secrets and clipped before it is stored (`~/.unwedge`, deleted
190
+ after 7 days) or sent to a provider. With `none` or `laya` nothing leaves your machine. unwedge is
191
+ a cost and liveness guard, **not** a security control. See [SECURITY.md](SECURITY.md).
192
+
193
+ ## Status
194
+
195
+ Alpha (0.1). The hook handler follows the documented Claude Code and Codex hook payloads and is
196
+ covered by tests (Linux, macOS and Windows in CI). In a local Claude Code run the hooks fired
197
+ and recorded the session; the rest of the flow was tested by feeding recorded hook payloads to
198
+ `unwedge hook`. The Codex integration has not yet been run against a live Codex CLI. Transcript
199
+ replay (`scan`, `replay`) reads internal formats and is best-effort. Thresholds were set before
200
+ looking at the data and have not been tuned for Laya.
201
+
202
+ ## Contributing
203
+
204
+ Issues and pull requests are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md).
205
+
206
+ ## License and credits
207
+
208
+ Apache-2.0. TypeSafe and jev are products of TypeSafe AI. Laya is by Convai Innovations;
209
+ laya-mlx is an independent MLX port. The benchmark samples the public
210
+ [nebius/SWE-agent-trajectories](https://huggingface.co/datasets/nebius/SWE-agent-trajectories)
211
+ dataset, which is not redistributed here. This project is independent and not affiliated with
212
+ any of them.