Bug Description
When Copilot CLI 1.0.55 resumes a session created by an external producer (e.g., Agency CLI via agency cp), the new resume-auto-cd feature changes the process working directory to / instead of using the actual terminal CWD.
Current Behavior
- User runs
agency cp from ~/projects/my-repo
- Agency creates a session file (
events.jsonl) with a session.start event (no cwd field — Agency does not set it)
- Agency launches
copilot --resume <session-id> — the child process correctly inherits the terminal CWD (~/projects/my-repo)
- Copilot 1.0.55 reads
workspace.yaml (which has no CWD yet, or defaults to /) and resume-auto-cd does process.chdir("/")
- The
session.resume event is emitted with "context": { "cwd": "/" } — no git info, no branch, no repository
workspace.yaml is written with cwd: /
- The session operates from
/ — all file operations, git detection, etc. are broken
Evidence from process log:
[DEBUG] resume-auto-cd: chdir -> /
Yet the process itself was started in the correct directory — after the chdir, remoteHosts sees / instead of the real project dir.
Expected Behavior
When resume-auto-cd finds no persisted CWD (or CWD is /), it should fall back to process.cwd() (the inherited terminal CWD) rather than changing to /. The logic should be:
- If
workspace.yaml has a valid, non-root CWD → use it (current behavior, correct)
- If
workspace.yaml has no CWD, or CWD is / or empty → stay in process.cwd() (do not chdir)
- If
COPILOT_DISABLE_RESUME_AUTO_CD=1 → skip entirely (current behavior, correct)
Regression
- Works in: Copilot CLI 1.0.51 (no
resume-auto-cd feature)
- Broken in: Copilot CLI 1.0.55-0 (
resume-auto-cd introduced)
Verified by comparing two sessions started 3 minutes apart in the same Agency session:
| Session |
Copilot Version |
session.resume context |
| Good session |
1.0.51 |
Full context: cwd, gitRoot, branch, repository ✅ |
| Bad session |
1.0.55 |
cwd: / only ❌ |
Steps to Reproduce
- Create a session file manually (simulating what Agency does):
SESSION_ID=$(uuidgen | tr "[:upper:]" "[:lower:]")
mkdir -p ~/.copilot/session-state/$SESSION_ID
cat > ~/.copilot/session-state/$SESSION_ID/events.jsonl << EOF
{"type":"session.start","data":{"sessionId":"$SESSION_ID","version":1,"producer":"external","copilotVersion":"1.0.55","startTime":"2026-01-01T00:00:00.000Z"},"id":"00000000-0000-0000-0000-000000000001","timestamp":"2026-01-01T00:00:00.000Z","parentId":null}
EOF
- From a project directory (e.g.,
~/projects/my-repo), run:
copilot --resume $SESSION_ID
- Observe that CWD is
/ instead of ~/projects/my-repo
Workaround
export COPILOT_DISABLE_RESUME_AUTO_CD=1
agency cp
Environment
- Copilot CLI: 1.0.55-0
- Agency CLI: 2026.5.23.2
- OS: macOS (arm64)
Additional Context
The resume-auto-cd feature checks workspace.yaml for a persisted CWD before the session fully initializes. When the session was created by an external producer that does not write CWD to the session metadata, workspace.yaml either does not exist yet or has a default/empty CWD — and the feature interprets this as "change to /".
This affects any external tool that creates Copilot sessions programmatically (Agency CLI, CI/CD pipelines, custom integrations) — not just direct copilot invocations.
Security Side-Effect
Because sessions resume with cwd: /, the user is prompted to trust / as a directory. If accepted, / gets added to trustedFolders in ~/.copilot/config.json, which effectively trusts the entire filesystem — a security concern.
Bug Description
When Copilot CLI 1.0.55 resumes a session created by an external producer (e.g., Agency CLI via
agency cp), the newresume-auto-cdfeature changes the process working directory to/instead of using the actual terminal CWD.Current Behavior
agency cpfrom~/projects/my-repoevents.jsonl) with asession.startevent (nocwdfield — Agency does not set it)copilot --resume <session-id>— the child process correctly inherits the terminal CWD (~/projects/my-repo)workspace.yaml(which has no CWD yet, or defaults to/) andresume-auto-cddoesprocess.chdir("/")session.resumeevent is emitted with"context": { "cwd": "/" }— no git info, no branch, no repositoryworkspace.yamlis written withcwd: //— all file operations, git detection, etc. are brokenEvidence from process log:
Yet the process itself was started in the correct directory — after the chdir, remoteHosts sees
/instead of the real project dir.Expected Behavior
When
resume-auto-cdfinds no persisted CWD (or CWD is/), it should fall back toprocess.cwd()(the inherited terminal CWD) rather than changing to/. The logic should be:workspace.yamlhas a valid, non-root CWD → use it (current behavior, correct)workspace.yamlhas no CWD, or CWD is/or empty → stay inprocess.cwd()(do not chdir)COPILOT_DISABLE_RESUME_AUTO_CD=1→ skip entirely (current behavior, correct)Regression
resume-auto-cdfeature)resume-auto-cdintroduced)Verified by comparing two sessions started 3 minutes apart in the same Agency session:
session.resumecontextcwd: /only ❌Steps to Reproduce
~/projects/my-repo), run:copilot --resume $SESSION_ID/instead of~/projects/my-repoWorkaround
export COPILOT_DISABLE_RESUME_AUTO_CD=1 agency cpEnvironment
Additional Context
The
resume-auto-cdfeature checksworkspace.yamlfor a persisted CWD before the session fully initializes. When the session was created by an external producer that does not write CWD to the session metadata,workspace.yamleither does not exist yet or has a default/empty CWD — and the feature interprets this as "change to/".This affects any external tool that creates Copilot sessions programmatically (Agency CLI, CI/CD pipelines, custom integrations) — not just direct
copilotinvocations.Security Side-Effect
Because sessions resume with
cwd: /, the user is prompted to trust/as a directory. If accepted,/gets added totrustedFoldersin~/.copilot/config.json, which effectively trusts the entire filesystem — a security concern.