mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix: propagate logging session context after daemon-pool compress_context
compress_context now runs on a daemon pool worker thread (via run_compress_context_with_progress_timeout). The session id rotation updates hermes_logging._session_context (a threading.local) on the WORKER thread, not the caller thread. After the wrapper returns, propagate self.session_id back to the caller's logging context so subsequent log lines carry the rotated id (#34089). Fixes CI failure in test_compression_logging_session_context.
This commit is contained in:
parent
b1218e5e70
commit
1f405aa9ef
1 changed files with 12 additions and 1 deletions
13
run_agent.py
13
run_agent.py
|
|
@ -6812,7 +6812,7 @@ class AIAgent:
|
|||
"session, or check auxiliary.compression."
|
||||
)
|
||||
|
||||
return run_compress_context_with_progress_timeout(
|
||||
result = run_compress_context_with_progress_timeout(
|
||||
worker=_run,
|
||||
messages=messages,
|
||||
system_prompt_fallback=_fallback_prompt,
|
||||
|
|
@ -6820,6 +6820,17 @@ class AIAgent:
|
|||
total_ceiling_seconds=total_ceiling,
|
||||
on_timeout=_on_timeout,
|
||||
)
|
||||
# compress_context ran on a daemon pool worker thread; the session
|
||||
# id rotation updated hermes_logging._session_context (a
|
||||
# threading.local) on the WORKER thread, not this one. Propagate
|
||||
# the current session_id back so subsequent log lines on this
|
||||
# thread carry the rotated id (#34089).
|
||||
try:
|
||||
from hermes_logging import set_session_context
|
||||
set_session_context(self.session_id)
|
||||
except Exception:
|
||||
pass
|
||||
return result
|
||||
finally:
|
||||
# Restore whatever the caller had, so a compaction never leaks its
|
||||
# tag into the surrounding scope.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue