fix(context-engine): honor assembled prompt authority in precheck#74247
fix(context-engine): honor assembled prompt authority in precheck#74247100yenadmin wants to merge 1 commit intoopenclaw:mainfrom
Conversation
|
Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
Greptile SummaryThis PR fixes a precheck false-positive where the embedded runner was checking the raw pre-assembly transcript against the context budget, causing LCM/windowing engines to appear broken even when their assembled prompt fit the model. The fix makes assembled context the default authority for overflow prechecks and gates the old raw-history behaviour behind an explicit Confidence Score: 5/5This PR is safe to merge; the change is narrowly scoped, additive to the public type, and fully covered by new regression tests. No P0/P1 issues found. The fix correctly initialises contextEnginePromptAuthority to assembled, updates it only on a successful assemble call, and the fallback path (assemble throws) stays safe because the default keeps the assembled-messages path. Both new test cases demonstrate the exact fixed and opt-in shapes. No files require special attention. Reviews (1): Last reviewed commit: "fix(context-engine): honor assembled pro..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR fixes a mismatch between context-engine “assembled” prompts and the embedded runner’s overflow precheck logic: the precheck now treats the assembled messages as the default authoritative prompt for overflow detection, preventing false hard-failures when a context engine windows/compacts history but the raw pre-assembly transcript is large.
Changes:
- Added
AssembleResult.promptAuthority?: "assembled" | "preassembly_may_overflow"(defaulting effectively to"assembled"). - Updated the embedded attempt precheck to only consider pre-assembly (unwindowed) messages when the context engine explicitly opts into that authority.
- Added regression tests covering both the default (“assembled proceeds”) and opt-in (“preassembly overflow fails early”) behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/context-engine/types.ts |
Extends AssembleResult with an optional promptAuthority contract for precheck behavior. |
src/agents/pi-embedded-runner/run/attempt.ts |
Makes assembled messages the default prompt authority for overflow prechecks; gates use of unwindowed messages behind the opt-in authority. |
src/agents/pi-embedded-runner/run/preemptive-compaction.test.ts |
Updates test description to reflect the “explicitly provided unwindowed messages” behavior. |
src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts |
Adds attempt-level regressions validating default assembled authority and explicit preassembly overflow authority. |
|
Branch update note: the fork branch |
|
Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
Summary
Fixes #74233.
Context-engine assembly is documented as returning the ordered messages ready for the model, but the embedded runner still let the preemptive overflow gate hard-fail on the larger pre-assembly transcript. That made LCM/windowing engines look broken even when their assembled prompt fit the model.
This PR makes assembled context the default prompt authority and keeps the older max-of-assembled-and-unwindowed behavior only for engines that explicitly opt in with
promptAuthority: "preassembly_may_overflow".Changes
AssembleResult.promptAuthority?: "assembled" | "preassembly_may_overflow", defaulting to"assembled".Validation
node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/pi-embedded-runner/run/preemptive-compaction.test.ts src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.tspnpm build:plugin-sdk:strict-smokeNotes
This is the production-side fix for the context blow-up path. LCM-side follow-ups add cache-policy hardening and assembly provenance so future incidents can be diagnosed from host-visible metadata instead of logs only.
Refs Martian-Engineering/lossless-claw#534.