Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#56,038 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, typescript
Área
tooling

Línea de trabajo

La asignación genérica de errores está en packages/core/src/tool/plugin/opencode.ts, en el Effect.mapError de la herramienta session_move. Compárala con la asignación de errores tipados en el manejador HTTP session.move y con worktree_remove en el mismo archivo. Reproduce el problema llamando a session_move en Code Mode con un directorio que no existe. Estará terminado cuando el fallo de la herramienta indique la causa, por ejemplo que el directorio no existe, en lugar de solo 'Unable to move session to ...'.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
213k
Forks
28.4k
Merge medio
8 h 58 min
PR fusionados (30 d)
251

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anomalyco/opencode

Todos los issues de anomalyco/opencode

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.