Compaction level 2 summarizes every old turn at once, leaving 10–24% of the budget at 96K

オープン
#394 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust

調査の方向性

Start with level2_summarize_old_turns and compact_messages in src/context.rs, then read docs/evals/compaction-defaults.md and run the compaction_sweep example to establish the baseline. Compare the 96K and 26K rows against the acceptance criteria, and add coverage for partial summaries and byte-for-byte stability before deciding whether the measured tradeoffs meet the target.

索引モデルが issue の本文から書いたものです。

説明

Summary

At the default budget (96K effective), a compaction leaves far less history than its own target asks for. Level 2 summarizes every turn older than keep_recent in one pass, whatever the target, so the context drops to 10–24% of the budget while the target sits at 30–70%. The model loses the detail of all older turns at once, with most of the budget unused.

Follow-up to #150 (closed by #393, which fixed the small-budget cliff in level 3). Noted in docs/evals/compaction-defaults.md: "level 2's all-or-nothing summarization is the remaining cliff at 96K."

Numbers

cargo run --release --example compaction_sweep (drives the real compact_messages; floor 0.30, compact_headroom_turns: Some(30), keep_recent: 10, 5 seeds × 240 requests), at 96K:

profile growth/turn effective target left after a compaction (mean / min) compactions /100
chat ~0.7K 0.70 (cap) 24.1% / 22.8% 0.4
records (#150's shape) ~1.6K ~0.50 10.5% / 9.3% 1.7
coding ~3.4K 0.30 (floor) 19.7% / 9.9% 3.8
mixed varies — 23.9% / 7.4% 2.3

The effective target is ContextConfig::effective_target_ratio: (budget − 30 × growth) / budget, capped at compact_target_ratio (0.7) and floored at MIN_HEADROOM_RATIO (0.30). For records it asks to keep ~48K and level 2 leaves ~10K. Level 3 never runs: level 2 already lands under the target.

Why

level2_summarize_old_turns(messages, keep_recent) (src/context.rs) replaces every assistant message before the keep_recent boundary with a [Summary] … one-liner and drops its tool results. The target isn't an input. compact_messages checks the target only afterwards (if total_tokens(&compacted) <= target).

Proposed

Summarize the oldest turns only until the history fits the target, the way level 3 drops the smallest span that reaches it. Turns between that point and the keep_recent boundary stay in full detail.

Things to settle with the sweep before changing it:

  • Retention vs compaction count. Keeping more after a compaction means reaching the budget sooner. records @ 96K should move from ~10% toward ~50% kept; measure how much cmp/100 and the ideal hit rate move.
  • Prefix-cache stability. Today a second pass re-summarizes from the same boundary. A partial summary moves the boundary each pass, so check the bytes before it stay put. Summaries are deterministic and inherit the turn's timestamp, so this should hold, but it needs a test like a_second_compaction_keeps_the_front_byte_for_byte.
  • Small budgets. At 26K, level 3 (with #393) already handles the protected set. Confirm the 26K rows don't regress.

Acceptance

  • The sweep's 96K rows: post-compaction size close to the effective target, the compaction count not materially higher, the hit rate not lower.
  • The 26K rows unchanged or better on head- / ask- / mkr.
  • compaction_is_well_formed_within_budget_and_keeps_what_fits still passes, plus a level-2 test that a partial summary keeps the turns after its cut in full.
主要言語
Rust
スター
327
フォーク
46
平均マージ
2時間 36分
マージ済み PR(30日)
107

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

yologdev/yoagent のほかの issue

yologdev/yoagent の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。