mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-26 01:01:40 +00:00
Long-lived gateway sessions can accumulate enough history that every new
message rehydrates an oversized transcript, causing repeated truncation
failures (finish_reason=length).
Add a session hygiene check in _handle_message that runs right after
loading the transcript and before invoking the agent:
1. Estimate message count and rough token count of the transcript
2. If above configurable thresholds (default: 200 msgs or 100K tokens),
auto-compress the transcript proactively
3. Notify the user about the compression with before/after stats
4. If still above warn threshold (default: 200K tokens) after
compression, suggest /reset
5. If compression fails on a dangerously large session, warn the user
to use /compress or /reset manually
Thresholds are configurable via config.yaml:
session_hygiene:
auto_compress_tokens: 100000
auto_compress_messages: 200
warn_tokens: 200000
This complements the agent's existing preflight compression (which
runs inside run_conversation) by catching pathological sessions at
the gateway layer before the agent is even created.
Includes 12 tests for threshold detection and token estimation.
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_async_memory_flush.py | ||
| test_channel_directory.py | ||
| test_config.py | ||
| test_delivery.py | ||
| test_document_cache.py | ||
| test_homeassistant.py | ||
| test_hooks.py | ||
| test_media_extraction.py | ||
| test_mirror.py | ||
| test_pairing.py | ||
| test_platform_base.py | ||
| test_session.py | ||
| test_session_hygiene.py | ||
| test_sticker_cache.py | ||
| test_telegram_documents.py | ||
| test_telegram_format.py | ||
| test_transcript_offset.py | ||
| test_update_command.py | ||
| test_whatsapp_connect.py | ||