Relative file reads retain the previous repository after OpenCode session_move
After moving an OpenCode session between repositories, AFT file tools still resolve relative paths against the previous repository. This can return a valid but unrelated file without an error.
Observed on macOS through OpenCode:
- Start in
rnd.math.api.contract. - Call
opencode.session_movewith the absolute siblingrnd.signalspath. It returns that directory, and OpenCode announces the new working directory and loads its instructions. - Call AFT
read({ path: "DESCRIPTION" }).
The result is the DESCRIPTION for rnd.math.api.contract, not rnd.signals. A relative read of inst/skills/r-error-handling/render.R also fails with an absolute error path under the old repository. Reading the absolute rnd.signals path succeeds.
The latest published AFT release checked was v0.63.5; the running AFT version was not confirmed. I have not established whether the stale root originates in AFT or the host integration. Expected behavior is that relative file operations follow the active session directory, or clearly expose that they remain bound to a different root.
Thanks for the clear report. It's in AFT, not the host.
AFT's OpenCode plugin remembers each session's directory from its first tool call, and that remembered directory takes precedence over the directory OpenCode passes with later calls. The cache was added for an OpenCode 1 problem, where a resumed session could report the launch directory instead of its own. On OpenCode 2, nothing clears that entry when session_move moves the session, so relative paths keep resolving against the first repository. That's why read DESCRIPTION returned the old repository's file, and absolute paths still work.
The fix is to follow the directory OpenCode 2 passes with each tool call, and to forget the remembered directory when a session moves. Until a release with it ships, absolute paths, or starting a new session in the target repository, avoid the stale root. We'll update this issue when the fix is released.
Fixed in v0.64.0: on OpenCode 2, AFT's tools use the folder sent with each call and drop the old one when a session moves. Closing this; please reopen if it comes back.