Skip to content

Feature Request: Expose message lifecycle hooks in Plugin API #9524

@nezovskii

Description

@nezovskii

Summary

I'm building a plugin for real-time message sync to an external database (Convex) and discovered that while OpenClaw has the infrastructure for message hooks, they're not fully exposed to the Plugin API.

Current State

Hooks defined but not called:

  • message_sent - defined in src/plugins/types.ts but never called
  • message_received - defined but never called

Internal events not exposed:

  • onSessionTranscriptUpdate in src/sessions/transcript-events.ts - fires when transcripts update but not accessible to plugins

Callbacks exist but internal only:

  • onPayload callback in deliverOutboundPayloads() - called before sending but not exposed

Proposal

Please consider one of:

  1. Implement the existing message hooks: Call runMessageSent() and runMessageReceived() in the appropriate places so plugins can register for these events

  2. Expose transcript events: Add api.runtime.transcriptEvents.onSessionTranscriptUpdate() to the Plugin API

  3. Add delivery callbacks to Plugin API: Allow plugins to register for onPayload callbacks in the delivery flow

Use Cases

  • Real-time message archival to external databases
  • Message logging/auditing
  • External integrations that need to react to messages
  • Memory/RAG systems that need to capture conversations

Research

I used Nia to trace the codebase and found:

  • src/infra/outbound/deliver.ts has onPayload callback at line 276
  • src/sessions/transcript-events.ts has the event system
  • src/plugins/hooks.ts has runMessageSent() defined but no callers

Would love to help implement if pointed in the right direction!

/cc @openclaw team

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions