Skip to content

fix(goals): forward standing /goal state when auto-compression rotates session_id - #48980

Closed
nanami7777777 wants to merge 1 commit into
NousResearch:mainfrom
nanami7777777:fix/goal-forward-on-compression-rotation
Closed

fix(goals): forward standing /goal state when auto-compression rotates session_id#48980
nanami7777777 wants to merge 1 commit into
NousResearch:mainfrom
nanami7777777:fix/goal-forward-on-compression-rotation

Conversation

@nanami7777777

Copy link
Copy Markdown
Contributor

Fixes #48956

When run_agent's _compress_context fires mid-turn it ends the parent session in SessionDB and creates a new continuation session with a fresh session_id. The /goal state is keyed on session_id in state_meta (goal:<sid>), so without forwarding the goal silently disappears: _get_goal_manager() rebinds for the new session_id, load_goal() returns None, mgr.is_active() is False, and the continuation loop dies with no user-visible signal.

Fix: in the same SessionDB transaction block that creates the continuation session, copy state_meta[goal:<old>] -> state_meta[goal:<new>] when present. No-op when the user has no active goal. Logged at INFO so a stuck loop is debuggable.

Originally fixed in #23530 (commit 4a080b1), reverted in #23813. Re-added at the current rotation site in conversation_compression.py.

Tests cover the round-trip via SessionDB and the no-op path.

@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 P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #29955 — both re-add /goal forwarding at the same continuation-session creation block in agent/conversation_compression.py, copying the goal:<old_sid> state_meta entry to goal:<new_sid> so the goal loop survives auto-compression. This PR inlines get_meta/set_meta; #29955 wraps the identical copy in a migrate_goal_session() helper invoked at the same insertion point — same site, same mechanism.

Context: originally fixed in merged #23530, reverted in #23813; the bug is confirmed still live on main (no goal-forward block present after the compression logic moved). This fixes #48956, which is itself a duplicate of the canonical issue #33618. Several competing open fix-PRs exist for the same root cause (#29955, #34035, #38231, #47408 — and #33890 which bundles it). #29955 is the earliest still-open same-mechanism fix.

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Acknowledged: noted competing PR(s) #29955, #29955, #23530, #23813, #48956, #33618, #29955, #34035, #38231, #47408, #33890, #29955. My approach differs and is complementary, not mutually exclusive. Open to consolidating if reviewers prefer one direction.

@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 duplicate This issue or pull request already exists 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.

fix(goals): forward /goal state_meta when auto-compression rotates session_id

4 participants