# NousResearch/hermes-agent · Collapsing terminal sessions into shared containers

## Open now

- Nothing open on GitHub.

These issues and PRs concern a bug where Docker creates separate containers per terminal session, preventing shared auth state, and related fixes or features to collapse sessions with matching CWD or subagent task IDs into a shared container.

## TL;DR

- 3 member(s): 0 open issue(s), 1 closed issue(s), 0 open PR(s), 1 merged PR(s), 1 PR(s) closed without merging.
- A fix was merged to main in PR #41822. Verify it addresses your case.
- **Recommended:** read PR #41822 (and any competing PRs below) before filing. Confirm the merged change covers your symptom.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `resolved` · deciding PR(s): `pr-41822`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_SPANNING`): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
- Pairwise link density `0.67`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Closed / duplicate issues

- #37361: \[Bug\]: terminal.backend: docker creates a separate container per session — auth state cannot be shared across TUI, gateway, and dashboard

## Prior & competing PRs

- **#41822: fix(terminal): collapse CWD-only overrides to shared container**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `tests/tools/test_shared_container_task_id.py`, `tools/terminal_tool.py`
  - fix hunks:
  - `tests/tools/test_shared_container_task_id.py`

    ```diff
    @@ -105,3 +105,49 @@ def test_get_active_env_honours_rl_override():
             terminal_tool.clear_task_env_overrides("rl-42")
             terminal_tool._active_environments.pop("default", None)
             terminal_tool._active_environments.pop("rl-42", None)
    +
    +
    +def test_cwd_only_override_collapses_to_default():
    +    """CWD-only overrides (ACP adapter workspace tracking) must NOT trigger
    +    container isolation — they should collapse to the shared 'default'
    +    container so all surfaces (TUI, gateway, dashboard) share one sandbox.
    +    Regression for #37361."""
    +    terminal_tool.register_task_env_overrides(
    +        "acp-session-abc", {"cwd": "/home/user/project"}
    +    )
    +    try:
    +        assert (
    +            terminal_tool._resolve_container_task_id("acp-session-abc")
    +            == "default"
    +        )
    +    finally:
    +        terminal_tool.clear_task_env_overrides("acp-session-abc")
    +
    +
    +def test_cwd_plus_docker_image_keeps_own_id():
    +    """When overrides include both cwd AND docker_image, isolation must
    +    still be honoured (RL/benchmark pattern with explicit cwd)."""
    +    terminal_tool.register_task_env_overrides(
    +        "rl-with-cwd", {"docker_image": "myimg:latest", "cwd": "/workspace"}
    +    )
    +    try:
    +        assert (
    +            terminal_tool._resolve_container_task_id("rl-with-cwd")
    +            == "rl-with-cwd"
    +        )
    +    finally:
    +        terminal_tool.clear_task_env_overrides("rl-with-cwd")
    +
    +
    +def test_env_type_override_keeps_own_id():
    +    """env_type is an isolation key — must trigger per-task container."""
    +    terminal_tool.register_task_env_overrides(
    +        "bench-env", {"env_type": "sandbox", "cwd": "/work"}
    +    )
    +    try:
    +        assert (
    +            terminal_tool._resolve_container_task_id("bench-env")
    +            == "bench-env"
    +        )
    +    finally:
    +        terminal_tool.clear_task_env_overrides("bench-env")
    ```
  - `tools/terminal_tool.py`

    ```diff
    @@ -1006,9 +1006,20 @@ def _resolve_container_task_id(task_id: Optional[str]) -> str:
         task_id, we honour it by returning the task_id unchanged -- those
         rollouts need their own isolated sandbox, which is the whole point of
         the override.
    +
    +    CWD-only overrides (registered by the ACP adapter for workspace
    +    tracking) are *not* isolation signals — they should not cause each
    +    session to spin up its own container.  Only overrides containing
    +    backend-specific image keys or ``env_type`` trigger isolation.
         """
    +    _ISOLATION_KEYS = frozenset({
    +        "docker_image", "modal_image", "singularity_image",
    +        "daytona_image", "env_type",
    +    })
         if task_id and task_id in _task_env_overrides:
    -        return task_id
    +        overrides = _task_env_overrides[task_id]
    +        if set(overrides.keys()) & _ISOLATION_KEYS:
    +            return task_id
         return "default"
     
     
    ```
- **#37372: fix(terminal): collapse CWD-only overrides to shared container**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`; refs `#41822`

## Fix status

- Merged to main in PR #41822 (cited above). No release data is tracked. Verify downstream.
- Fix last verified (merged) `2026-06-08`.
- Subsystem: `environments`
