fix: use runtime Hermes home for agent logging - #27336
Conversation
This comment was marked as spam.
This comment was marked as spam.
|
Thanks for the focused fix — I verified the premise still holds on current main. Current main assigns Suggested changes
Automated hermes-sweeper review; humans decide final salvage/merge. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused runtime-home fix. The cached-home premise remains valid on current main: run_agent.py:125 captures _hermes_home, and agent/agent_init.py:700 passes it into setup_logging().
Problems
- The changed call at PR
agent/agent_init.py:454adds handlers for the runtime profile but does not replace the existing default-home handlers.setup_logging()registersagent.loganderrors.loghandlers athermes_logging.py:321-338;_add_rotating_handler()deduplicates only the same resolved path athermes_logging.py:741-746. The queue listener then dispatches root records to every registered target (hermes_logging.py:615-639). Default-home logging therefore continues, and concurrent profile sessions can cross-copy logs.
Suggested changes
- Make handler routing profile-aware (or otherwise isolate existing handlers) and add an unmocked regression test that initializes default-home logging before constructing an agent under the context-local profile override used by
tui_gateway/server.py:1349.
Automated hermes-sweeper review.
| # (which creates a new AIAgent per message) won't duplicate handlers. | ||
| from hermes_logging import setup_logging, setup_verbose_logging | ||
| setup_logging(hermes_home=_ra()._hermes_home) | ||
| setup_logging(hermes_home=get_hermes_home()) |
There was a problem hiding this comment.
This selects the new profile path but leaves existing default-home handlers active: _add_rotating_handler() only deduplicates identical resolved paths (hermes_logging.py:741-746), and the shared QueueListener sends every root record to all registered targets (hermes_logging.py:615-639). Please add profile-aware routing or retire/filter the old handlers, then cover the pre-initialized default-home case without mocking setup_logging().
Summary
HERMES_HOMEinstead of the import-time cachedrun_agent._hermes_home.run_agentunder one home and create an agent after switching to a profile home.Root Cause
run_agent._hermes_homeis captured whenrun_agentis imported. Long-lived hosts such as the Web UI bridge can importrun_agentwhile the default profile is active, then temporarily setHERMES_HOMEto a named profile before creatingAIAgent. Because logging setup used the cached value,agent.loganderrors.logcontinued writing to the default profile even though runtime profile state had changed.Validation
pytest -o addopts="" tests/run_agent/test_run_agent.py -k "logging_uses_runtime_hermes_home or reuses_existing_errors_log_handler"Note:
-o addopts=""was used locally because this environment does not have the xdist plugin required by the repository default-npytest option.