Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

core: agent silently stays in old directory when session_move fails ("Unable to move session to <dir>")

Aperta Adatta ai principianti
#56,038 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@1052326311 ci sta già lavorando.

Dal 16/10/2026.

  • #56059 di @1052326311 — aperta
  • #56060 di @bercedev — chiusa senza merge

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

reproduced
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:

  1. Say why the move failed. packages/core/src/tool/plugin/opencode.ts (same on dev) maps every error to one message:
    Effect.mapError(
      (error) => new ToolFailure({ message: `Unable to move session to ${input.directory}`, error }),
    ),
    
    SessionMove already fails with typed errors (DestinationNotFoundError, DestinationNotDirectoryError, DestinationUnavailableError, NotFoundError). The session.move HTTP handler maps them to specific messages, and worktree_remove in the same file maps its own errors, so the same pattern fits here. With Directory does not exist: … the model would most likely have retried.
  2. Say when to call it. The injected hint ("When you create a worktree outside the current working directory … consider using execute to call tools.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
  1. 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", no cause)
  2. 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"}
  3. opencode.log has 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anomalyco/opencode

Tutte le issue di anomalyco/opencode

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.