Skip to content

fix(cron): finalize compressed session tips (#67188) - #67221

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/67188-cron-session-tips
Closed

fix(cron): finalize compressed session tips (#67188)#67221
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/67188-cron-session-tips

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Summary

  • resolve a cron run's live compression tip before final title/completion
  • use that resolved session consistently across success, exception, and inactivity-timeout finalization
  • preserve the existing first-reason-wins completion contract and title de-duplication

Context

This adapts the still-valid preventive portion of Colin Greig's earlier carried cron fix (4ba5f6077b90e3b67814b8e50b31a8145178ba7c) to current upstream rather than cherry-picking the old patch.

The historical age/identifier-regex stale-session reconciler from that patch is intentionally not included: age and identifier shape do not prove that a long-running job is orphaned. The follow-up commit 71d8352ee4aaf6007c7ba8376496f0bbdef864a5 is also retired because it only repaired that omitted reconciler.

Previously the cron finalization block always used the original _cron_session_id captured before AIAgent started. When compression rotated the live agent onto a continuation session during the run, title/end_session targeted the stale original instead of the active continuation, losing the compressed session's data and violating the first-reason-wins contract.

Now the finally block queries SessionDB.get_compression_tip() to resolve the live tip and falls back to agent.session_id on lookup failure.

Changes

File Lines Change
cron/scheduler.py +33 / -5 Resolve compression tip before title/end_session; use _final_cron_session_id in all paths
tests/cron/test_scheduler.py +112 / -1 Added 4 tests: compression finalization, title dedup, lookup-failure fallback, timeout coverage
tests/test_hermes_state.py +52 / -0 Added concurrent end_session audit test proving first-reason-wins contract

Validation

  • 28 passed in tests/cron/test_scheduler.py (TestRunJobSessionPersistence)
  • 1 passed in tests/test_hermes_state.py (concurrent end_session test)
  • ruff check passed on all 3 modified files

Closes #67188

Resolve a cron run's live compression tip before final title/completion
and use that resolved session consistently across success, exception,
and inactivity-timeout finalization paths. Preserve the existing
first-reason-wins completion contract and title de-duplication.

Previously the cron finalization block always used the original
_cron_session_id captured before AIAgent started. When compression
rotated the live agent onto a continuation session during the run,
title/end_session targeted the stale original instead of the active
continuation, losing the compressed session's data and violating
the first-reason-wins contract.

Now the finally block queries SessionDB.get_compression_tip() to
resolve the live tip and falls back to agent.session_id on lookup
failure. Added concurrent end_session audit test proving one
transition wins, and parametrized coverage for compression-tip
resolution, title de-duplication, and timeout paths.

Closes NousResearch#67188
@alt-glitch alt-glitch added type/bug Something isn't working comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists 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 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #67188: the production cron finalization diff is byte-equivalent.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for adapting the cron finalization fix to current main. The premise is verified: cron/scheduler.py:3634 and cron/scheduler.py:3659 finalize the original cron session, while legacy compression rotates agent.session_id and creates a continuation in agent/conversation_compression.py:868-902.

Problems

Suggested changes

  • Keep one PR as the salvage source so the same cron finalization change is not reviewed or landed twice.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/sessions Session lifecycle, resume, persistence, history area/compression Context compression and continuation sessions labels Jul 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as a duplicate of #67188, which @colingreig opened ~100 minutes earlier — the two diffs are byte-identical (same sha256), so there is no salvageable delta here. #67188 is the vehicle moving forward.

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

Labels

area/compression Context compression and continuation sessions area/sessions Session lifecycle, resume, persistence, history comp/cron Cron scheduler and job management duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform 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.

3 participants