fix(tui_gateway): bind the session cwd around manual /compress
session.compress runs compress_now on the RPC thread without the session context, so the compaction-boundary system-prompt rebuild resolved the backend's cwd (the process HOME) and persisted a prompt whose cwd line every later process rejects as stale runtime. The next resume (TUI or 'hermes chat --resume') then rebuilt the prompt from scratch - a second prompt-cache miss right after the sanctioned compaction one - and, on the oneshot path, skipped the tools pin. Bind the session cwd exactly like the sibling prompt-persist sites (server.py _persist_live_session_system_prompt, methods_slash.py). Exposed by tests/e2e/core/history/test_prefix_stability.py[tui_gateway_restarts].
This commit is contained in:
@@ -242,7 +242,13 @@ def _compress_session_history(
|
||||
request = parse_compress_args(focus_topic or "")
|
||||
if request.aggressive:
|
||||
raise ValueError(AGGRESSIVE_UNSUPPORTED)
|
||||
result = compress_now(agent, before_messages, request, task_id=session.get("session_key") or "default")
|
||||
# RPC thread: bind the session cwd, or the boundary prompt rebuild resolves the backend's cwd and
|
||||
# persists a prompt every other process then rejects as stale runtime (fresh build, no tools pin).
|
||||
tokens = _set_session_context(session.get("session_key") or "", cwd=_session_cwd(session))
|
||||
try:
|
||||
result = compress_now(agent, before_messages, request, task_id=session.get("session_key") or "default")
|
||||
finally:
|
||||
_clear_session_context(tokens)
|
||||
if result.status == "preview":
|
||||
return 0, _get_usage(agent)
|
||||
# Lock-skipped: raise so callers surface a clear message instead of "No changes from compression".
|
||||
|
||||
Reference in New Issue
Block a user