fix(agent): inherit parent session cwd during compression rotation - #42240
fix(agent): inherit parent session cwd during compression rotation#42240liuhao1024 wants to merge 1 commit into
Conversation
When a session with an explicit workspace (cwd) is compressed, the continuation session was created without passing cwd. This caused list_sessions_rich() tip projection to surface cwd=null, moving the conversation into the "No workspace" group in Desktop/TUI. Fix: read the old session's cwd before ending it and pass it to the continuation create_session() call. Fixes NousResearch#42228
|
Independent confirmation from a Windows Desktop profile, with private row data redacted. I re-ran the read-only I am intentionally not posting real session ids, workspace paths, titles, prompts, screenshots, or local DB paths. The relevant data shape was: That matches this PR's root cause exactly: The One follow-up edge case worth covering before merge: existing user DBs can already contain old continuation rows with If the intended scope is only future rows, it may be worth documenting that existing affected rows need a separate repair. Otherwise, adding a root-cwd fallback in the projection path would make the fix immediately correct for already-affected Desktop profiles too. |
|
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 ( |
Local carry of upstream PR NousResearch#42240 for issue NousResearch#42228 so Desktop/TUI sessions keep their workspace after compression rotation.
What does this PR do?
Inherits the parent session's
cwd(workspace path) into the continuation session created during context compression. Previously, the continuation was created withoutcwd, causinglist_sessions_rich()tip projection to surfacecwd=null— moving the conversation into the "No workspace" group in Desktop/TUI.Related Issue
Fixes #42228
Type of Change
Changes Made
agent/conversation_compression.py: Read the old session'scwdviaget_session()before ending it, and passcwd=old_cwdto the continuationcreate_session()calltests/agent/test_compression_cwd_inheritance.py: 3 regression tests — continuation inherits cwd, null cwd stays null, tip projection preserves cwdHow to Test
/Users/test/project)pytest tests/agent/test_compression_cwd_inheritance.py -v— all 3 tests should passChecklist
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/ACode Intelligence
agent/conversation_compression.py(compress_context → create_session call chain)