Skip to content

fix: preserve goals across compression sessions - #38231

Closed
denisqq wants to merge 1 commit into
NousResearch:mainfrom
denisqq:fix/goal-session-migration
Closed

fix: preserve goals across compression sessions#38231
denisqq wants to merge 1 commit into
NousResearch:mainfrom
denisqq:fix/goal-session-migration

Conversation

@denisqq

@denisqq denisqq commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve persistent /goal state when compression rotates agent.session_id into a continuation session
  • add fail-soft goal migration helper that copies only unfinished goals and archives the source as non-active
  • add lineage recovery for already-created compression children plus regression coverage for direct migration and the real compression boundary

Why

GoalManager stores state in SessionDB.state_meta under goal:<session_id>. Compression creates a new child session id, so the next GoalManager(new_session_id) used to miss the active goal and the judging/continuation loop stopped silently.

Safety

  • no-op for missing, done, cleared, blank, or same-session goals
  • does not overwrite destination active, paused, or done goals
  • migration errors are logged at debug level and never break the main conversation turn
  • source goal is archived as cleared instead of deleting metadata

Tests

  • python3 -m pytest tests/hermes_cli/test_goals.py tests/run_agent/test_compression_boundary_hook.py -q -o 'addopts=' — 60 passed, 1 warning
  • python3 -m pytest tests/run_agent/test_compression_boundary_hook.py tests/run_agent/test_compression_persistence.py tests/run_agent/test_compression_boundary.py tests/gateway/test_compression_session_id_persistence.py tests/agent/test_compression_concurrent_fork.py tests/hermes_cli/test_goals.py -q -o 'addopts=' — 76 passed, 1 warning

Fixes #33618.

@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 comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels Jun 3, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for this — the diagnosis and fix are correct for the rotation path.

Context on why we're closing it: as of #52658 (#38763), compression.in_place now defaults to True. Compaction keeps ONE durable session id for the conversation's whole life — it no longer ends the session and forks a continuation id. Because the id no longer rotates, the active /goal stays attached to the same session automatically — there is no rotation boundary to migrate the goal across.

Rotation now only runs as an explicit opt-out (compression.in_place: false), and the direction is to treat that path as legacy. So this fix hardens a code path that no longer executes by default and that we're not investing further in. Closing as superseded by the in-place default — not a reflection on the code, which was a correct fix for the behavior at the time. Credit preserved in the issue/PR history. Appreciate the contribution.

@teknium1 teknium1 closed this Jun 25, 2026
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 comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persistent /goal is lost after context compression rotates session_id

3 participants