Skip to content

fix(agent): migrate goal state across compression session rotation - #34035

Closed
sharziki wants to merge 1 commit into
NousResearch:mainfrom
sharziki:fix/33618-goal-lost-after-compression
Closed

fix(agent): migrate goal state across compression session rotation#34035
sharziki wants to merge 1 commit into
NousResearch:mainfrom
sharziki:fix/33618-goal-lost-after-compression

Conversation

@sharziki

Copy link
Copy Markdown
Contributor

Summary

  • Goal state is stored in state_meta under goal:<session_id>; when context compression rotates the session_id, GoalManager for the new id finds no goal — the user's /goal silently disappears
  • Copy the active goal to the continuation session's key during compression, following the same pattern used for session titles, system prompts, context engine hooks, and memory manager hooks
  • Defensive: wrapped in try/except, logs on failure, no-op if no active goal

Test plan

  • New test test_goal_migrates_across_session_rotation in tests/hermes_cli/test_goals.py
  • All 51 goal tests pass

Closes #33618

🤖 Generated with Claude Code

Goal state is stored in state_meta under `goal:<session_id>`.  When
context compression rotates the session_id to create a continuation
session, GoalManager for the new id finds no goal — the user's /goal
silently disappears.

Copy the active goal to the continuation session's key during
compression, following the same pattern used for session titles,
system prompts, context engine hooks, and memory manager hooks.

Closes NousResearch#33618

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@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 labels May 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #33890, #33620, #29955, #18749, and #18427 — all fix #33618 (goal lost after compression session rotation). Prior fix #23530 was merged then reverted in #23813. Maintainer should pick one.

@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 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