Skip to content

fix(prompt): use HOME env var over expanduser for system prompt - #7

Open
liuhao1024 wants to merge 1 commit into
mainfrom
liuhao/cron-bugfix-63093
Open

liuhao1024 wants to merge 1 commit into
mainfrom
liuhao/cron-bugfix-63093

Conversation

@liuhao1024

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes a bug where the system prompt reported an incorrect "User home directory" value in container environments. The prompt displayed /opt/data (the CWD) instead of the actual $HOME value /opt/data/home.

The root cause: os.path.expanduser('~') may return incorrect paths in some container setups where the $HOME environment variable is the authoritative source. This PR prioritizes $HOME over os.path.expanduser('~').

Related Issue

Fixes NousResearch#63093

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • agent/prompt_builder.py: Changed User home directory: {os.path.expanduser('~')} to User home directory: {os.environ.get('HOME', os.path.expanduser('~'))} (1 line)
  • tests/agent/test_prompt_builder.py: Added regression test test_build_environment_hints_uses_home_env_over_expanduser (13 lines)

How to Test

  1. In a container environment where $HOME differs from CWD (e.g., HOME=/opt/data/home, CWD=/opt/data)
  2. Run Hermes with local terminal backend
  3. Observe the system prompt header — it should now correctly report User home directory: /opt/data/home (matching $HOME) instead of /opt/data

Test coverage: pytest tests/agent/test_prompt_builder.py -k "uses_home_env" should pass.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4.1

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Fixes NousResearch#63093

The system prompt reported 'User home directory: /opt/data' (CWD)
instead of the actual HOME value '/opt/data/home' in container
environments. os.path.expanduser('~') may return incorrect paths in
some container setups; HOME env var is the authoritative source.
liuhao1024 pushed a commit that referenced this pull request Aug 15, 2026
…ovider

Cancelling the API-key prompt mid-wizard (Enter → 'Cancelled.') let the
wizard continue through Terminal/Gateway/Tools and finish 'successfully'
with no model configured — the user exits believing they're set up, then
hits a broken chat.

_print_setup_summary() (called by every setup path: full, quick,
blank-slate, portal) now probes resolve_provider() and, when nothing is
configured, prints an unmissable warning with the two one-line fixes
(hermes model / hermes setup --portal).

Consumer-onboarding audit finding #7 (sev 4), Aug 2026.
liuhao1024 pushed a commit that referenced this pull request Aug 15, 2026
… (re-review #7)

- website/docs/user-guide/configuration.md (en) and the zh-Hans
  translation gain a 'Session Stall Watchdog' section: default 300,
  0=disabled, notify-only semantics (never kills the turn — contrast
  gateway_timeout), one notification per stall episode, and the exact
  stall message text so it is greppable.
- cli-config.yaml.example: the two in-agent compression timeout keys
  (compression.context_timeout_seconds /
  compression.context_total_ceiling_seconds) are shown as commented
  lines next to session_stall_timeout's example for discoverability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: System prompt reports incorrect home directory path (/opt/data instead of $HOME)

1 participant