Skip to content

TypeError: got multiple values for keyword argument 'TERMINAL_CWD' when profile config.yaml has terminal.cwd set #1270

@mrabit

Description

@mrabit

Describe the Bug

When a user's profile config.yaml has terminal.cwd set to a non-null value, sending a chat message triggers:

TypeError: api.config._set_thread_env() got multiple values for keyword argument 'TERMINAL_CWD'

Root Cause

In api/streaming.py (line ~1422), _set_thread_env() is called with both:

  1. **_profile_runtime_env — populated by get_profile_runtime_env() (added in commit 8a74ea8) which reads terminal.cwd from the profile's config.yaml and maps it to TERMINAL_CWD via _TERMINAL_ENV_MAPPINGS in api/profiles.py (line 164)
  2. An explicit TERMINAL_CWD=str(s.workspace) keyword argument

Python raises TypeError because the same key appears in both the **dict unpacking and as an explicit kwarg.

The same risk applies to HERMES_EXEC_ASK, HERMES_SESSION_KEY, and HERMES_HOME if _profile_runtime_env ever contains them.

Steps to Reproduce

  1. Set terminal.cwd: . (or any non-null value) in the profile's config.yaml
  2. Open WebUI and send a chat message
  3. Server returns 500 with the TypeError above

Expected Behavior

Each key should be passed to _set_thread_env() only once. Keys that are explicitly passed should be removed from _profile_runtime_env before unpacking.

Suggested Fix

# api/streaming.py, before the _set_thread_env() call
_profile_runtime_env.pop('TERMINAL_CWD', None)
_profile_runtime_env.pop('HERMES_EXEC_ASK', None)
_profile_runtime_env.pop('HERMES_SESSION_KEY', None)
_profile_runtime_env.pop('HERMES_HOME', None)

_set_thread_env(
    **_profile_runtime_env,
    TERMINAL_CWD=str(s.workspace),
    ...
)

Environment

  • hermes-webui: master (9f269a4 / v0.50.239)
  • hermes-agent: v0.11.0
  • Triggered by: commit 8a74ea8 ("fix: apply profile terminal env in webui sessions") which introduced get_profile_runtime_env()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsprint-candidateStrong candidate for next sprint

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions