Conversation
Context compression ends the active session and forks a child session (new session_id, linked via parent_session_id); /resume then redirects to that child. The goal/objective is keyed `goal:<session_id>` in state_meta and GoalManager does a flat lookup with no lineage fallback, so the objective read None on the child session after a long/compressed turn (and on resume). Add `migrate_goal(old, new)` and call it at the rotation boundary in compress_context. Copy (not move), never overwrites an existing child goal, never raises -- a migration failure can't abort the compression split. Flat GoalManager lookup and resume semantics are unchanged. Tests: goal survives rotation + resume redirect, no-overwrite and no-source no-op invariants, and a focused test that compress_context actually calls migrate_goal during rotation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for this — the diagnosis and fix are correct for the rotation path. Context on why we're closing it: as of #52658 (#38763), Rotation now only runs as an explicit opt-out ( |
Context compression ends the active session and forks a child session (new session_id, linked via parent_session_id); /resume then redirects to that child. The goal/objective is keyed goal:<session_id> in state_meta and GoalManager does a flat lookup with no lineage fallback, so the objective read None on the child session after a long/compressed turn (and on resume).
Add migrate_goal(old, new) and call it at the rotation boundary in compress_context. Copy (not move), never overwrites an existing child goal, never raises — a migration failure can't abort the compression split. Flat GoalManager lookup and resume semantics are unchanged.
Tests: goal survives rotation + resume redirect, no-overwrite and no-source no-op invariants, and a focused test that compress_context actually calls migrate_goal during rotation.
Related to #15000: that issue covers compression-created child session chains for message history; this handles another session-scoped state affected by the same rotation.
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
Local platform: Debian GNU/Linux on x86_64, Python 3.11.15.
Documentation & Housekeeping