Skip to content

fix(agent): calibrate compaction from measured input - #6623

Merged
M4n5ter merged 3 commits into
rust-previewfrom
fix/measured-compaction
Nov 4, 2026
Merged

M4n5ter merged 3 commits into
rust-previewfrom
fix/measured-compaction

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 4, 2026

Copy link
Copy Markdown
Member

Summary

Main could block for compaction while provider-reported usage was still below the configured threshold: a separate full-history estimate was being compared against the summary input budget. A ready background summary was also adopted immediately, regardless of current pressure.

  • Calibrate the current complete request estimate against the latest matching Main request's measured input. Estimate only the change, including new messages, results and tool schemas; do not add cached or reasoning tokens twice. Reuse existing request metadata without adding persistent state or a database migration.
  • Start background preparation at 85% of the resolved adoption threshold. Keep Main running and hold completed candidates until the adoption threshold or a confirmed provider overflow. Summary input fitting no longer decides when Main must wait.
  • Use the same calibration for Main output capacity, frozen retries, prediction and continuation replay. Remove the separate 8,000-token heuristic reserve.
  • Adapt OpenCode V2's overflow phrases, exclusions and nested provider-code recognition across adapter families. Recognize raw/nested evidence and empty 400/413 responses, while retaining throttling and invalid output parameters as their own failures. Remove the 64 KiB error-body parsing cutoff. Preserve upstream attribution and MIT licensing.

For a 500k window with a 425k adoption threshold, background preparation begins around 361k; it does not force adoption there or when the summary finishes.

Verification

  • Relevant engine, event-log and model unit/integration suites through nextest: 606 passed, 3 skipped by existing configuration. Final lifecycle-fixture adjustments were also rerun separately: 3 passed.
  • Strict Clippy for all targets of these three crates.
  • Rust formatting, the changed JavaScript's formatting, source headers and dependency licenses.
  • Source-header policy tests: 4 passed.

Behavior coverage includes continuing with a measured prefix despite an over-window raw estimate, holding ready candidates below the threshold, preserving newer steering/tool results through adoption, frozen physical retry identity, handoff/restart, and provider overflow versus throttling/parameter failures. Existing lifecycle fixtures now use realistic usage and threshold ranges instead of relying on the previous trigger algorithm.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex implemented and reviewed the change and its behavioral tests. OpenCode V2 source provenance is recorded in docs/code-origin-audit.md and LICENSE.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Reap failed speculative compaction candidates so renewed budgets and output pruning are not blocked, align provider overflow classification with Maka's typed HTTP/SSE/image/quota/rate-limit diagnostics, and validate persisted context_breakdown on read.

Generated-by: Antigravity
…ry tool retry

- Rewrite compaction prompts and checkpoint handoff prefixes across en, zh-CN, and zh-TW for agent-oriented recovery without re-reading settled work.
- Narrow Recall and RecallMore active-turn exclusion to uncompacted tail events (source_sequence > covered_through) so MidTurn checkpoints unlock earlier compacted messages of the active turn.
- Index and project ToolCall names and unescaped arguments in Recall, remove the redundant SQLite JSON roundtrip, and rank multi-term matches by distinct matched term count with sublinear length normalization.
- Prepend a compact ranked anchor directory on multi-hit Recall results and expose optional before/after context windows on the Recall model tool.
- Retry non-native summary generation once with protocol-level tool_choice=none when a provider emits tool calls under advertised tools.

Generated-by: Antigravity
@M4n5ter
M4n5ter force-pushed the fix/measured-compaction branch from 6be24c6 to 86d78ec Compare November 4, 2026 12:53
@M4n5ter
M4n5ter merged commit 89e7dcd into rust-preview Nov 4, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the fix/measured-compaction branch November 4, 2026 12:54
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.

1 participant