feat(subagents): add workspaceScope config to reduce token consumption#3
Merged
Merged
Conversation
Part of openclaw#56029 Add configuration options to control which bootstrap files are injected into spawned subagents, reducing token consumption for narrow tasks. New config options in agents.defaults.subagents: - workspaceScope: "full" | "essential" | "minimal" | "none" - workspaceFiles: string[] (custom allowlist)
Part of openclaw#56029 Add filtering function to reduce bootstrap files injected into subagents: - "none": No files (for stateless tasks) - "minimal": BOOTSTRAP.md only - "essential": AGENTS.md, TOOLS.md, BOOTSTRAP.md - "full": All files (default, current behavior)
This was referenced Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes openclaw#56029
Problem
When spawning subagents via
sessions_spawn, each subagent automatically receives ALL workspace files (AGENTS.md, SOUL.md, USER.md, MEMORY.md, HEARTBEAT.md, TOOLS.md, IDENTITY.md, etc.) as context — even when the subagent is doing a narrow, stateless task like scanning database rows or running shell commands.Impact:
Solution
Add configuration options to control workspace context injection for subagents:
{ "agents": { "defaults": { "subagents": { "workspaceScope": "essential", "workspaceFiles": ["AGENTS.md", "TOOLS.md"] } } } }Scope Options
fullessentialminimalnoneCustom Allowlist
For fine-grained control:
{ "workspaceFiles": ["AGENTS.md", "MEMORY.md"] }Implementation (Phase 1)
This PR implements the foundation:
Type definitions (
types.agent-defaults.ts)workspaceScopeandworkspaceFilestoAgentDefaultsConfig.subagentsFiltering logic (
bootstrap-files.ts)SubagentWorkspaceScopetypeapplySubagentWorkspaceScopeFilter()functionresolveBootstrapFilesForRun()to accept scope parametersRemaining Work (Phase 2)
applySubagentWorkspaceScopeFilter()Token Savings Estimate
For a workflow spawning 5 workers per cycle, 10 cycles/day:
Checklist