core: agent silently stays in old directory when session_move fails ("Unable to move session to <dir>")
I maintainer di solito rispondono entro 1 giorno
@1052326311 ci sta già lavorando.
Dal 16/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 70/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- git, typescript
- Ambito
- tooling
Direzione di ricerca
La mappatura generica degli errori si trova in packages/core/src/tool/plugin/opencode.ts, nel Effect.mapError dello strumento session_move. Confrontala con la mappatura degli errori tipizzati nel gestore HTTP session.move e con worktree_remove nello stesso file. Riproduci il problema chiamando session_move in Code Mode su una directory inesistente. È completato quando il fallimento dello strumento indica la causa, ad esempio che la directory non esiste, invece di mostrare solo 'Unable to move session to ...'.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
After creating a worktree, the agent can end up working in the old directory without anyone noticing: session_move failed, the agent couldn't tell why, and it carried on by cd-ing into the worktree in every shell call. The session stayed in the old directory, so the worktree's AGENTS.md was never loaded and relative paths in read/edit/glob resolved against the wrong root.
How it happened (2.0.30, Sonnet 5.5): in one turn the model ran git fetch && git worktree add ../repo-x in a shell call and called tools.opencode.session_move to ../repo-x as a parallel tool call. The move ran ~100 ms after the shell started, before the fetch had finished, so the directory didn't exist yet. Rejecting the move was correct. But the tool result was only:
Unable to move session to /…/repo-x
so the model had no reason to retry. Calling session_move again once the directory existed worked.
Two things would make this recoverable:
- Say why the move failed.
packages/core/src/tool/plugin/opencode.ts(same ondev) maps every error to one message:Effect.mapError( (error) => new ToolFailure({ message: `Unable to move session to ${input.directory}`, error }), ),SessionMovealready fails with typed errors (DestinationNotFoundError,DestinationNotDirectoryError,DestinationUnavailableError,NotFoundError). Thesession.moveHTTP handler maps them to specific messages, andworktree_removein the same file maps its own errors, so the same pattern fits here. WithDirectory does not exist: …the model would most likely have retried. - Say when to call it. The injected hint ("When you create a worktree outside the current working directory … consider using
executeto calltools.opencode.session_move") and the tool description ("do not run destination-dependent tools in the same execute call") don't say the directory must exist first. Adding "call it after the command that creates the directory has finished, not in parallel with it" would likely have prevented this.
Plugins
No response
OpenCode version
2.0.30
Steps to reproduce
- In Code Mode:
await tools.opencode.session_move({ directory: "/tmp/does-not-exist" })
→Unable to move session to /tmp/does-not-exist(caught error:name: "Error", nocause) - Same move over HTTP:
opencode api post /api/session/<sessionID>/move --data '{"directory":"/tmp/does-not-exist"}'
→400 {"_tag":"InvalidRequestError","message":"Directory does not exist: /tmp/does-not-exist"} opencode.loghas no entry for the failed tool call.
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
- Lingua principale
- TypeScript
- Stelle
- 215k
- Fork
- 28.9k
- Merge medio
- 8h 29m
- PR unite (30g)
- 252
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di anomalyco/opencode
-
cli: manual recovery `node postinstall.mjs` fails on Windows - `npm_execpath` unset causes silent `spawnSync("npm")` ENOENTForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
anomalyco/opencode#56380 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
anomalyco/opencode#56352 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
web / desktop client: model tooltip shows "No reasoning" for models that expose reasoning variantsApertapending close triaging
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
anomalyco/opencode#56317 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
anomalyco/opencode#56277 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
anomalyco/opencode#56251 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di anomalyco/opencode
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
auth: agent-bearer --manager-call is told to use the MCP instance argument on an ambiguous managerAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
Lyric and ApostrophesApertabug module: playback
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
chthollyphile/folia-major#739 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
agilepathway/label-checker#773 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno