Skip to content

delegate_task subagent environments lack $HOME, causing cascading Path.home() failures #11068

@Ramadas108

Description

@Ramadas108

GitHub Issue: delegate_task HOME env bug

Repo: NousResearch/hermes-agent
Labels: bug

Title

delegate_task subagent environments lack $HOME, causing cascading Path.home() failures

Body

Bug Description

When using delegate_task, spawned subagent environments do not inherit the $HOME environment variable. This causes Path.home() and os.path.expanduser() to fail in hermes_tools during API calls, triggering retry loops that consume ~40x more time than actual compute.

Steps to Reproduce

  1. Call delegate_task with a task that requires hermes_tools (e.g., read_file, terminal)
  2. Observe error: Could not determine home directory
  3. Subagent retries, each retry takes ~10-15s of recovery overhead

Expected Behavior

Subagent environments should inherit $HOME from the parent process, or hermes_tools should include a fallback:

home = os.environ.get('HOME') or os.path.expanduser('~') or '/home/openclaw'

Actual Behavior

  • 6 API call failures in a 9-call task
  • 869s total runtime, ~20s actual compute, ~849s retry/recovery overhead
  • Error originates from pathlib.Path.home() when HOME is unset

Environment

  • OS: Linux (Ubuntu, VPS)
  • Hermes Agent: latest (NousResearch/hermes-agent)
  • Python: 3.12
  • Tool: delegate_task with toolsets=['terminal','file','web']

Evidence

Session log shows repeated pattern:

❌ Error during OpenAI-compatible API call #6: Could not determine home directory.

Proposed Fix

Either:

  1. delegate_task injects HOME into subagent process environment before spawning
  2. hermes_tools adds fallback chain: $HOME → getent passwd → /home/openclaw

The init scripts (init_run.py, validate_run.py) already implement this fallback — the same pattern should apply to the tool runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt buildertool/delegateSubagent delegationtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions