Skip to content

fix: persist rotated compression transcripts - #57508

Closed
rayjun wants to merge 1 commit into
NousResearch:mainfrom
rayjun:fix/compression-rotation-persisted-marker
Closed

fix: persist rotated compression transcripts#57508
rayjun wants to merge 1 commit into
NousResearch:mainfrom
rayjun:fix/compression-rotation-persisted-marker

Conversation

@rayjun

@rayjun rayjun commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a rotated-compression persistence gap introduced by the intrinsic _db_persisted marker. When compression rotates into a child session, protected head/tail messages are shallow-copied into the compressed transcript. If those source dictionaries were already persisted in the parent session, the copied _db_persisted marker makes the child-session flush skip them, so the rotated transcript can lose live context.

This strips persistence-only markers from messages copied into a newly compressed transcript, while leaving in-place compaction semantics unchanged.

Related Issue

Fixes #57491

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • agent/context_compressor.py
    • Add a compression-copy helper that removes session-store persistence markers from copied transcript messages.
    • Use the helper when copying protected head and tail messages into a rotated compressed transcript.
  • tests/run_agent/test_compression_persistence.py
    • Add a regression test covering already-persisted parent messages copied into a rotated child transcript.
    • Verify the compressed child transcript is flushable and includes the summary row.

How to Test

  1. Run python -m pytest tests/run_agent/test_compression_persistence.py tests/agent/test_codex_app_server_persist.py -q
  2. Run python -m pytest tests/agent/test_context_compressor.py tests/agent/test_context_compressor_session_end_clears_state.py tests/agent/test_context_compressor_temporal_anchoring.py tests/agent/test_context_compressor_summary_continuity.py tests/agent/test_context_compressor_cross_session_guard.py tests/run_agent/test_compression_persistence.py -q
  3. Confirm rotated compression copies no longer carry _db_persisted into the child session and the child session receives the compressed transcript rows.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Ubuntu 24.04

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A

Screenshots / Logs

$ python -m pytest tests/run_agent/test_compression_persistence.py tests/agent/test_codex_app_server_persist.py -q
.............                                                            [100%]
13 passed in 4.18s
$ python -m pytest tests/agent/test_context_compressor.py tests/agent/test_context_compressor_session_end_clears_state.py tests/agent/test_context_compressor_temporal_anchoring.py tests/agent/test_context_compressor_summary_continuity.py tests/agent/test_context_compressor_cross_session_guard.py tests/run_agent/test_compression_persistence.py -q
........................................................................ [ 43%]
........................................................................ [ 86%]
.......................                                                  [100%]
167 passed in 7.40s

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P1 High — major feature broken, no workaround labels Jul 3, 2026
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Fixed on main via #57574 (commits 3e204bd, e1a1dac).

Your PR and #57531 were independent fixes for the same root cause (shallow .copy() propagating _db_persisted into the rotated child transcript). #57574 landed the fix with a structural terminal-sweep guard on top. Credit to you and @nankingjing for the parallel diagnosis.

Closing as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rotation compression: _db_persisted marker copied via messages[i].copy() skips bulk flush to child session (cached gateway regression since #50372)

3 participants