Files
hermes-agent/tests/hermes_cli/test_cli_context_reference_passthrough.py
unsupportedpastels dddbc6dc38 fix(gateway): resolve local paths against the session's folder, not the daemon's
The shared gateway runs in its own working directory, and several paths a
local session names were resolved there.

- @file/@folder/@diff/@git (TUI-1): the inbound expansion ran before the
  turn's policy scope was bound and read the daemon's TERMINAL_CWD. A local
  session now uses its own policy cwd as both cwd and allowed root;
  messaging is unchanged.
- Classic CLI double expansion (PLG-4): the CLI expanded references itself,
  then the gateway expanded the result again. The client-side pass is
  removed; the gateway expands once against the cwd the CLI sends at
  session.create. The CLI's "N refs" line goes with it; refusals are still
  reported by the gateway.
- Ink path completion (TUI-2) sends the session's folder with complete.path.
- Ink image attach (TUI-10) resolves relative paths against the session's
  folder (the launch folder for a remote gateway) instead of the ui-tui
  install folder.
- Remote terminal backends (TUI-11): build_policy forced the client's host
  folder as TERMINAL_CWD for ssh/modal/docker sessions. The host cwd now
  applies only to the local backend, docker with
  docker_mount_cwd_to_workspace, or an explicitly picked folder.

Refs #134889 (PLG-4, TUI-1, TUI-2, TUI-10, TUI-11)
2026-10-14 20:38:25 -04:00

42 lines
1.4 KiB
Python

"""The classic CLI leaves ``@`` references to the gateway, which expands them once against the
session's cwd; a client-side pass first expanded them twice (PLG-4)."""
from types import SimpleNamespace
import pytest
class _Staged(Exception):
pass
def test_chat_submits_at_references_unexpanded(tmp_path, monkeypatch):
from cli import HermesCLI
(tmp_path / "example.py").write_text("CLIENT-SIDE-CONTENT", encoding="utf-8")
monkeypatch.chdir(tmp_path)
cli = HermesCLI.__new__(HermesCLI)
cli.model = "gpt-5.6-terra"
cli.base_url = "https://chatgpt.com/backend-api/codex"
cli.api_key = "token"
cli.provider = "openai-codex"
cli.agent = SimpleNamespace(_config_context_length=None)
cli._active_agent_route_signature = "route"
cli._secret_capture_callback = lambda *_args, **_kwargs: None
cli._last_turn_interrupted = False
cli._ensure_runtime_credentials = lambda: True
cli._resolve_turn_agent_config = lambda _message: {
"signature": "route", "model": cli.model, "runtime": None, "request_overrides": None}
cli._init_agent = lambda **_kwargs: True
staged = []
def _stage(_agent, message):
staged.append(message)
raise _Staged
cli._chat_stage_user_message = _stage
with pytest.raises(_Staged):
cli.chat("inspect @file:example.py")
assert staged == ["inspect @file:example.py"]