{"record":{"id":"224727a99b27fd18","repo":"zed-industries/zed","slug":"working-directory-cannot-be-empty","errorCode":null,"errorMessage":"Working directory cannot be empty","messagePattern":"Working directory cannot be empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_servers/src/acp.rs","lineNumber":1481,"sourceCode":"        self,\n        session_id: acp::SessionId,\n        mcp_servers: Vec<acp::McpServer>,\n    ) -> acp::ResumeSessionRequest {\n        acp::ResumeSessionRequest::new(session_id, self.cwd)\n            .additional_directories(self.additional_directories)\n            .mcp_servers(mcp_servers)\n    }\n}\n\nfn session_directories_from_work_dirs(\n    work_dirs: &PathList,\n    supports_additional_directories: bool,\n) -> Result<SessionDirectories> {\n    let mut ordered_paths = work_dirs.ordered_paths();\n    let cwd = ordered_paths\n        .next()\n        .cloned()\n        .ok_or_else(|| anyhow!(\"Working directory cannot be empty\"))?;\n    let additional_directories = if supports_additional_directories {\n        ordered_paths.cloned().collect()\n    } else {\n        Vec::new()\n    };\n\n    Ok(SessionDirectories {\n        cwd,\n        additional_directories,\n    })\n}\n\nfn work_dirs_from_session_info(cwd: PathBuf, additional_directories: Vec<PathBuf>) -> PathList {\n    let mut seen_paths = HashSet::default();\n    let mut paths = Vec::with_capacity(1 + additional_directories.len());\n\n    seen_paths.insert(cwd.clone());\n    paths.push(cwd);","sourceCodeStart":1463,"sourceCodeEnd":1499,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent_servers/src/acp.rs#L1463-L1499","documentation":"Before sending session/new or session/load, Zed derives the session's cwd from the first entry of the work_dirs PathList; remaining entries become additional_directories (when the agent supports them). An empty list leaves no cwd to send — ACP requires one — so this error is thrown before any RPC is made.","triggerScenarios":"open_or_create_session or load_session invoked with an empty work_dirs PathList — e.g. the project has no worktrees open, or a programmatic caller built the request without any directories.","commonSituations":"The agent panel is used in a window where only a single file (no folder) is open; a caller constructs a session request with an empty path list.","solutions":["Open a folder in the project so the work-dir list is non-empty, then retry","When building the request programmatically, always pass at least one existing directory"],"exampleFix":"// before — no working directory\nopen_session(&project, PathList::default(), cx)\n\n// after — first entry becomes the session cwd\nopen_session(&project, PathList::new(vec![worktree_abs_path]), cx)","handlingStrategy":"validation","validationCode":"if work_dirs.ordered_paths().next().is_none() {\n    // no cwd to send; require at least one directory before opening a session\n    return Err(anyhow::anyhow!(\"provide a working directory\"));\n}","typeGuard":null,"tryCatchPattern":"On 'Working directory cannot be empty', prompt the user to open a folder (creating a worktree) or supply a directory, then retry the session open.","preventionTips":["Never construct session requests without at least one work directory; the first entry is the cwd","Guard agent-panel entry points on the project having at least one folder worktree"],"tags":["acp","agent-server","session","working-directory","validation"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}