Repository navigation
Conversation
…ion override Project directories now discover AGENTS.override.md alongside AGENTS.md and agents.md, preferring it over the plain names within the same directory so a local override can replace a committed AGENTS.md without editing it, matching the OpenAI Codex convention. The instruction-file watcher includes the new candidate too, so editing AGENTS.override.md triggers a live reload. Fixes MoonshotAI#3566
🦋 Changeset detectedLatest commit: 6245af3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
1 task
This branch has not been deployed
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.
Requirement or Bug
Resolve #3566
Bug Reproduction Steps
$REPOBASE, create$REPOBASE/AGENTS.override.mdwith distinctive content and noAGENTS.md.mainat21406fb4creproduces it as well)./statusor inspect the injected system prompt:$REPOBASE/AGENTS.override.mdis never loaded. Renaming the same file toAGENTS.mdmakes it load immediately.The new tests in
packages/agent-core-v2/test/agent/profile/context.test.ts(loadAgentsMd AGENTS.override.md) encode this scenario and failed before the fix.Root Cause
loadAgentsMdForRootsinpackages/agent-core-v2/src/agent/profile/context.tsenumerates the candidate instruction file names per directory from theAGENTS_MD_PLAIN_NAMESconstant, which only containedAGENTS.mdandagents.md.AGENTS.override.mdwas therefore never probed anywhere in the discovery chain (project root → cwd). This is a fundamental omission, not a workaround-level issue: the OpenAI Codex convention this feature mirrors (seecodex-rs/core/src/agents_md.rs,LOCAL_AGENTS_MD_FILENAME = "AGENTS.override.md") probes the override name first in every directory and uses the first existing candidate, so an override replaces the plainAGENTS.mdof the same directory.Code Changes
All in
packages/agent-core-v2:src/agent/profile/context.tsAGENTS_MD_PLAIN_NAMESis now['AGENTS.override.md', 'AGENTS.md', 'agents.md']. Because every consumer probes the list in order and stops at the first hit (loadAgentsMdForRoots,findAgentsMdInDir,agentsMdCandidatePaths), the override shadows only the plain names of its own directory;.kimi-code/AGENTS.mdkeeps its existing additive behavior, and ancestor directories keep contributing their own files.agentsMdWatchRootspreviously re-listed the three project candidate names by hand; it now derives the per-directory list fromAGENTS_MD_PLAIN_NAMES(plusdotKimiAgentsMdPath), so the file watcher reloads onAGENTS.override.mdedits and cannot drift from the loader again.test/agent/profile/context.test.ts— three tests: override-only root loads; override preferred overAGENTS.mdwithin one directory; per-directory replacement while ancestors keep their own files..changeset/read-agents-override-md.md— patch changeset for@moonshot-ai/kimi-code.Behavior Changes and Affected Users
AGENTS.override.mdAGENTS.override.mdandAGENTS.md/agents.mdAGENTS.override.mdand expect it ignored.kimi-code/AGENTS.mdstill loads additivelyAGENTS.md/agents.mdAGENTS.override.mdduring a sessionwatch.enabled = falseAffected modules: instruction discovery (
agent/profile/context.ts), instruction watching (WorkspaceInstructionsServiceviaagentsMdWatchRoots), the AGENTS.md discovery reminder (agentsMdReminderService.ts, which consumes the shared constants and now recognizes reads ofAGENTS.override.md). Test coverage: the three newcontext.test.tscases for discovery, and the existingagentsMdReminder.test.ts/workspaceInstructionssuites confirming no regression.Checklist
fix(agent-core-v2): read AGENTS.override.md as per-directory instruction override.changeset/read-agents-override-md.md,@moonshot-ai/kimi-code: patch).typecheck,lint(incl.check-no-comments) and theagent-core-v2suites pass locally (2 pre-existing symlink tests fail on Windows both with and without this change).