Tool calls racing plugin reload fail on a released Location lease
After an OpenCode plugin hot-reload, AFT write, edit and bash intermittently returned AFT bridge Location lease has already been released. Retrying a few seconds later worked. Fourteen failures across four sessions and repeated writes in another session are recorded in dotfiles #7 and #9; #20 describes further long-session occurrences. One failure interrupted git push, so guessing whether a mutation ran is unsafe.
The v0.63.5 code still releases the Location lease on disposal (server-runtime.mjs:245-257); location-lifecycle.ts:117-123 rejects subsequent calls on that lease. Disposal may be expected. The user-facing gap is that a call racing reload fails without a bridge-side reacquire/retry path or a reliable statement of whether the call ran. A new attempt often succeeds, but agents have to inspect state first for writes.
Could the bridge recover a disposed Location for a call that has not started, and explicitly mark in-flight mutation outcomes unknown? AFT #401 improved shutdown error classification; this report is about repeated tool-call failures after hot-reload. Historical observations were on 0.59.0; the lifecycle path persists in 0.63.5. No forced reload reproduction was run on 0.63.5.
Confirmed trigger, 2026-11-07, AFT 0.63.5 / OpenCode 2.2.6: editing a file under a global plugin dir (~/.config/opencode/plugins/rnd/..., a symlink into a dotfiles repo) reloads every open project location. The server log shows 12-13 loading plugin ... aft-opencode lines at each of 20:14:06, 20:14:11 and 20:14:50. Five consecutive edit calls in one session (index.ts x2, jobs.ts, plugin.test.ts, tools.test.ts) failed with 'The AFT module connection is down or unavailable; this AFT-backed option has no host fallback', and an edit/bash call from a second session in the same server failed with 'Location lease has already been released'. Every retry races the next reload, because each edit to the plugin dir causes one. So an agent editing plugin source in place can fail repeatedly with no way to make progress. A reacquire-on-disposed-lease path for calls that have not started would fix it; edit/write have no host fallback to hide behind.
Thanks, @jjjermiah. Fixed in v0.67.1: a tool call that races a plugin reload now says whether its change may still have happened and whether it is safe to retry, instead of failing on the released lease. Please reopen if you still see it.
This still happens on 0.68.0, but only for shell.
On 2026-11-29, between 18:17 and 19:28 UTC, one session had 8 shell calls fail with AFT bridge Location lease has already been released. In the same minutes bash_watch, edit, read and grep failed 11 times with the 0.67.1 message, AFT's plugin reloaded while this call was waiting, so the call was not sent. Nothing was started; it is safe to retry now. The OpenCode log has loading plugin id=@cortexkit/[email protected] at each burst: 12 lines at 18:17, 13 at 18:18, 10 at 18:27, 6 at 19:25.
So the new wording reaches the other tools, and shell still gets the raw lease error, which does not say whether the command ran. Three of the 8 commands included a cp, so retrying them blind was a guess.
I think the reloads came from another session editing a project plugin, because the log has failed to load plugin ... .opencode/plugins/gwops at 18:17:22, but I did not confirm that.
Can shell give the same safe-to-retry answer? I have not reopened this. Tell me if you want a new issue instead.
Thanks, @jjjermiah. That's a gap in the 0.67.1 fix, and a new issue isn't needed.
On OpenCode 2, shell has its own path that keeps a command's error so it can fall back to running the command on the host. That path passed the raw lease error through instead of the reload answer the other tools give. With the fix, shell answers the same way as the other tools:
- if the plugin reloaded before the command was sent: "AFT's plugin reloaded while this call was waiting, so the call was not sent. Nothing was started; it is safe to retry now."
- if the command was already sent when the reload closed its route: the existing message that the outcome is unknown and the command must not be blindly retried.
I'm reopening this until the release with the fix is out, and I'll post here then.