mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-11 08:42:11 +00:00
test(prompt): place cwd regression tests in TestEnvironmentHints (drop redundant docker case)
This commit is contained in:
parent
16047655b5
commit
c79b80a8a5
1 changed files with 23 additions and 25 deletions
|
|
@ -3,7 +3,6 @@
|
|||
import builtins
|
||||
import importlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
|
@ -19,7 +18,6 @@ from agent.prompt_builder import (
|
|||
build_skills_system_prompt,
|
||||
build_nous_subscription_prompt,
|
||||
build_context_files_prompt,
|
||||
build_environment_hints,
|
||||
CONTEXT_FILE_MAX_CHARS,
|
||||
DEFAULT_AGENT_IDENTITY,
|
||||
TOOL_USE_ENFORCEMENT_GUIDANCE,
|
||||
|
|
@ -929,6 +927,29 @@ class TestEnvironmentHints:
|
|||
assert "Terminal backend: docker" in result
|
||||
assert "inside" in result.lower()
|
||||
|
||||
def test_build_environment_hints_uses_terminal_cwd_over_launch_dir(self, monkeypatch, tmp_path):
|
||||
"""THE BUG: gateway/cron set TERMINAL_CWD but the prompt emitted os.getcwd()
|
||||
(the daemon launch dir). Regression for #24882/#24969/#27383/#29265."""
|
||||
import agent.prompt_builder as _pb
|
||||
monkeypatch.setattr(_pb, "is_wsl", lambda: False)
|
||||
monkeypatch.delenv("TERMINAL_ENV", raising=False)
|
||||
configured = tmp_path / "workspace"
|
||||
configured.mkdir()
|
||||
monkeypatch.setenv("TERMINAL_CWD", str(configured))
|
||||
monkeypatch.chdir(tmp_path)
|
||||
_pb._clear_backend_probe_cache()
|
||||
assert f"Current working directory: {configured}" in _pb.build_environment_hints()
|
||||
|
||||
def test_build_environment_hints_falls_back_to_launch_dir(self, monkeypatch, tmp_path):
|
||||
"""The #19242 local-CLI contract: no TERMINAL_CWD → the launch dir."""
|
||||
import agent.prompt_builder as _pb
|
||||
monkeypatch.setattr(_pb, "is_wsl", lambda: False)
|
||||
monkeypatch.delenv("TERMINAL_ENV", raising=False)
|
||||
monkeypatch.delenv("TERMINAL_CWD", raising=False)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
_pb._clear_backend_probe_cache()
|
||||
assert f"Current working directory: {tmp_path}" in _pb.build_environment_hints()
|
||||
|
||||
def test_build_environment_hints_uses_live_probe_when_available(self, monkeypatch):
|
||||
"""When the probe succeeds, its output must appear in the hint block."""
|
||||
import agent.prompt_builder as _pb
|
||||
|
|
@ -1249,26 +1270,3 @@ class TestOpenAIModelExecutionGuidance:
|
|||
# =========================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TestBuildEnvironmentHints:
|
||||
"""The cwd line must reflect the configured TERMINAL_CWD, not the daemon launch dir.
|
||||
|
||||
Regression for the gateway working-directory cluster (#24882, #24969, #27383, #29265):
|
||||
gateway/cron set TERMINAL_CWD, but build_environment_hints emitted os.getcwd() — telling
|
||||
the model the wrong directory.
|
||||
"""
|
||||
|
||||
def test_uses_terminal_cwd_when_set(self, monkeypatch, tmp_path):
|
||||
monkeypatch.delenv("TERMINAL_ENV", raising=False)
|
||||
monkeypatch.setenv("TERMINAL_CWD", str(tmp_path))
|
||||
monkeypatch.chdir(os.path.expanduser("~"))
|
||||
assert f"Current working directory: {tmp_path}" in build_environment_hints()
|
||||
|
||||
def test_falls_back_to_launch_dir_when_unset(self, monkeypatch, tmp_path):
|
||||
# The #19242 local-CLI contract: no TERMINAL_CWD → the launch dir.
|
||||
monkeypatch.delenv("TERMINAL_ENV", raising=False)
|
||||
monkeypatch.delenv("TERMINAL_CWD", raising=False)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
assert f"Current working directory: {tmp_path}" in build_environment_hints()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue