Skip to content

Fix #42228: Inherit parent session cwd in compressed continuation sessions - #42233

Closed
Morad37 wants to merge 3 commits into
NousResearch:mainfrom
Morad37:fix/42228-compression-inherit-cwd
Closed

Fix #42228: Inherit parent session cwd in compressed continuation sessions#42233
Morad37 wants to merge 3 commits into
NousResearch:mainfrom
Morad37:fix/42228-compression-inherit-cwd

Conversation

@Morad37

@Morad37 Morad37 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

During context compression, the continuation (tip) session row was created
without inheriting the parent session's working directory (cwd). This caused
compressed conversations to appear under "No workspace" in the TUI/desktop
session list, even when the root session had a recorded cwd.

Changes

hermes_state.py — Added get_session_cwd() method to SessionDB,
mirroring the existing get_session_title() pattern, so callers can
retrieve a session's recorded working directory.

agent/conversation_compression.py — In compress_context(), before
the session rotation, look up the old session's cwd from the database
and pass it to create_session() for the new continuation row.

Root Cause

create_session() accepts an optional cwd parameter, and the initial
session creation in run_agent.py does pass it (via
_launch_cwd_for_session). But the compression rotation path in
compress_context never copied the parent's cwd, so every continuation
session had cwd=NULL.

Testing

  • All 8 TestCompressionChainProjection tests pass, including
    test_list_projection_uses_tip_cwd (which validates that a tip with
    a persisted cwd projects correctly onto the lineage row).
  • All 24 test_413_compression tests pass.
  • All 25 test_compression_feasibility + test_compression_persistence
    • test_compression_boundary_hook tests pass.
  • All 16 compression lock + concurrent fork tests pass.
  • No regressions in test_hermes_state or other session tests.

Fixes #42228

Morad37 added 3 commits June 8, 2026 19:06
…inuation sessions

During context compression, the continuation session row was created
without inheriting the parent session's working directory (cwd).
This caused compressed sessions to appear under 'No workspace' in the
TUI/desktop session list when the root session had a recorded cwd.

Changes:
- Add get_session_cwd() method to SessionDB in hermes_state.py
  (mirrors the existing get_session_title() pattern)
- In compress_context() (conversation_compression.py), look up the
  old session's cwd before rotation and pass it to create_session()
  so the continuation row preserves workspace grouping

Fixes NousResearch#42228
…ror from _is_payment_error

Add two new error detection functions:
- _is_server_error(exc): detects HTTP 500-504 status codes and gRPC
  UNAVAILABLE status. These indicate the provider's servers are having
  issues, distinct from client-side problems like billing or auth.
- _is_unavailable_error(exc): detects HTTP 503 (Service Unavailable),
  HTTP 429 with server-overload messaging, and service-unavailable
  language in error text. This covers transient unavailability.

Update should_fallback in both call_llm (sync) and async_call_llm to
include the new error categories alongside the existing _is_payment_error,
_is_connection_error, and _is_rate_limit_error checks.

Update is_capacity_error to include _is_server_error, so server errors
bypass the explicit-provider gate (the server literally cannot serve the
request regardless of user intent).

Previously, 5xx and 'unavailable' errors were lumped into _is_payment_error
or simply not caught, which was semantically wrong - a 503 from a proxy
is not a payment error.

Closes NousResearch#42088
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Jun 8, 2026
@teknium1

Copy link
Copy Markdown
Contributor

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 there is no continuation session, the conversation keeps its original cwd through compaction — there is no null-cwd continuation row to inherit into.

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.

@teknium1 teknium1 closed this Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop/TUI compressed sessions can move into No workspace because continuation cwd is null

3 participants