Skip to content

fix(agent-core-v2): follow symlinks when loading AGENTS.md and reading files - #1840

Merged
7Sageer merged 1 commit into
mainfrom
fix/agents-md-symlink
Jul 17, 2026
Merged

fix(agent-core-v2): follow symlinks when loading AGENTS.md and reading files#1840
7Sageer merged 1 commit into
mainfrom
fix/agents-md-symlink

Conversation

@7Sageer

@7Sageer 7Sageer commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None — the problem is described below.

Problem

The v2 engine's filesystem stat used lstat semantics, so symbolic links were never counted as regular files. Two user-visible consequences in the web backend (a common dotfiles setup is installing config/instruction files as symlinks):

  • AGENTS.md instruction files installed as symlinks were silently dropped while assembling the system prompt.
  • The Read tool rejected symlinked files with "<path>" is not a file., and ReadMediaFile size checks measured the symlink itself instead of its target.

The CLI (v1 engine) follows symlinks and handles such files correctly, so CLI and web behavior diverged.

What changed

  • IHostFileSystem.stat accepts an optional followSymlinks flag; the default keeps the previous lstat semantics, so other consumers (e.g. directory listings that need to detect symlinks) are unaffected.
  • The AGENTS.md loader, Read, and ReadMediaFile now stat with followSymlinks, matching the v1 CLI behavior.
  • Added regression tests covering symlinked user-level and project-level AGENTS.md files, plus an assertion that the Read tool stats with followSymlinks.

Skill discovery and MCP config loading were audited for the same problem and are not affected: they use node:fs directly, which already follows symlinks.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 73f77fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@73f77fc
npx https://pkg.pr.new/@moonshot-ai/kimi-code@73f77fc

commit: 73f77fc

@7Sageer
7Sageer merged commit fa7e4ba into main Jul 17, 2026
15 checks passed
@7Sageer
7Sageer deleted the fix/agents-md-symlink branch July 17, 2026 10:55
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
@7Sageer 7Sageer changed the title fix(agent-core-v2): follow symlinks when loading AGENTS.md fix(agent-core-v2): follow symlinks when loading AGENTS.md and reading files Jul 17, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 17, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 17, 2026
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant