Skip to content

fix(agent): focus automatic compression on recent user turns (salvages #38155)#44687

Merged
teknium1 merged 2 commits into
mainfrom
fix/compression-auto-focus-topic
Jun 12, 2026
Merged

fix(agent): focus automatic compression on recent user turns (salvages #38155)#44687
teknium1 merged 2 commits into
mainfrom
fix/compression-auto-focus-topic

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Automatic compaction now derives a focus topic from the last 3 real user turns, so iterative summaries stop keeping completed topics alive and overriding the active one.

Root cause (#9631): the iterative-update prompt says "PRESERVE all existing information", so dead topics accrete across compactions with no recency weighting — only manual /compress <topic> ever set a focus; automatic compaction passed focus_topic=None.

Closes #9631.

Changes

  • agent/context_compressor.py: _derive_auto_focus_topic() — last ≤3 real user turns (skips persisted handoff summaries), redacted, 260 chars/turn, 700 chars total; used by compress() whenever no explicit focus is given — from fix(agent): focus automatic compression on recent user turns #38155 by @konsisumer
  • agent/context_compressor.py: focus-prompt wording no longer claims "the user has requested" when the focus is auto-derived
  • Follow-up: dropped the reserved-but-unused tail_start parameter (YAGNI)

Validation

Before After
Auto compaction focus none — all topics weighted equally, completed topics accrete last 3 real user turns get 60-70% of summary budget
Handoff summaries in transcript could be picked as "user focus" skipped via _is_context_summary_content
pytest test_compress_focus.py + compressor suites 107 passed

Attribution

Salvages #38155 by @konsisumer — cherry-picked with authorship preserved; rebase-merge to keep per-commit credit. Rebased onto the #44454 prompt consolidation.

Infographic

compression-auto-focus-topic

konsisumer and others added 2 commits June 11, 2026 22:39
…_topic

The parameter was reserved-but-unused (del'd immediately); YAGNI. Test
call site updated.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/compression-auto-focus-topic vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10776 on HEAD, 10772 on base (🆕 +4)

🆕 New issues (4):

Rule Count
unsupported-operator 3
unresolved-attribute 1
First entries
tests/agent/test_compress_focus.py:145: [unresolved-attribute] unresolved-attribute: Attribute `startswith` is not defined on `None` in union `Unknown | None`
tests/agent/test_compress_focus.py:147: [unsupported-operator] unsupported-operator: Operator `in` is not supported between objects of type `Literal["- third"]` and `Unknown | None`
tests/agent/test_compress_focus.py:146: [unsupported-operator] unsupported-operator: Operator `in` is not supported between objects of type `Literal["- second"]` and `Unknown | None`
tests/agent/test_compress_focus.py:148: [unsupported-operator] unsupported-operator: Operator `in` is not supported between objects of type `Literal["- fourth"]` and `Unknown | None`

✅ Fixed issues: none

Unchanged: 5648 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit c7bee8f into main Jun 12, 2026
28 checks passed
@teknium1 teknium1 deleted the fix/compression-auto-focus-topic branch June 12, 2026 06:03
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.

[Bug]: Iterative context compaction summary keeps completed topics alive and overrides the current active topic

2 participants