feat(agent-core-v2): announce environment drift via system reminders - #2316
Open
7Sageer wants to merge 7 commits into
Open
feat(agent-core-v2): announce environment drift via system reminders#23167Sageer wants to merge 7 commits into
7Sageer wants to merge 7 commits into
Conversation
…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.
|
commit: |
…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.
# Conflicts: # packages/agent-core-v2/docs/state-manifest.d.ts
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.
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
date_changecontext 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.skill_listreminder. 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.agents_mdreminder 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.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.Verification:
agent-core-v2: 274 test files / 4244 tests passedklientinvalid-input matrix: 19 / 19 tests passedlint:domain: passedChecklist
gen-changesetsskill, or this PR needs no changeset. No changeset: experimentalagent-core-v2behavior only.gen-docsskill, or this PR needs no doc update. No CLI user-doc update: no shipped command, flag, or configuration surface changed.