feat(context): compose context files instead of first-match-wins - #2849
Closed
dlkakbs wants to merge 1 commit into
Closed
feat(context): compose context files instead of first-match-wins #2849dlkakbs wants to merge 1 commit into
dlkakbs wants to merge 1 commit into
Conversation
Load all present context files (hermes.md, AGENTS.md, CLAUDE.md) together instead of stopping at the first match. Each file is still independently capped at 20k chars. .cursorrules remains a fallback and is only loaded when none of the above are present. Closes NousResearch#2835
Contributor
|
Thanks for the contribution, @dlkakbs! Closing this as a duplicate of #2846 (by @Mibayy), which targets the same fix/feature. We're consolidating on that PR for review. If you want to help push it over the line, please jump in there — or if you think your approach is better for a specific reason that isn't covered in the other PR, let us know and we can reopen. |
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.
What does this PR do?
build_context_files_prompt()used anor-chain that silently dropped every context file after the first match. A project with both.hermes.mdandAGENTS.mdwould only ever load.hermes.md-AGENTS.mdwas never seen by the agent.This PR makes context files composable: all present primary sources are loaded and concatenated. Each file keeps its own independent 20k char cap rather than distributing a shared budget proportionally (#2846)This avoids penalizing large files when fewer sources are present - a project with only two context files still gets up to 20k each, not 10k.
.cursorrulesremains a pure fallback and is only loaded when none of the primary sources are present.Related Issue
Fixes #2835
Type of Change
Changes Made
agent/prompt_builder.py— replacedor-chain inbuild_context_files_prompt()with explicit composition;.cursorrulesloaded only when no primary files are presenttests/agent/test_prompt_builder.py— updated 3 tests that asserted first-match-wins behavior; added composition assertionsHow to Test
.hermes.mdandAGENTS.mdhermesin that directory.cursorrules(no.hermes.md,AGENTS.md, orCLAUDE.md).cursorrulesstill loads as beforeChecklist
feat(context):)pytest tests/ -qand all tests pass (95 passed, 1 pre-existing failure unrelated to this change)Documentation & Housekeeping
build_context_files_prompt()docstring to reflect new behaviorcli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A