What version of Kimi Code is running?
0.38.0
The same sequencing is present on current main at 2102c43dcec8ab09936f29695a5433efb9948b51.
Which open platform/subscription were you using?
Kimi Code. This report is model- and provider-independent because it concerns tool-execution ordering in agent-core-v2.
Which model were you using?
kimi-k3 — the tool lifecycle issue itself is model-independent.
What platform is your computer?
Darwin 25.5.0 arm64 arm
What issue are you seeing?
The AGENTS.md discovery reminder introduced by #2545 is registered on onDidExecuteTool. For mutating tools such as Edit, Write, and Bash, the target operation has therefore already completed before Kimi discovers an uninjected nested AGENTS.md and tells the model to read it.
This makes the reminder text — “Read them before making changes in those directories” — impossible to satisfy for the first mutating call in a newly touched subtree.
Current ordering:
Edit / Write / Bash executes
-> tool result is finalized
-> onDidExecuteTool runs
-> nested AGENTS.md is discovered
-> reminder is queued for the model
Source evidence at the fixed main SHA:
This is a correctness/policy-ordering issue rather than a security-boundary report: AGENTS.md is model guidance, while permissions and sandboxing remain the enforcement boundary.
What steps can reproduce the bug?
Create a repository like this:
repo/
├── AGENTS.md
└── packages/
└── api/
├── AGENTS.md # “Do not modify generated.ts.”
└── generated.ts
- Start Kimi Code from
repo/, so packages/api/AGENTS.md is outside the initial root-to-cwd instruction chain.
- Make the first operation in that subtree an
Edit or Write against packages/api/generated.ts, without reading another file in packages/api/ first.
- Observe that the mutation succeeds.
- Only after execution does the AGENTS.md reminder become model-visible.
This does not depend on model behavior: it can be reproduced at the executor/integration-test level by making Write the first tool call into the nested subtree and asserting both filesystem state and reminder delivery order.
Bash has an additional blind spot. Target extraction only recognizes directory-listing commands (ls, tree, find, dir, exa, eza, lsd):
For example, a first-touch mutation such as the following does not identify packages/api as a reminder target:
sed -i 's/old/new/' packages/api/generated.ts
Dynamic and compound path forms are intentionally skipped as well, so Bash-only workflows may receive no reminder at all.
What is the expected behavior?
Before the first mutating tool call affects a subtree covered by an uninjected AGENTS.md, Kimi should make the relevant instructions model-visible or prevent that call and ask the model to read the instruction file before retrying.
Possible behavior contracts include:
- Preflight
Edit and Write using their already-resolved file accesses. If an unseen nested AGENTS.md is found, veto the current call with an actionable result and allow the model to read and retry.
- Keep the current post-execution reminder for read-only discovery tools (
Read, Glob, Grep).
- Define an explicit policy for Bash: expand conservative literal mutation-target detection, or document that Bash-only mutations cannot receive this guarantee.
- Add a regression test proving that the first
Edit/Write cannot modify a nested subtree before its newly discovered instructions become visible.
Additional information
The existing implementation already handles many difficult edges well: per-agent deduplication, restore/resume seeding, concurrent discovery, instruction-file change announcements, symlinks, Windows paths, and not-yet-created directories. This report is intentionally limited to the remaining pre-mutation ordering gap.
For comparison, Claude Code documents that nested CLAUDE.md files are loaded on demand when it reads files in those subdirectories. Codex documents only project-root-to-cwd discovery and does not claim child-on-access enforcement. The issue here is therefore not that Kimi must copy another product; it is that Kimi's own reminder promises “before making changes” while its hook runs after the first change.
What version of Kimi Code is running?
0.38.0The same sequencing is present on current
mainat2102c43dcec8ab09936f29695a5433efb9948b51.Which open platform/subscription were you using?
Kimi Code. This report is model- and provider-independent because it concerns tool-execution ordering in
agent-core-v2.Which model were you using?
kimi-k3— the tool lifecycle issue itself is model-independent.What platform is your computer?
Darwin 25.5.0 arm64 armWhat issue are you seeing?
The AGENTS.md discovery reminder introduced by #2545 is registered on
onDidExecuteTool. For mutating tools such asEdit,Write, andBash, the target operation has therefore already completed before Kimi discovers an uninjected nestedAGENTS.mdand tells the model to read it.This makes the reminder text — “Read them before making changes in those directories” — impossible to satisfy for the first mutating call in a newly touched subtree.
Current ordering:
Source evidence at the fixed
mainSHA:agentsMdReminderregisters ononDidExecuteToolprobeAndReminddiscovers and schedules the reminderfinalizeToolResultinvokes the hook after receiving the tool resultThis is a correctness/policy-ordering issue rather than a security-boundary report:
AGENTS.mdis model guidance, while permissions and sandboxing remain the enforcement boundary.What steps can reproduce the bug?
Create a repository like this:
repo/, sopackages/api/AGENTS.mdis outside the initial root-to-cwd instruction chain.EditorWriteagainstpackages/api/generated.ts, without reading another file inpackages/api/first.This does not depend on model behavior: it can be reproduced at the executor/integration-test level by making
Writethe first tool call into the nested subtree and asserting both filesystem state and reminder delivery order.Bash has an additional blind spot. Target extraction only recognizes directory-listing commands (
ls,tree,find,dir,exa,eza,lsd):LISTING_COMMANDSFor example, a first-touch mutation such as the following does not identify
packages/apias a reminder target:sed -i 's/old/new/' packages/api/generated.tsDynamic and compound path forms are intentionally skipped as well, so Bash-only workflows may receive no reminder at all.
What is the expected behavior?
Before the first mutating tool call affects a subtree covered by an uninjected
AGENTS.md, Kimi should make the relevant instructions model-visible or prevent that call and ask the model to read the instruction file before retrying.Possible behavior contracts include:
EditandWriteusing their already-resolved file accesses. If an unseen nestedAGENTS.mdis found, veto the current call with an actionable result and allow the model to read and retry.Read,Glob,Grep).Edit/Writecannot modify a nested subtree before its newly discovered instructions become visible.Additional information
The existing implementation already handles many difficult edges well: per-agent deduplication, restore/resume seeding, concurrent discovery, instruction-file change announcements, symlinks, Windows paths, and not-yet-created directories. This report is intentionally limited to the remaining pre-mutation ordering gap.
For comparison, Claude Code documents that nested
CLAUDE.mdfiles are loaded on demand when it reads files in those subdirectories. Codex documents only project-root-to-cwd discovery and does not claim child-on-access enforcement. The issue here is therefore not that Kimi must copy another product; it is that Kimi's own reminder promises “before making changes” while its hook runs after the first change.CLAUDE.mdfiles load