Skip to content

The agent that grows with you

fix(gateway): cold-session /compress engine gets compression.model_thresholds; document manual /compress for engines

Teknium601b3682670e
diff --git a/gateway/session_mutation_compress.py b/gateway/session_mutation_compress.py
index 7756cc30d92..a61f07c16be 100644
--- a/gateway/session_mutation_compress.py
+++ b/gateway/session_mutation_compress.py
@@ -132,6 +132,9 @@ def _plugin_engine(authority, policy, config, model, runtime, resident, target):
if engine is None:
return None
from agent.model_metadata import get_model_context_length
+ thresholds = (config.get('compression') or {}).get('model_thresholds')
+ if isinstance(thresholds, dict) and thresholds: # before update_model, like agent init
+ engine.model_thresholds = {str(k): float(v) for k, v in thresholds.items()}
base_url, api_key = runtime.get('base_url') or '', runtime.get('api_key') or ''
provider = runtime.get('provider') or ''
context_length = get_model_context_length(model, base_url=base_url, api_key=api_key, provider=provider,
diff --git a/website/docs/developer-guide/context-engine-plugin.md b/website/docs/developer-guide/context-engine-plugin.md
index 8ffc9822a03..1fae25c8b20 100644
--- a/website/docs/developer-guide/context-engine-plugin.md
+++ b/website/docs/developer-guide/context-engine-plugin.md
@@ -315,6 +315,13 @@ def clone_for_agent(self):
`on_session_reset()` is called on `/new` or `/reset` to clear per-session state without a full shutdown.
+Manual `/compress` on every surface (classic CLI, TUI, Desktop, messaging, ACP) calls your
+engine's `compress()` with `force=True` and the optional focus topic, never the built-in
+compressor. Once the compacted history is committed, the engine receives
+`on_session_start(session_id, boundary_reason="compression", old_session_id=...)` (the same id
+twice for in-place compaction). A session with no live agent may get a fresh engine instance
+for that compression, which then also receives `on_session_end()`.
+
## Configuration
Users select your engine via `hermes plugins` → Provider Plugins → Context Engine, or by editing `config.yaml`: