You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointduplicateThis issue or pull request already existsP2Medium — degraded but workaround existstype/bugSomething isn't working
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.