-
-
Notifications
You must be signed in to change notification settings - Fork 52.9k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Add a new hook event message:received that fires before the agent processes an incoming message. This enables pre-turn automations like memory curation, context injection, and audit logging.
Use Cases
- Memory curation (memfas) — Score and curate relevant memories before the turn, reducing token usage by 80%+
- Context injection — Auto-inject relevant context based on message content
- Audit logging — Log all incoming messages for compliance
- Rate limiting — Check/enforce per-user limits before processing
Proposed Event Shape
type MessageReceivedHookEvent = {
type: "message";
action: "received";
context: {
message: string;
senderId?: string;
channel: string;
isGroup: boolean;
sessionKey: string;
// Mutable: hooks can inject context
injectedContext?: string;
// Mutable: hooks can skip processing
skipProcessing?: boolean;
};
};Example Hook
const handler: HookHandler = async (event) => {
if (event.type !== "message" || event.action !== "received") return;
// Run memfas curation
const curated = await runMemfasCurate(event.context.message);
event.context.injectedContext = curated.context;
};Design Doc
See docs/proposals/message-received-hook.md for full proposal.
Related
- Hooks system: https://docs.clawd.bot/hooks
- memfas (memory curation): https://github.com/wangtian24/agent-memfas
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request