Community ContextEngine Implementation
Following up on #202 (Hermes Context Engine support), we built and open-sourced a feature-complete Python ContextEngine plugin for Hermes Agent that uses TencentDB Gateway's offload V2 API.
Repo
https://github.com/ysun0804/tencentdb-offload
What it does
Aligns with the official OpenClaw offload implementation, providing:
- post_tool_call hook — async tool_pair ingest after each tool call (L1 data source)
- pre_llm_call hook — heartbeat filtering + MMD canvas injection + incremental compression
- L3 4-level compression — fastpath → mild → aggressive → emergency (via Gateway compact API)
- L2 Mermaid canvas injection — via Gateway query-mmd endpoint
- Reclaimer — stale session cleanup
- SessionRegistry + SessionState — multi-session state management with LRU eviction
- Graceful degradation — tail-truncation fallback when Gateway is unavailable
- Zero dependencies — pure Python stdlib (urllib, json, threading, logging)
Key implementation details
- Hermes ContextEngine ABC doesn't have
assemble() or afterToolCall — we use pre_llm_call and post_tool_call hooks as equivalents
context_window is dynamically calculated (tokens / 0.7) to make Gateway's ratio land in the mild compression range
ingest_before_compact preserves full messages before truncation
Tests
25/25 passing (14 core + 11 feature-specific)
Compatibility
- TencentDB Agent Memory v1.0.0+ (offload V2 API)
- Hermes Agent v0.17.0+
- Python 3.10+
Happy to collaborate if the team is interested in an official integration.
Community ContextEngine Implementation
Following up on #202 (Hermes Context Engine support), we built and open-sourced a feature-complete Python ContextEngine plugin for Hermes Agent that uses TencentDB Gateway's offload V2 API.
Repo
https://github.com/ysun0804/tencentdb-offload
What it does
Aligns with the official OpenClaw offload implementation, providing:
Key implementation details
assemble()orafterToolCall— we usepre_llm_callandpost_tool_callhooks as equivalentscontext_windowis dynamically calculated (tokens / 0.7) to make Gateway's ratio land in the mild compression rangeingest_before_compactpreserves full messages before truncationTests
25/25 passing (14 core + 11 feature-specific)
Compatibility
Happy to collaborate if the team is interested in an official integration.