feat: make accessible_paths optional during agent creation#13126
feat: make accessible_paths optional during agent creation#13126kangfenmao merged 6 commits intomainfrom
Conversation
Default workspace is auto-created at {userData}/Data/agents/{agentId}/
when no paths are provided. Users can still optionally add paths during
creation or change them later in agent settings.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
DeJeune
left a comment
There was a problem hiding this comment.
Review Summary
The intent of this PR is solid — removing friction from agent creation by making accessible_paths optional is a good UX improvement, and the backend's createAgent() already handles the empty case with a default workspace.
Critical
- Empty paths on update: The frontend guard in
AccessibleDirsSetting.tsxthat prevented removing the last path was removed, but the backendupdateAgent()andupdateSession()methods do not have the same default-workspace fallback thatcreateAgent()has. If a user removes all paths via Agent Settings, the agent will be left with an emptyaccessible_pathsarray, causingPluginService.getWorkdirOrThrow()and the Claude Code service to throw errors.
Minor
- Stale
tin theremoveAccessiblePathdependency array after toast removal.
Positives
- Clean, minimal diff — only touches what's necessary.
- Good PR description with clear before/after, tradeoffs, and backend cross-references.
- Schema change propagates correctly through all derived types.
| (path: string) => { | ||
| if (!base) return | ||
| const newPaths = base.accessible_paths.filter((p) => p !== path) |
There was a problem hiding this comment.
Bug: The frontend guard preventing removal of the last path is removed, but the backend AgentService.updateAgent() does NOT auto-assign a default workspace when accessible_paths is set to an empty array — the default-path logic only exists in createAgent() (lines 40-43 of AgentService.ts).
This means: if a user removes all accessible paths via Agent Settings, the agent ends up with accessible_paths: [] in the database. Downstream code like PluginService.getWorkdirOrThrow() and ClaudeCodeService (session.accessible_paths[0]) will then throw or error.
Suggested fix options:
- Add the same default-path fallback to
AgentService.updateAgent()(andSessionService.updateSession()) whenaccessible_pathsis set to an empty array. - Keep the frontend guard here in the settings page (remove-last prevention) while still making it optional during creation.
| name: z.string().optional(), | ||
| description: z.string().optional(), | ||
| accessible_paths: z.array(z.string()).nonempty(), // Array of directory paths the agent can access | ||
| accessible_paths: z.array(z.string()), // Array of directory paths the agent can access (empty = use default workspace) |
There was a problem hiding this comment.
Note: The schema change itself looks correct. Worth noting that this also affects AgentSessionEntitySchema (line 131), CreateAgentRequestSchema, UpdateAgentRequestSchema, etc. since they all extend AgentBaseSchema. The relaxation propagates cleanly to all derived schemas — just confirming this was intentional (and it makes sense that it is).
…via update The backend createAgent() already assigned a default workspace when accessible_paths was empty, but updateAgent() and updateSession() did not. This caused PluginService and ClaudeCodeService to throw when a user removed all paths via Agent Settings. Also removes a stale `t` dependency in AccessibleDirsSetting. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Aligns with the existing convention used by other data directories (e.g., KnowledgeBase). Co-Authored-By: Claude Opus 4.6 <[email protected]>
GeorgeDong32
left a comment
There was a problem hiding this comment.
Code Review Summary
Overall this is a well-designed change that reduces friction in agent creation. The backend already had fallback logic for empty accessible_paths, so removing the frontend validation is a clean improvement.
Key Findings
-
Path Case Change: The directory name changed from
agentstoAgents. This may cause compatibility issues with existing agents. Consider keeping lowercase. -
Code Duplication: The empty path handling logic is duplicated across 3 locations. A protected method in BaseService could reduce this.
What's Good
- Frontend/backend consistency maintained
- Security validation still happens on backend (absolute path check)
- User experience improved by removing required folder selection
- Graceful fallback to default workspace when no paths provided
Security
No security issues found. Backend properly validates that paths are absolute.
Consolidates the duplicated empty-path → default-workspace logic from AgentService.createAgent, AgentService.updateAgent, and SessionService.updateSession into a single BaseService method. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Use last 9 chars of agent ID as folder name instead of full ID - Show hint text in creation modal when no paths are selected - Add i18n keys for default workspace hint Co-Authored-By: Claude Opus 4.6 <[email protected]>


What this PR does
Before this PR:
Users were required to manually select at least one workspace folder via the OS file picker when creating an agent. The creation form would block submission if no
accessible_pathswere provided.After this PR:
The
accessible_pathsfield is optional during agent creation. When no paths are provided, the backend automatically creates a default workspace at{userData}/Data/agents/{agentId}/. Users can still optionally add paths during creation or change them later in Agent Settings.Why we need it and why it was done in this way
The mandatory folder picker adds friction to agent creation — especially for new users who may not know what folder to pick. The backend already had fallback logic to create a default workspace when
accessible_pathsis empty, so this change simply removes the frontend enforcement that prevented that path from being reached.The following tradeoffs were made:
accessible_pathsconstraint was relaxed from.nonempty()to.array(z.string()). This is safe because the backend handles the empty case.The following alternatives were considered:
Breaking changes
None. The backend behavior is unchanged — it already supported empty
accessible_pathsand auto-created a default workspace.Special notes for your reviewer
AgentService.createAgent()(lines 40-43) already had the default workspace logic. No backend changes were needed.AccessibleDirsSetting.tsx, the restriction preventing removal of the last path was also removed, since the backend always ensures a valid workspace exists.Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note