You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently no way to set a different cwd or additional allowed directories for a subagent. Both AgentDefinition (SDK) and file-based subagent frontmatter lack any directory-scoping fields. This makes per-subagent filesystem isolation impossible at the configuration level.
Neither supports cwd or additionalDirectories. Subagents always inherit the parent session's cwd, and additionalDirectories is only available on the top-level query() options — applying to the entire session, not per-agent.
Expected behavior
AgentDefinition and file-based frontmatter should support:
// SDKconstagents={"user-reader-user1": {description: "Reads user1's private data",prompt: "...",tools: ["Read"],cwd: "/workspace",// override cwdadditionalDirectories: ["users/user1"],// allow this dir only}}
Concrete use case: A scheduling agent where the orchestrator spawns per-user subagents to read private calendar and contact data from users/{userId}/. The orchestrator should have no access to user data; each user-subagent should be scoped to its own user's directory.
Summary
There is currently no way to set a different
cwdor additional allowed directories for a subagent. BothAgentDefinition(SDK) and file-based subagent frontmatter lack any directory-scoping fields. This makes per-subagent filesystem isolation impossible at the configuration level.Current behavior
AgentDefinition(TypeScript SDK) supports:File-based subagent frontmatter supports:
Neither supports
cwdoradditionalDirectories. Subagents always inherit the parent session'scwd, andadditionalDirectoriesis only available on the top-levelquery()options — applying to the entire session, not per-agent.Expected behavior
AgentDefinitionand file-based frontmatter should support:Why this matters
Concrete use case: A scheduling agent where the orchestrator spawns per-user subagents to read private calendar and contact data from
users/{userId}/. The orchestrator should have no access to user data; each user-subagent should be scoped to its own user's directory.Without directory scoping per subagent:
PreToolUsehooks with union-based enforcement (see related issue PreToolUse hook input should include agent_id to identify subagent origin #31939), which breaks down when multiple user-subagents run in parallelisolation: worktreegoes the wrong direction — it isolates the subagent into a fresh git worktree that lacks runtime-generated user data entirelyadditionalDirectorieson the parentquery()grants the directories to all agents in the session, not just the intended subagentWith
additionalDirectoriesonAgentDefinition/ frontmatter:Related
PreToolUsehook input missingagent_id(the other half of this problem — without either fix, per-subagent isolation requires fragile workarounds)Verified SDK version
@anthropic-ai/claude-agent-sdkv0.2.52