Skip to content

fix(subdirectory-hints): avoid crash when HOME is unavailable - #50926

Closed
infinitycrew39 wants to merge 2 commits into
NousResearch:mainfrom
infinitycrew39:fix/subdir-hints-expanduser-runtime
Closed

fix(subdirectory-hints): avoid crash when HOME is unavailable#50926
infinitycrew39 wants to merge 2 commits into
NousResearch:mainfrom
infinitycrew39:fix/subdir-hints-expanduser-runtime

Conversation

@infinitycrew39

Copy link
Copy Markdown
Contributor

What happened

In restricted service environments (cron/systemd/container), Path.expanduser() can raise:

RuntimeError: Could not determine home directory.

When that happened inside SubdirectoryHintTracker._add_path_candidate(), it bubbled out and interrupted tool-call execution.

Why this is a bug

Subdirectory hints are best-effort context enrichment. They should never crash the agent/tool path when a path token cannot be resolved.

Fix

Treat RuntimeError from Path.expanduser() the same as existing path-resolution errors (OSError, ValueError) and skip that candidate path.

Tests

Added regression test in tests/agent/test_subdirectory_hints.py to force Path.expanduser() to raise RuntimeError("Could not determine home directory.") and verify check_tool_call() returns safely.

Commits

  1. fix(subdirectory-hints): ignore expanduser runtime failure when HOME is missing
  2. test(subdirectory-hints): cover expanduser RuntimeError with missing HOME

…is missing

Path.expanduser() can raise RuntimeError in restricted service environments
where HOME is unavailable. That error bubbled out of SubdirectoryHintTracker,
interrupting tool-call execution.

Treat this the same as other path-resolution failures and skip the candidate
path instead of crashing the turn.
…HOME

Add a regression test that forces Path.expanduser() to raise
RuntimeError('Could not determine home directory.') and verifies
check_tool_call() returns safely instead of crashing.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists labels Jun 22, 2026
@teknium1

teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixed on main via #56355, which salvaged @udatny's #29433 — the earliest of three PRs fixing this exact bug (catch RuntimeError from Path.expanduser() in agent/subdirectory_hints.py). Your fix was correct and confirmed the same root cause; #29433 was submitted first, so it was salvaged with its authorship preserved. Thanks for the contribution — credited here.

Merge commit: 55c8b2c

@teknium1 teknium1 closed this Jul 1, 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 P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants