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:
**_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)
- 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
- Set
terminal.cwd: . (or any non-null value) in the profile's config.yaml
- Open WebUI and send a chat message
- 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()
Describe the Bug
When a user's profile
config.yamlhasterminal.cwdset to a non-null value, sending a chat message triggers:Root Cause
In
api/streaming.py(line ~1422),_set_thread_env()is called with both:**_profile_runtime_env— populated byget_profile_runtime_env()(added in commit8a74ea8) which readsterminal.cwdfrom the profile'sconfig.yamland maps it toTERMINAL_CWDvia_TERMINAL_ENV_MAPPINGSinapi/profiles.py(line 164)TERMINAL_CWD=str(s.workspace)keyword argumentPython raises
TypeErrorbecause the same key appears in both the**dictunpacking and as an explicit kwarg.The same risk applies to
HERMES_EXEC_ASK,HERMES_SESSION_KEY, andHERMES_HOMEif_profile_runtime_envever contains them.Steps to Reproduce
terminal.cwd: .(or any non-null value) in the profile'sconfig.yamlExpected Behavior
Each key should be passed to
_set_thread_env()only once. Keys that are explicitly passed should be removed from_profile_runtime_envbefore unpacking.Suggested Fix
Environment
9f269a4/ v0.50.239)8a74ea8("fix: apply profile terminal env in webui sessions") which introducedget_profile_runtime_env()