Cyber-Yichen
hermes-feishu-group-context
Local Feishu/Lark group chat archiving and on-demand context retrieval for Hermes Agent.
Repository last updated Jul 1, 2026
Overview
Hermes Feishu Group Context is a plugin that archives Feishu/Lark group messages locally and provides context only when the agent is explicitly triggered. It uses a local SQLite database to store messages, ensuring model tokens are not consumed for every message. The plugin automatically injects recent history for empty mentions or provides specific time-range summaries via a dedicated tool, allowing the agent to maintain group awareness without processing every message in real-time.
When a user sends a message without mentioning the bot, the message is archived but does not trigger the model. A bare mention (just @bot) automatically loads the most recent archived messages (default 20) for context. A mention with content checks relevance against the last 5 messages; if unrelated, no context is injected. Users can also request summaries for specific time ranges (today, yesterday, last N hours, or custom) using natural language, which triggers the feishu_group_history tool.
This plugin is ideal for teams using Hermes Agent with Feishu/Lark who want to retain group chat history without incurring token costs for every message. It is designed for Windows environments and integrates seamlessly with the Hermes Feishu adapter via hooks.
Highlights
- Local SQLite storage for group chat archiving and persistence
- Automatic context injection for empty mentions and relevant queries
- Customizable retention periods and context window sizes per group
- On-demand time-range summaries via feishu_group_history tool
- Backfill historical messages using Feishu Open API
- Idempotent installation script with adapter backup
Features
Local Archiving
All group messages are archived to a local SQLite database with WAL mode, surviving Hermes restarts.
Selective Context Injection
Only injects recent history for bare mentions or relevant queries; unrelated messages do not consume tokens.
Per-Group Configuration
Each group can independently set the number of context messages for bare mentions and content mentions, as well as retention days.
Time-Range Summaries
Users can request summaries for today, yesterday, last N hours, or a custom time range via the feishu_group_history tool.
Historical Backfill
A script allows backfilling messages from before plugin installation using the Feishu Open API, with deduplication by message_id.
Automatic Cleanup
Old messages are automatically deleted based on per-group retention settings (default 30 days), with cleanup triggered on new messages and config changes.
Requirements
- Windows 10 or Windows 11
- Hermes Agent installed and configured with Feishu/Lark platform
- Feishu app with bot capability enabled and im.message.receive_v1 event subscribed
- Bot added to target groups
- Feishu app permissions: im:message.group_msg, im:message:readonly (or im:message), im:message:send_as_bot
How it's built
The plugin consists of two parts: a Hermes user plugin and an adapter patch. The user plugin registers hooks for feishu_group_message_received, feishu_group_empty_mention, and feishu_group_content_mention, as well as the feishu_group_history tool and the /group-context command. The adapter patch adds hooks before the Hermes Feishu adapter discards non-mention messages, enabling archiving and context injection without modifying the core agent logic.
The plugin is written in Python 3.10+ using only the standard library (sqlite3, urllib, json, zoneinfo). It requires no additional PyPI packages. The repository layout includes plugin/__init__.py and plugin/plugin.yaml for the plugin, scripts/patch_adapter.py for patching the adapter, and scripts/backfill_history.py for historical backfill. The installation script install.ps1 is PowerShell-based and targets Windows.
Data is stored in HERMES_HOME/archives/feishu_group_messages.sqlite3 (SQLite with WAL) and HERMES_HOME/archives/feishu_context_settings.json. The plugin integrates with the Hermes Feishu adapter by adding hooks at specific insertion points, which are checked and applied by the patch script. The patch is idempotent and creates backups before modification.
Source
This summary was written for Neura Market from the project's own repository. Install commands, identifiers and licence details are reproduced unchanged. The Cyber-Yichen/hermes-feishu-group-context repository is the authoritative source and the place to file issues or contribute.
Category: Messaging & Social · Licensed under MIT