Skip to content

fix(harness): preserve durable context through compaction - #3798

Merged
Buktal merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/context-compaction
Oct 28, 2026
Merged

Buktal merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/context-compaction

Conversation

@Buktal

@Buktal Buktal commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Refs #3794, review unit 3 of 3. Synthetic messages can be durable conversation records or request-only projections. Treating both as transient moves persisted notifications out of order and keeps them outside compaction. Comparing copied/restored messages by Java object/value types can also prevent a valid summary from being written back.

Summary

canonical history (including persisted synthetic notifications)
  -> ordered conversation -> budget/compact -> guarded summary writeback
request-only projections
  -> current request only
overflow retry
  -> latest canonical history + surviving request projections
system sources
  -> one System message / one TextBlock, joined by blank lines
  • Use canonical membership/IDs to distinguish persisted notifications from transient projections, retaining ordinary history order, budgeting, and compaction behavior.
  • Require complete serialized-history equality before durable writeback. Use the configured JSON codec and a precision-preserving JSON-tree comparison so restored number types match while edited content, metadata, and high-precision decimal values do not.
  • Rebuild overflow retries from current history without reviving compacted-away notifications. Preserve concurrent-history and final-budget rejection guards.
  • Clarify the synthetic marker's lifetime contract and update English/Chinese context documentation.

Evidence

  • Before: with the old history comparison, JSON-restored notification cases failed summary persistence: 3 failures in a 37-test context/compaction regression run.
    After: all 37 passed after the numeric-comparison fix, including protection for distinct 1.0000000000000000001 and 1.0000000000000000002 metadata. ContextPipelineV2Test also covers copied/converted notifications, same-ID edits, single-block system text, final-budget rejection, and concurrent changes; CompactionMiddlewareTest covers overflow reconstruction.
  • Independent branch: mvn -B -T1C clean verify passed across 99 modules: 11,317 tests, 0 failures/errors, 242 skipped. Spotless ran without skip flags. Docs: npm test (13/13) and npm run validate (432 pages, 584 redirects, Mintlify build) passed. npm run broken-links reports 2,218 links across 326 files, the same counts recorded before; individual links were not baseline-attributed.
  • Includes the shared three-line my_skill -> my-skill test-fixture correction needed after fix(skill): block path traversal in skill materialization and disambiguate skillId #3787/fix(skill): move blocking skill reload off reactive event-loop threads #3792. It is also in both sibling PRs so these branches validate independently and can merge in any order.

Merge Danger

Door: two-way

No serialized-state schema change. The existing synthetic marker continues to identify origin; canonical membership determines whether a message is durable.

Blast Radius: context

Changes request layout, compaction eligibility, summary writeback, and overflow retries. Fake-model regressions verify these paths; provider cache behavior and task quality were not benchmarked. #3780's older streaming/backport and custom memory-flush-prompt concerns are separate.

Checklist

  • Spotless formatting check passes as part of full verification
  • All executed tests pass; skipped-test count is reported above
  • Javadoc updated for changed contracts
  • Related English and Chinese documentation updated
  • Code ready for review

@mintlify

mintlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit c220890.

Approve preview

@Buktal
Buktal force-pushed the codex/context-compaction branch from b4e25a0 to c220890 Compare October 27, 2026 14:14
@Buktal
Buktal merged commit e7710e1 into agentscope-ai:main Oct 28, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants