fix(coding-agent): make continual harness state reachable from the prompt - #889
Open
Hotragn wants to merge 1 commit into
Open
fix(coding-agent): make continual harness state reachable from the prompt#889Hotragn wants to merge 1 commit into
Hotragn wants to merge 1 commit into
Conversation
…ompt The system-prompt overview rendered an alphabetical head slice of 6 entries per kind, so which lessons the model saw was decided by how their paths happened to be spelled, and neither production call site could raise the cap. Rank entries by recency (updated_at, then created_at, then version) so the newest lessons survive truncation, and read the cap and body clip from a new `harnessOverview` setting. The same ranking now feeds the refiner's own overview, which had an unordered 40-entry head slice. The overflow line named withheld entries by count alone while the prompt told the model to "inspect the underlying continual harness entry" — with no call that reads them. It now names that call. On the kernel side, `rlm.harness` resolves to the session-local store, which is empty in a freshly spawned child even though the child's system prompt was built from the merged global + local state. A local overview now names the global store, its per-kind counts, and how to read it, and `overview()` and `list()` accept `include_global=True` for the merged view the prompt was built from. fixes PrimeIntellect-ai#819
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
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.
Fixes #819.
Two defects compound so that a spawned child has no reachable path to the continual harness state its own system prompt was built from. Each is the workaround for the other, so they are fixed together.
A. The prompt overview kept the alphabetically-first entries
formatHarnessStateForPromptsorted every kind by[path, title, id]and kept the first 6. Which lessons reached the model was decided by how their paths happened to be spelled — a memory written seconds ago undermemory/w/...lost its slot to 48 older entries undermemory/a/.... The options object already acceptedmaxEntriesPerKind/maxContentLength, but neither production call site insystem-prompt.tspassed them and no setting reached them, so the caps were hardcoded in practice.updated_at, falling back tocreated_atwhen it is unparseable, thenversion, then the old[path, title, id]comparison purely to break exact ties. Selection and render order are both recency-first, so the newest lesson is nearest the model and the output stays deterministic for a given state.harnessOverviewsetting (maxEntriesPerKind,maxContentLength) reaches both call sites throughSettingsManager.getHarnessOverviewSettings()andBuildSystemPromptOptions. Values are clamped informatHarnessStateForPrompt(0-500 entries, 40-4000 chars) so a bad settings value cannot blow up or collapse the prompt.overviewForPrompt, the refiner's own input, had the same defect in a milder form: an unordered 40-entry head slice. It now uses the same ranking, so a truncated list still shows the refiner the entries most likely to need an edit.The overflow line was
- +42 more memory entrieswhile the surrounding prompt instructed the model to "inspect the underlying continual harness entry only when detail matters". It named a number and no way to act on it. It now names the call:Sessions without IPython get the settings half only, matching the existing
includeIpythonExamplesgating.B.
rlm.harnesswas silent about the global storerlm.harnessresolves to the session-local store. For anrlm()-spawned child that store is new and empty, sooverview()returnsmemory: 0— while the same child's system prompt was built from the merged global + local state and lists global entries. Nothing in the output mentioned that a global store existed, how many entries it held, or thatglobal_=Truereads it.A local overview now ends with:
overview()andlist()also acceptinclude_global=True, which returns the same union the host merges to build the prompt — local entries shadow global entries on id collision, matchingmergeHarnessStates. The pointer is emitted only when a distinct global store resolves, so a global store never points at itself and a local store aliased onto the global file stays quiet.Running the issue's repro B verbatim against this branch:
Deliberately not in scope
The issue's third observation — parent-local entries never reach children, while the prompt recommends local scope for session coordination — is a scope-inheritance design change rather than a reachability fix, and would need its own decision about whether a child sees a read-only view of its parent's local store. Left for a separate issue.
Tests
packages/coding-agent/test/suite/regressions/819-harness-overview-reachability.test.ts(7 cases): the issue's repro A (the newest entry now renders, first, out of 49);created_atfallback and tie-break determinism; the overflow hint in both IPython and non-IPython prompts; clamping of negative,NaN, and oversized budgets;SettingsManagerround-trip;buildSystemPrompthonoring the option; and an end-to-end case that writes a global harness file, boots a session withharnessOverview.maxEntriesPerKind: 12, and asserts the livesession.systemPromptrenders all 12.prime-agent-runtime/test/test_harness.py(3 cases): the local overview names the global store and its counts;include_global=Truemerges with local shadowing whileglobal_=Truestill reads global alone; and no pointer is emitted when no distinct global store exists.Verified:
npm run checkclean;prime-agent-runtime38/38;test/refinement.test.ts,test/system-prompt.test.ts,test/settings-manager.test.tspass except one pre-existing Windows-only path-separator assertion inrefinement.test.tsthat also fails onmain.Note
Make continual harness state reachable from the system prompt via recency ranking and global store pointers
rlm.harness.list/rlm.harness.overviewread instructions so agents know how to access withheld entries.rlm.harness.overview()andrlm.harness.list()in harness.py gain aninclude_global=Trueparameter that merges the global peer store, with local entries shadowing global ones.harnessOverview.maxEntriesPerKindandharnessOverview.maxContentLengthsettings are exposed viaSettingsManagerand forwarded throughbuildSystemPrompt, with clamping deferred to the formatter.Macroscope summarized 47027e3.