Repository navigation
feat(agent-runtime): recall, a reversible compaction boundary, and per-model context settings - #721
zhangqingkun976 wants to merge 2 commits into
Conversation
35e2be9 to
b079451
Compare
…under pressure Rebased onto main (79cd7ae). One conflict, from vastsa#733 extracting the budget formula: `ContextBudget` and the `retainedUserMessageBudget` doc comment now live in `context-budget.ts`, so they stay out of `runtime.ts`, and `narrowToolResultsUnderPressure` sits beside the import. Standalone shape: the gate is the fixed `TOOL_RESULT_TIER_PRESSURE` share of the hard limit. The per-model configurable threshold is in vastsa#721, which contains this change.
…under pressure Rebased onto main (79cd7ae). One conflict, from vastsa#733 extracting the budget formula: `ContextBudget` and the `retainedUserMessageBudget` doc comment now live in `context-budget.ts`, so they stay out of `runtime.ts`, and `narrowToolResultsUnderPressure` sits beside the import. Standalone shape: the gate is the fixed `TOOL_RESULT_TIER_PRESSURE` share of the hard limit. The per-model configurable threshold is in vastsa#721, which contains this change. C:\Users\10470\.pi-desktop\scratch\cb9e2d41-8a55-4a18-899d-92ca2791ab51\commit-705-r.txt
fd75eb8 to
cfdbcfb
Compare
…under pressure Rebased onto main (79cd7ae). One conflict, from vastsa#733 extracting the budget formula: `ContextBudget` and the `retainedUserMessageBudget` doc comment now live in `context-budget.ts`, so they stay out of `runtime.ts`, and `narrowToolResultsUnderPressure` sits beside the import. Standalone shape: the gate is the fixed `TOOL_RESULT_TIER_PRESSURE` share of the hard limit. The per-model configurable threshold is in vastsa#721, which contains this change. C:\Users\10470\.pi-desktop\scratch\cb9e2d41-8a55-4a18-899d-92ca2791ab51\commit-705-r2.txt
84e63d5 to
bf43a61
Compare
|
Rebased onto The only conflicts were append-vs-append — the E2E scenario catalog and the decisions log, where main and this branch each added an entry — and both sides are kept. The identifier bands are still free: upstream's newest ADR is 0299 and its newest decisions-log entry is D607 (the plugin crash report, which is this repository's own fix for issue #747 built on my #756). This one is two commits on the new base: the change itself, then the ADR/spec/decisions-log/E2E text. |
…under pressure Rebased onto main (79cd7ae). One conflict, from vastsa#733 extracting the budget formula: `ContextBudget` and the `retainedUserMessageBudget` doc comment now live in `context-budget.ts`, so they stay out of `runtime.ts`, and `narrowToolResultsUnderPressure` sits beside the import. Standalone shape: the gate is the fixed `TOOL_RESULT_TIER_PRESSURE` share of the hard limit. The per-model configurable threshold is in vastsa#721, which contains this change. C:\Users\10470\.pi-desktop\scratch\cb9e2d41-8a55-4a18-899d-92ca2791ab51\commit-705-r2.txt
5204115 to
daf9d33
Compare
|
Rebased onto Two conflicts, both append-vs-append, both resolved by keeping both sides:
Local gates on the rebased head:
On the shape: this is still a superset of #688 / #700 / #705, and all three are rebased and green as well — take whichever unit you prefer. |
…under pressure Rebased onto main (79cd7ae). One conflict, from vastsa#733 extracting the budget formula: `ContextBudget` and the `retainedUserMessageBudget` doc comment now live in `context-budget.ts`, so they stay out of `runtime.ts`, and `narrowToolResultsUnderPressure` sits beside the import. Standalone shape: the gate is the fixed `TOOL_RESULT_TIER_PRESSURE` share of the hard limit. The per-model configurable threshold is in vastsa#721, which contains this change. C:\Users\10470\.pi-desktop\scratch\cb9e2d41-8a55-4a18-899d-92ca2791ab51\commit-705-r2.txt
daf9d33 to
8f0f2c2
Compare
|
Rebased onto It applied cleanly, including the Local gates on the rebased head: One thing to know when reading the JS job: |
…under pressure Rebased onto main (79cd7ae). One conflict, from vastsa#733 extracting the budget formula: `ContextBudget` and the `retainedUserMessageBudget` doc comment now live in `context-budget.ts`, so they stay out of `runtime.ts`, and `narrowToolResultsUnderPressure` sits beside the import. Standalone shape: the gate is the fixed `TOOL_RESULT_TIER_PRESSURE` share of the hard limit. The per-model configurable threshold is in vastsa#721, which contains this change. C:\Users\10470\.pi-desktop\scratch\cb9e2d41-8a55-4a18-899d-92ca2791ab51\commit-705-r2.txt
…r-model context settings One change for the context/compaction line, rebased onto current main. - recall: `recall` and `recall_project` (plus `RECALL_POINTER`, the two tools in the core tool set), over byte-exact transcript reads in host-core (`recall_transcript`, `read_message_text`, `search_project_messages`, `read_project_messages`) and five RPCs (`session.recall`, `session.readMessage`, `search.query`, `session.readProject`, `session.appendSleep`). A compacted-away message stays readable verbatim, so the boundary is reversible rather than final. - reversible boundary: the checkpoint carries a session ledger and the runtime projects it into the session context, so the model can ask for what it lost instead of being told it is gone. - one tier of budget reminder (ADR 0300): the sharper second reminder claimed unsummarized detail "will not be available afterwards", which recall made false; it is removed rather than rephrased, and the rollover/fallback wording is neutral. - deterministic failed-compaction recovery: a degraded checkpoint describes its own range and restores a non-empty context without a model call. - post-compaction occupancy: `CompactionRecord.tokensAfter` (optional, old records read as absent) plus the ring and title that lead with what the compaction just freed until the next real request reports usage. - tool-result tiering: old tool results are narrowed only once the outgoing view is under pressure, with the full text kept reachable through the pointer the pass embeds. - per-model settings: `dynamicContext` / `earlyCompaction` / `sleepTime` on `ModelBinding`, persisted with the binding, carried on the launch payload, surfaced in the settings pane, and translated in all eight catalogs. The gate is the single source of the threshold, so the outgoing request, the hard boundary and the idle pass all read the same number (ADR 0301). - silent early compaction: armed when a run settles, stood down by any new prompt, and `compaction_end` carries `idle`/`silent`; only the toast channel is silenced - the transcript row, the inspector and recall all remain. - sleep-time digest: a deterministic digest taken before the summary attempt (`session.appendSleep`), so a digest exists even when the attempt never returns. Rebased onto 6f24ff2 (main) for the PR-base gate. The comment-level fixes that cited a private ADR numbering are folded into this commit, so every comment now cites ADR 0300/0301; the specification, ADR and E2E text follows in the next commit. The merge was clean: main's new work in `runtime.ts` (custom SYSTEM.md, the retry-budget reset, delegate budgeting) sits in different regions.
…ettings ADR 0300 and ADR 0301, the specification text they amend, the decisions-log entries for the changed defaults, and the E2E scenarios with their traceability rows - in both maintained locales. - `03-runtime/02-agent-runtime.md` §5.1: the boundary is reversible (recall, the ledger, one reminder tier), the idle pass, and the configurable pressure gate with tool-result tiering. - `03-runtime/16-tool-result-limits.md` §6a: the pressure gate and tiering, plus its acceptance line. - `03-runtime/06-host-rpc-protocol.md` §4 Sessions: the five methods (`session.recall`, `session.readMessage`, `search.query`, `session.readProject`, `session.appendSleep`). `03-runtime/01-ipc-protocol.md`: `compaction_end.idle`/`silent` and `mark.tokensAfter`. - `04-ux/06-settings-ia.md`: the three per-binding context controls behind the Advanced disclosure. - `08-meta/decisions-log.md`: D604 (reversible boundary, one reminder tier) and D605 (per-model pressure settings). - `06-delivery/04-e2e-test-plan.md`: E2E-CONTEXT-recall-reads-a-compacted-away-message, E2E-CONTEXT-idle-compaction-is-silent-and-yields, E2E-CONTEXT-tool-results-tier-under-pressure and E2E-SETTINGS-per-model-context-thresholds, with their matrix rows. Rebased onto f6dd5e2 (main) for the new PR-base gate; the only conflicts were append-vs-append in the E2E plan, resolved by keeping both scenarios. C:\Users\10470\.pi-desktop\scratch\cb9e2d41-8a55-4a18-899d-92ca2791ab51\commit-721-docs-r2.txt
8f0f2c2 to
ada8938
Compare
|
Correction to my previous comment on this PR. I wrote that pristine What actually happened: my local After rebuilding
The two real baseline failures are:
So This head Apologies for the noise — and for stating a baseline I had not verified. The CI panel on this head is the authoritative record, and it is green. |
The context/compaction line as one change, rebased onto
mainand gated locally before it was pushed.This is a superset of the three smaller PRs I opened for the same work — #688 (deterministic failed-compaction recovery), #700 (post-compaction occupancy), #705 (tool-result tiering). Take whichever shape you prefer: the small ones are still accurate and I will keep them updated, or take this one and I close them on request.
The two commits
feat(agent-runtime): recall, a reversible compaction boundary, and per-model context settingsdocs(adr): record the reversible boundary and the per-model context settings(The first revision's red CI was my publisher's fault, not the change's: it uploaded a hand-maintained file list that was missing six files of the occupancy work, so the branch contained a
runtime.tsstampingcheckpoint.tokensAfteragainst aContextCompactionRecordwith no such field. The file set is now derived mechanically from the diff, and the Rust job'scargo fmtfailure is fixed.)Specification, ADRs and E2E
recall/recall_projecttools, the host read path, the ledger, one reminder tier, deterministic degraded recovery.dynamicContext,earlyCompaction,sleepTime), the single gate, tool-result tiering, the silent idle pass and the sleep digest.docs/spec/03-runtime/02-agent-runtime.md§5.1 ·03-runtime/16-tool-result-limits.md§6a ·03-runtime/06-host-rpc-protocol.md§4 Sessions (five methods) ·03-runtime/01-ipc-protocol.md(compaction_end.idle/silent,mark.tokensAfter) ·04-ux/06-settings-ia.md§2 Model configuration ·08-meta/decisions-log.mdD604/D605 · all mirrored todocs/zh-CN/….06-delivery/04-e2e-test-plan.md:E2E-CONTEXT-recall-reads-a-compacted-away-message,E2E-CONTEXT-idle-compaction-is-silent-and-yields,E2E-CONTEXT-tool-results-tier-under-pressure,E2E-SETTINGS-per-model-context-thresholds, each with its traceability row and an honest status line.Verification (local, the same steps CI runs)
Re-run on the rebased head
ada89381, with@pi-desktop/sharedrebuilt first.JS job —
pnpm --filter @pi-desktop/agent-runtime typecheckexit 0;pnpm -r --if-present test:native-pi-session(pre-existing: the same test fails on pristinemain)context-compaction, 9/9latest-turn-contextRust job —
cargo fmt --all --check0;cargo test -p host-core --locked→587 passed, 4 failed, and those four (
mcp_servers,user_skills,scheduled_rpc,scheduled_tools) are the Windows path-separator assertions infiles this change never touches. Seven new Rust tests are added, all passing
(recall ranking, non-ASCII folding, character paging,
sleepappend + layout,project search scoping, project read isolation, a pre-
tokensAftercheckpointstill loading).
Docs —
pnpm docs:check(79 EN/zh pairs, 501 pages) exit 0.E2E: partial.
pnpm test:e2e(scripts/e2e-smoke.mjs, the headless protocol suite) — 23/23 passed, 2 skipped (the skips needPI_DESKTOP_TEST_API_KEY), run against the host binary built from this branch, so the host surface it covers (RPC, tools, sessions, plugins) is exercised. The four scenarios below are not driven end to end: they need a built candidate plus an Electron profile with a deterministic boundary/summary fixture, and no suite implements them yet. Alternative validation: the runtime's timer, budget and source-contract seams are covered by unit tests, the host read paths by host-core tests, and both the context inspector and the settings pane by desktop contract tests (all green above). Remaining risk: a real checkpoint boundary followed by a model-issuedrecall, and the idle-pass timing against a live renderer, have not been observed running.Where to start reading
crates/host-core/src/transcripts.rs— the recall read path, plus its tests.packages/agent-runtime/src/recall-tools.ts— the two tools and the pointer text.packages/agent-runtime/src/runtime.ts— the gate, the idle pass, the ledger projection (mostly additive).docs/adr/0300-*.md/0301-*.md— the two decisions, if the shape of the change matters more than the diff.packages/shared/src/types/models.ts+ModelSelectionPanes.tsx— the settings, which are the only user-visible surface.Open questions
collectDumpPathsswallowingEACCES, the non-atomic marker write, shared dumps dir across profiles) are still open — happy to take them as a separate PR if useful.Base and head
base 206085c07· headada89381· 48 files, +5820 / −95. Rebased onto currentmain(82 commitsfurther on); it applied cleanly except for one same-point insertion in
ModelSelectionPanes.tsxon the branches that touch it, where both sides werekept. The published tree is verified to be the same object the gates ran on: