fix(cli, gateway): migrate /goal across all session_id rebind sites#18749
Open
Tranquil-Flow wants to merge 2 commits into
Open
fix(cli, gateway): migrate /goal across all session_id rebind sites#18749Tranquil-Flow wants to merge 2 commits into
Tranquil-Flow wants to merge 2 commits into
Conversation
Collaborator
Collaborator
|
Related to #18427. |
2 tasks
When auto- or manual context compression mints a child session_id on the agent, every site that syncs a stored session_id to the agent's new id must also migrate the goal row stored in SessionDB.state_meta under goal:<sid>. Otherwise the judge loop silently dies under the orphaned parent and /goal status reports "No active goal" with no warning. Five sites carried this rebind pattern; only the manual-/compress one was wired in the first attempt: cli.py:7577 manual /compress cli.py:9408 auto-compression mid-turn (run_conversation) cli.py:12016 single-query / non-interactive run mode gateway/run.py:6165 gateway post-run session_entry sync gateway/run.py:12742 gateway session split on compression Wire migrate_goal at all five. Gateway sites use a defensive try/except around the helper since gateway logging deliberately swallows non-fatal errors. Add a regression test under tests/cli/test_manual_compress.py that plants a goal, runs _manual_compress, and asserts the goal carried to the child session. Fixes NousResearch#18467
63ac186 to
4a5f693
Compare
This was referenced May 28, 2026
19 tasks
This was referenced Jun 12, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Carries an in-flight
/goalacross every session_id rebind so the goal judge loop doesn't silently die after compression. The goal row is keyed bygoal:<session_id>inSessionDB.state_meta; when_compress_context()mints a childsession_idon the agent, every site that syncs a stored session_id to the agent's new id must also migrate that row, otherwise/goal statusreports "No active goal" with no warning.The reporter localised one site exactly (
cli.py:7567-7572, manual/compress). Code review surfaced four more sites with the same rebind pattern that all need the same treatment:cli.py:7577/compresscli.py:9408run_conversation)cli.py:12016gateway/run.py:6165session_entry.session_idsyncgateway/run.py:12742This PR adds
migrate_goal(old_sid, new_sid)inhermes_cli/goals.pyand wires it at all five sites. Migration semantics:turns_used,last_verdict,paused_reasonintact).done,cleared) stay with the original session — they belong to the session that completed them.clear_goal()helper so/goal statusunder the dead session reflects reality.Gateway sites wrap the call in a defensive
try/exceptsince gateway logging deliberately swallows non-fatal errors.Related Issue
Fixes #18467
Type of Change
Changes Made
hermes_cli/goals.py— addmigrate_goal(old_session_id, new_session_id)cli.py— wiremigrate_goalat the manual/compress, auto-compression, and single-query rebind sitesgateway/run.py— wiremigrate_goalat the post-run sync and session-split sites (withtry/exceptfor non-fatal failure)tests/hermes_cli/test_goals.py— addTestMigrateGoal(7 unit cases: active carry, status preservation, old-cleared, done/cleared not migrated, paused state, no-goal noop, empty-sid noop)tests/cli/test_manual_compress.py— addtest_manual_compress_migrates_active_goal_to_child_sessionintegration test that plants a goal, runs_manual_compressend-to-end, and asserts migrationHow to Test
python -m pytest tests/hermes_cli/test_goals.py tests/cli/test_manual_compress.py -q— 38/38 passhermes→/goal port the thing→ a few turns →/compress→/goal statusshould show the goal still active under the new session id (previously: "No active goal")Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs