Repository navigation
Description
Environment
- Copilot CLI version:
1.0.119 - OS: Windows (OS build 26300)
Describe the bug
Enabling remote access (/remote on / AHP session publication) on a resumed session repeatedly fails with:
UI error:
AHP on did not complete: Error: Request host.publishSession failed with message: session publication failed
Process / AHP logs:
[WARNING] [rust:copilotd_hosting::attached] application catalog write failed {"error":"invalid params: published session metadata conflicts with its catalog identity","operation":"publication"}
[WARNING] [rust:copilot_sdk::jsonrpc] JsonRpcClient::send_request JSON-RPC request finished {"elapsed_ms":"0","method":"host.publishSession","request_id":6,"status":"failed","code":-32603,"error":"Request host.publishSession failed with message: session publication failed"}
Root cause
For the affected sessions, the working directory recorded in the local session metadata diverged from the AHP host catalog:
~/.copilot/session-state/<session-id>/workspace.yaml:cwd: C:\Users\<user>\repo\<project>~/.copilot/ahp/<host-id>/sessions/<session-id>.json:"working_directory": "\\\\?\\C:\\Users\\<user>"
Whenever the session was resumed and /remote on (triggering host.publishSession) was invoked, the catalog write rejected the publication with invalid params: published session metadata conflicts with its catalog identity.
Additionally, if the AHP JSON file was edited while a copilot.exe process was still running, the host overwrote the JSON file on exit with the stale in-memory working_directory, causing the error to persist across restarts.
Steps to reproduce
- Have a session whose AHP catalog record (
~/.copilot/ahp/<host-id>/sessions/<session-id>.json) storesworking_directoryas directory A (e.g.\\?\C:\Users\<user>), while~/.copilot/session-state/<session-id>/workspace.yamlhascwdpointing to directory B (e.g.C:\Users\<user>\repo\<project>), e.g. after switching directories on a session already registered in AHP. - Resume that session in Copilot CLI.
- Run
/remote on. - Observe
host.publishSessionfailing immediately withpublished session metadata conflicts with its catalog identity.
Expected behavior
- Changing a session's working directory (e.g. via
/cdor/cwd) should keep the AHP catalog'sworking_directoryin sync, orhost.publishSessionshould cleanly reconcile/update the catalog entry instead of failing permanently with-32603. - Surface a clearer error message indicating which metadata field conflicted.
Verified workaround
- Exit all
copilot.exeprocesses completely (so the running host does not overwrite the catalog JSON on exit). - Update
"working_directory"in~/.copilot/ahp/<host-id>/sessions/<session-id>.jsonto matchcwdinworkspace.yaml(with the\\?\prefix on Windows, e.g.\\?\C:\Users\<user>\repo\<project>). - Restart Copilot CLI, resume the session, and run
/remote on— publication succeeds and no furthercatalog identityerrors occur.
Additional observation
Sessions created via the SDK/remote side (client_name: sdk) also store verbatim Windows extended-length paths (cwd: \\?\C:\Users\<user>) in workspace.yaml (rendered literally as \\?\C:\Users\<user> instead of ~ in the session picker) and have an ahp-session:/<uuid> URI different from session_id. Normalizing \\?\ prefixes during path comparison may also help prevent future identity mismatches on Windows.
Activity