Bug Description
Developer agents in taskctl pipelines are seeing the wrong working directory in assistant messages, causing them to correctly stop and refuse to work.
Symptoms:
- Developer prompt says: "Your working directory: /path/.worktrees/task-name"
- Agent runs
pwd and sees: /path (main project)
- Agent detects mismatch and stops: "WORKING DIRECTORY MISMATCH DETECTED"
Root Cause:
SessionPrompt.prompt() and compaction logic use Instance.directory for path.cwd in message creation instead of session.directory. This causes all assistant messages to report the main project directory regardless of the session's actual worktree directory.
Files Affected:
packages/opencode/src/session/prompt.ts - Lines 388, 613, 1575, 1665
packages/opencode/src/session/compaction.ts - Line 123
Fix:
Replace all instances of Instance.directory used for path.cwd with session.directory. The session object is already available in scope at all affected locations.
Quality Gates (Non-Negotiable)
Acceptance Criteria
- Developer agents see correct worktree directory in
path.cwd
- Messages reflect
session.directory for all session types
- All existing tests pass
- New tests verify the fix
Bug Description
Developer agents in taskctl pipelines are seeing the wrong working directory in assistant messages, causing them to correctly stop and refuse to work.
Symptoms:
pwdand sees:/path(main project)Root Cause:
SessionPrompt.prompt()and compaction logic useInstance.directoryforpath.cwdin message creation instead ofsession.directory. This causes all assistant messages to report the main project directory regardless of the session's actual worktree directory.Files Affected:
packages/opencode/src/session/prompt.ts- Lines 388, 613, 1575, 1665packages/opencode/src/session/compaction.ts- Line 123Fix:
Replace all instances of
Instance.directoryused forpath.cwdwithsession.directory. Thesessionobject is already available in scope at all affected locations.Quality Gates (Non-Negotiable)
Acceptance Criteria
path.cwdsession.directoryfor all session types