fix(install): stop folding sub-agent context into CLAUDE.md / copilot-instructions.md#121
Merged
Merged
Conversation
…-instructions.md
Sub-agent context was being duplicated into the provider's primary
instructions file (CLAUDE.md, .github/copilot-instructions.md) on top of
the dedicated `.claude/agents/{id}.md` / `.github/agents/{id}.md` file,
bloating the main agent's context window. The `writesSubAgentInstructionsContext`
fallback fired whenever the provider had a `subagents` integration and an
instructions filename that wasn't the universal `AGENTS.md` — covering
both claude-code (`foldSubAgentsIntoInstructions: false` notwithstanding)
and github-copilot. Treat a dedicated `subagents` integration as the
single source of truth and only fold when `foldSubAgentsIntoInstructions: true`
is explicitly set on a provider without its own sub-agent dir.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
CLAUDE.md,.github/copilot-instructions.md) on top of the dedicated.claude/agents/{id}.md/.github/agents/{id}.mdfile. This bloated the main agent's context window on every turn.writesSubAgentInstructionsContext(src/cli/utils/agents-file.ts:441) fired whenever the provider had asubagentsintegration AND an instructions filename that wasn't the universalAGENTS.md. That caught claude-code (the explicitfoldSubAgentsIntoInstructions: falsewas silently overridden) and github-copilot. Providers writing toAGENTS.md(cursor, codex, …) were unaffected because the equality short-circuited the branch.subagentsintegration is the single source of truth — no fold into the primary instructions file. Folding is only performed when a provider has no sub-agent integration AND explicitly opts in viafoldSubAgentsIntoInstructions: true.Behavioural diff
.claude/agents/{id}.md+CLAUDE.mdsnippet.claude/agents/{id}.mdonly.github/agents/{id}.md+.github/copilot-instructions.mdsnippet.github/agents/{id}.mdonly.{provider}/agents/{id}.mdonlycapa cleancontinues to remove any stale sub-agent blocks fromCLAUDE.md/AGENTS.mdfor users upgrading from a pre-fix install (the cleanup path is purely text-based and doesn't care how the blocks got there).Test plan
bun test src/cli/utils/__tests__/sub-agent-instructions.test.ts— flipped three assertions, added regression tests for claude-code and github-copilotbun test src/cli/utils/__tests__/agents-file.test.tsbun test src/cli/commands/__tests__/clean.test.tsbun test(1096 pass, 0 fail)tsc --noEmitclean🤖 Generated with Claude Code