Skip to content

feat: add working_dir parameter to spawn tool for project-specific subagents#1935

Open
GodGMN wants to merge 2 commits intoHKUDS:mainfrom
GodGMN:subagent-working-dir
Open

feat: add working_dir parameter to spawn tool for project-specific subagents#1935
GodGMN wants to merge 2 commits intoHKUDS:mainfrom
GodGMN:subagent-working-dir

Conversation

@GodGMN
Copy link
Copy Markdown

@GodGMN GodGMN commented Mar 12, 2026

Summary

Adds a working_dir parameter to the spawn tool, allowing subagents to operate in specific project directories and automatically inherit project conventions from AGENTS.md as well as the SKILLS.

Problem

Previously, subagents always operated from the agent's workspace, making it difficult to:

  • Run subagents in specific project directories
  • Have subagents follow project-specific conventions (defined in AGENTS.md)
  • Have subagents use SKILLS in the project directory
  • Keep file operations isolated per project (sometimes they would put documentation and similar kindof files in the bot's base workdir, instead of the project itself)

Solution

  • Added optional working_dir parameter to SpawnTool JSON schema
  • Pass working_dir through to SubagentManager.spawn()
  • Resolve and validate working directory paths
  • Set file tool base directories and exec working directory to specified path
  • Automatically load AGENTS.md from working_dir into subagent system prompt

The new parameter is completely optional. In case it isn't included, it just functions normally.

I have added to the AGENTS.md of my coding nanobot that every subagent spawned should include a workdir parameter. Seems like it works well for strictly structured projects that may have very specific workflow/architecture instructions in the AGENTS.md. Previously, subagents would missplace files somewhat often, and they never followed the more strict project conventions.

Add a working_dir parameter to spawn so subagents can operate in a
specific directory instead of always using the root workspace.

When a working_dir is provided, file tools, exec, and the system
prompt all use that path. Skills and AGENTS.md are loaded from
the target directory as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant