Skip to content

Feature Request: message:sent and message:received hooks #12775

@rb2763-ux

Description

@rb2763-ux

Summary

Request for message:sent and message:received hook events to enable response filtering/validation before messages are sent to users.

Use Case

I'm building a fact-checker middleware that validates AI responses before they reach the user. The goal is to catch "guessed" facts and force rewrites.

Currently, the hooks system supports:

  • command:new, command:reset, command:stop
  • agent:bootstrap
  • gateway:startup
  • tool_result_persist

But there's no way to intercept outgoing messages.

Proposed Events

// Triggered before a message is sent to the user
// Handler can modify or reject the message
message:sent

// Triggered when a message is received from the user
// Handler can preprocess or filter
message:received

Example Handler

const factCheckHandler: HookHandler = async (event) => {
  if (event.type !== 'message' || event.action !== 'sent') return;
  
  const result = await factChecker.check(event.context.message);
  
  if (!result.passed) {
    // Reject message, request rewrite
    event.reject = true;
    event.rejectReason = result.grund;
  }
};

Notes

I see these are already listed as "Future Events" in the docs. Any timeline for implementation?

Thanks for the great project! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions