Repository navigation
fix(harness): align compaction with final input accounting - #3847
Merged
Merged
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
9 tasks
jujn
approved these changes
Oct 29, 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.
AgentScope-Java Version
2.1.0-SNAPSHOT
Description
Compaction can skip oversized media history because it uses a different estimator from final request validation. This change uses the configured
ContextPolicy.estimator()throughout compaction triggering, tail retention, lightweight reductions, and final validation.Refs #3834 — slice 02 of the shared tracking issue. The remaining slices stay open; slice 03 depends on this change.
Summary
TokenCounterUtilretains its public integer API and delegates to the existing default estimator, removing duplicate text/tool/media accounting. Existing public compactor and middleware entry points remain available.Single-result accounting excludes unrelated task projections. Tail selection checks suffixes in order: removing a full Todo receipt can expand the task-state projection, so suffix costs are not necessarily monotonic. English and Chinese context documentation describe these scopes.
The budgeting references are ZCode's effective input window and DeepSeek Harness's full-envelope measurement, which also exposes single-message estimation. The nonmonotonic Todo case is reproduced against AgentScope's own projection implementation.
Evidence
After: The media fixture summarizes once, retains the current message, and fits the limit. The custom-estimator fixture retains the expected tail and finishes at 510 estimated tokens.
readoutput to lose protection; binary tail selection missed a fitting suffix containing that receipt. These regressions produced two failing tests.After: Both Todo display forms preserve the same protected outputs, and the fitting receipt/tail is retained. A custom-cost regression also excludes request/schema overhead from each output.
mvn -B -T1C clean verifysucceeded across 99 modules: 11,350 passed, 243 skipped, zero failures/errors, including Spotless. Skips include disabled integration/E2E suites and unavailable credentials/Docker.npm run validatepassed.npm run broken-linksreports the same 2,222 links in 328 files as before this follow-up; this PR changes no links or anchors.Merge Danger
Door: two-way
No dependency or persisted-state migration. Existing estimator defaults are reused; legacy message-token estimates intentionally change to match final input accounting.
Blast Radius: Harness
Compaction timing and retained history can change for media, custom estimators, and task projections. Sequential suffix checks may require O(n) estimator calls; latency has not been benchmarked. Validation uses local fixtures, with no live provider or sandbox E2E run.
Checklist
mvn spotless:applymvn -B -T1C clean verify; skips noted above)