Skip to content

fix(compression): make continuation rotation atomic - #68929

Closed
trac3r00 wants to merge 1 commit into
NousResearch:mainfrom
trac3r00:fix/compression-lineage-atomic
Closed

fix(compression): make continuation rotation atomic#68929
trac3r00 wants to merge 1 commit into
NousResearch:mainfrom
trac3r00:fix/compression-lineage-atomic

Conversation

@trac3r00

Copy link
Copy Markdown
Contributor

[Bob]

Summary

  • close a compression parent and create its continuation child in one BEGIN IMMEDIATE transaction
  • publish the new in-memory session id only after the atomic DB rotation succeeds
  • add a deterministic WAL race regression proving a concurrent reader/pruner can never observe an ended parent without its child

Root cause

Legacy rotation called end_session() and create_session() as separate transactions. Auto-prune could select and delete the newly ended parent between those writes, so the child insert lost its lineage target and the live agent could continue with a session id that was never persisted.

Verification

  • uv run pytest -q tests/agent/test_compression_rotation_state.py tests/agent/test_compression_concurrent_fork.py tests/test_hermes_state.py — 435 passed
  • race regression repeated 40/40 successfully
  • mutation probe against the old split sequence exposed parent_ended=true, child_visible=false, confirming the test distinguishes the regression
  • uv run ruff check agent/conversation_compression.py hermes_state.py tests/agent/test_compression_rotation_state.py — clean
  • independent review — PASS, no blockers

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists 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 duplicate This issue or pull request already exists labels Jul 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #64373. Both patches atomically complete compression parent-to-child rotation; #64373 is the existing broader implementation, including durable lease validation and regression coverage.

@trac3r00

Copy link
Copy Markdown
Contributor Author

Confirmed. #64373 predates this PR and covers the same atomic parent-to-child rotation while also adding durable lease validation and broader concurrency regression coverage. Closing this duplicate in favor of #64373; credit to @yingliang-zhang for the earlier, more complete implementation.

[bob]

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 duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists 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.

2 participants