core: agent silently stays in old directory when session_move fails ("Unable to move session to <dir>")
メンテナーはふだん 1 日以内に返信
@1052326311 がすでに取り組んでいます。
2026年10月16日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- git, typescript
- 領域
- tooling
調査の方向性
汎用的なエラーマッピングは packages/core/src/tool/plugin/opencode.ts 内、session_move ツールの Effect.mapError にあります。HTTP ハンドラ session.move の型付きエラーマッピングや、同じファイル内の worktree_remove と比較してください。Code Mode で存在しないディレクトリを指定して session_move を呼び出し、再現します。ツールの失敗が、単に 'Unable to move session to ...' と表示するのではなく、ディレクトリが存在しないといった原因を示せば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 215k
- フォーク
- 28.9k
- 平均マージ
- 7時間 53分
- マージ済み PR(30日)
- 278
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
anomalyco/opencode のほかの issue
-
pending close triaging
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
anomalyco/opencode#56765 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
anomalyco/opencode#56735 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
anomalyco/opencode#56663 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
pending close triaging
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
anomalyco/opencode#56625 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
anomalyco/opencode#56624 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
anomalyco/opencode の issue をすべて見る
似ている issue
-
bug priority: P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
wayfinder:task
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
bug customer-reported data-plane question Service Attention Storage
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
Azure/azure-rest-api-specs#47397 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Claude thinking budget can shrink capped Haiku responses to 2,048 tokens対応中かも @DavyMassoneto が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
diegosouzapw/OmniRoute#17109 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
paperclipai/paperclip#16785 ·
メンテナーはふだん 1 日以内に返信