Skip to content

feat(agent-core-v2): announce environment drift via system reminders - #2316

Open
7Sageer wants to merge 7 commits into
mainfrom
feat-skill-reminder
Open

feat(agent-core-v2): announce environment drift via system reminders#2316
7Sageer wants to merge 7 commits into
mainfrom
feat-skill-reminder

Conversation

@7Sageer

@7Sageer 7Sageer commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No public issue — the problem is explained below.

Problem

The v2 system prompt is rendered at profile bind and after compaction. In a long-lived session, the rendered environment can therefore drift from reality: the date becomes stale after midnight, newly added skills stay invisible to the model, and edited AGENTS.md instructions remain stale until the next prompt refresh.

Skill removals do not need an announcement because invoking a removed skill already fails naturally. Plugin enable/disable remains session-boundary behavior and is outside this PR.

What changed

  • Added an App-scoped file-source monitor that shares equivalent host watchers across consumers, follows missing-root ancestors until the target appears, normalizes real paths, bounds skill traversal depth, follows symlinked skill bundles, debounces change bursts, and disposes or cancels pending work with its owner.
  • Updated user, workspace, explicit, extra, and plugin skill sources to watch their candidate roots and reload only the affected source. A failed watch-triggered reload keeps the previous contribution.
  • Added a date_change context reminder. Its baseline comes from the latest surviving reminder, the rendered prompt date, or an Agent-state seed for prompts without a date line; it announces each later local calendar date once.
  • Added a structured skill_list reminder. The persisted wire value records the system-prompt disclosure baseline, while the latest surviving reminder supplies the live conversation baseline. New names inject the full current listing; removals and text-only changes stay quiet. Context undo or clear naturally removes the live baseline and allows the addition to be announced again.
  • Added an agents_md reminder that watches the active candidate chain and reads only after a relevant change. Its baseline comes from surviving reminder history, the prompt's fenced block, or an Agent-state seed. Edits, creations, and removals all announce.
  • Refreshes the rendered system prompt when profile.update({ cwd }) changes the working directory, updating cwd-dependent prompt content such as the directory listing and AGENTS.md chain. Forking with a cwd override waits for that refresh before returning the child. An omitted binding cwd falls back to the session cwd rather than the process cwd.
  • Keeps the harness on a stubbed host watcher so tests do not spawn unrelated real chokidar handles.

Verification:

  • agent-core-v2: 274 test files / 4244 tests passed
  • klient invalid-input matrix: 19 / 19 tests passed
  • lint:domain: passed
  • TypeScript typecheck: passed
  • Oxlint: no new warnings in this round
  • Config, state, and wire manifests regenerated with no diff

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. No changeset: experimental agent-core-v2 behavior only.
  • Ran gen-docs skill, or this PR needs no doc update. No CLI user-doc update: no shipped command, flag, or configuration surface changed.

…reminders

The system prompt is only re-rendered at profile bind and after
compaction, so a long session keeps a stale date after midnight and a
skill added mid-session is invisible to the model. Inject the two
facts as <system-reminder> messages through the per-step context
injector instead:

- date_change: before each step, compares the local date against a
  baseline derived from the last such reminder in context, else the
  date rendered into the current system prompt.
- skill_list: watches the file-based skill roots (chokidar, 300ms
  debounce, parent-dir re-bind so roots created mid-session are
  detected), reloads only the changed source, and injects the full
  fresh listing only when new skill names appear.

Both baselines are history-derived (no extra state files), so resume
does not double-inject and compaction resets them naturally. The test
harness now stubs the fs watch service so sessions no longer spawn
real chokidar watchers per test.
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f5638b3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026

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

commit: f5638b3

…t on cwd change

Two more system-prompt facts that drift mid-session:

- agents_md: re-reads the AGENTS.md chain when a watch over the chain's
  candidate paths reports a change (never per step, so the step pipeline
  carries no filesystem IO), and injects the fresh content when it
  differs from the last reminder in context or the system prompt's
  fenced AGENTS.md block. Edits, creations, and removals all announce —
  a deleted rule fails silently, never on invocation.
- cwd: profile.update({cwd}) now re-renders the system prompt, since a
  working-directory change invalidates the whole environment section
  (cwd, directory listing, AGENTS.md chain, project skill roots), the
  same class of change as the existing tool-policy refresh triggers.
@7Sageer 7Sageer changed the title feat(agent-core-v2): announce date changes and new skills via system reminders feat(agent-core-v2): announce environment drift via system reminders Jul 28, 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