|
1 | 1 | # opencode-retry-patch |
2 | 2 |
|
3 | | -**opencode gives up on a turn after 5 retries, about 68 seconds. On a busy free |
4 | | -model that is exactly when it should keep trying.** This retunes the retry policy |
5 | | -in the compiled binary, because it is not exposed through config. |
| 3 | +## On opencode 2.x you don't need this |
| 4 | + |
| 5 | +2.0 rewrote the retry policy. It retries 10 times instead of 5, waiting 2, 4, 8 |
| 6 | +and then 10 seconds, about 84 seconds in all. And plugins get a documented |
| 7 | +`session.retry` hook that can stop a retry or change its delay. This example is |
| 8 | +from [their plugin README](https://github.com/anomalyco/opencode/blob/dev/packages/plugin/src/README.md): |
| 9 | + |
| 10 | +```ts |
| 11 | +await ctx.session.hook("retry", (event) => { |
| 12 | + if (event.attempt >= 3) event.decision = { retry: false } |
| 13 | +}) |
| 14 | +``` |
| 15 | + |
| 16 | +The one thing 2.0 can't do yet is go past those 10 retries, which is tracked in |
| 17 | +[#54862](https://github.com/anomalyco/opencode/issues/54862). |
| 18 | + |
| 19 | +This tool only patches opencode 1.x. Run against 2.x it says so and changes |
| 20 | +nothing. It will not grow 2.x support: the 2.x binary carries a Developer ID |
| 21 | +signature, and patching it would mean swapping that for an ad-hoc one. 1.x was |
| 22 | +only ever ad-hoc signed, so nothing was lost there. |
| 23 | + |
| 24 | +If you patched 1.x and have since upgraded, you can delete what this left next |
| 25 | +to the binary, `opencode.retrypatch.json` and any `opencode.*.orig`, and remove |
| 26 | +the launch hook if you installed it. |
| 27 | + |
| 28 | +Everything below is about opencode 1.x. |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +**opencode 1.x gives up on a turn after 5 retries, about 68 seconds. On a busy |
| 33 | +free model that is exactly when it should keep trying.** This retunes the retry |
| 34 | +policy in the compiled binary, because it is not exposed through config. |
6 | 35 |
|
7 | 36 | ``` |
8 | 37 | python3 opencode-retry-patch |
@@ -30,10 +59,10 @@ reported in [#41848](https://github.com/anomalyco/opencode/issues/41848) and |
30 | 59 | default. It is also the wrong default when a free tier is under load and every |
31 | 60 | error is transient. |
32 | 61 |
|
33 | | -There is no way to change it. The published config schema at |
34 | | -`opencode.ai/config.json` has no `retry` key, and the plugin `Hooks` API has no |
35 | | -retry hook. [Issue #43596](https://github.com/anomalyco/opencode/issues/43596) |
36 | | -asks for these knobs and is still open with no label and no PR. Same request in |
| 62 | +On 1.x there is no way to change it. The config schema has no `retry` key, and |
| 63 | +the 1.x plugin `Hooks` API has no retry hook. |
| 64 | +[Issue #43596](https://github.com/anomalyco/opencode/issues/43596) asked for |
| 65 | +these knobs and was closed with the rest of the 1.x backlog. Same request in |
37 | 66 | [#41709](https://github.com/anomalyco/opencode/issues/41709), |
38 | 67 | [#43324](https://github.com/anomalyco/opencode/issues/43324) and |
39 | 68 | [#37412](https://github.com/anomalyco/opencode/issues/37412). |
@@ -157,6 +186,9 @@ actually changed pays for the full scan. |
157 | 186 | If you would rather not hook your shell, set `"autoupdate": false` in your |
158 | 187 | `opencode.json` and rerun the script whenever you update by hand. |
159 | 188 |
|
| 189 | +This is for upgrades within 1.x. The jump to 2.x ends it: the hook then prints |
| 190 | +one line saying it has nothing to do, which is your cue to remove it. |
| 191 | + |
160 | 192 | ## Is this your bug? |
161 | 193 |
|
162 | 194 | Three different failures get reported as the same thing. Only the first one is |
@@ -271,9 +303,12 @@ python3 test_patch.py |
271 | 303 |
|
272 | 304 | ## The real fix |
273 | 305 |
|
274 | | -This should be a config option, not a byte patch. If |
275 | | -[#43596](https://github.com/anomalyco/opencode/issues/43596) lands, this |
276 | | -repository becomes useless and that is the good outcome. Go add a thumbs up to |
277 | | -it. |
| 306 | +This should never have been a byte patch. The request for 1.x, |
| 307 | +[#43596](https://github.com/anomalyco/opencode/issues/43596), was closed when |
| 308 | +2.0 shipped, and 2.0 answered most of it another way: more retries by default |
| 309 | +and a plugin hook rather than config keys. That makes this repository useless |
| 310 | +on 2.x, which is the good outcome. What is left, letting the hook go past the |
| 311 | +built-in 10 retries, is |
| 312 | +[#54862](https://github.com/anomalyco/opencode/issues/54862). |
278 | 313 |
|
279 | 314 | MIT. |
0 commit comments