openclaw - 💡(How to fix) Fix Feature request: session:send and session:spawn hook events [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50030Fetched 2026-04-08 01:00:06
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
closed ×1locked ×1

Multi-agent setups need to observe inter-agent communication. Currently, message:sent and message:received hook events only fire for outbound channel messages (Discord, Telegram, etc.), not for internal sessions_send or sessions_spawn calls.

This means hooks like mc-bridge cannot auto-track inter-agent work delegation, because the dispatch happens through internal routing that doesn't trigger any hook event.

Root Cause

This means hooks like mc-bridge cannot auto-track inter-agent work delegation, because the dispatch happens through internal routing that doesn't trigger any hook event.

Fix Action

Fix / Workaround

This means hooks like mc-bridge cannot auto-track inter-agent work delegation, because the dispatch happens through internal routing that doesn't trigger any hook event.

In a Discord-based multi-agent org (inspired by Alex Finn's setup):

  • An orchestrator agent (Moth) dispatches tasks to a worker agent (Bob) via sessions_send
  • A Mission Control hook should auto-track these dispatches as 'runs'
  • Currently this is impossible because no hook event fires on sessions_send

Current Workaround

The orchestrator manually mirrors every dispatch to Discord via openclaw message send, which is fragile (depends on prompt compliance) and duplicates effort.

RAW_BUFFERClick to expand / collapse

Summary

Multi-agent setups need to observe inter-agent communication. Currently, message:sent and message:received hook events only fire for outbound channel messages (Discord, Telegram, etc.), not for internal sessions_send or sessions_spawn calls.

This means hooks like mc-bridge cannot auto-track inter-agent work delegation, because the dispatch happens through internal routing that doesn't trigger any hook event.

Requested Events

  • session:send — fires when sessions_send delivers a message to another agent session
    • Context should include: source session key, target session key, message content, success/failure
  • session:spawn — fires when sessions_spawn creates a new sub-agent session
    • Context should include: parent session key, child session key, task/label, model

Use Case

In a Discord-based multi-agent org (inspired by Alex Finn's setup):

  • An orchestrator agent (Moth) dispatches tasks to a worker agent (Bob) via sessions_send
  • A Mission Control hook should auto-track these dispatches as 'runs'
  • Currently this is impossible because no hook event fires on sessions_send

Current Workaround

The orchestrator manually mirrors every dispatch to Discord via openclaw message send, which is fragile (depends on prompt compliance) and duplicates effort.

With These Events

A hook on session:send could automatically:

  • Track run lifecycle in an external dashboard
  • Mirror inter-agent messages to Discord channels for observability
  • Log all delegation for audit purposes

Impact

This would make multi-agent observability a first-class capability instead of requiring manual workarounds. It's the missing piece for reliable agent-to-agent orchestration hooks.

extent analysis

Fix Plan

To address the issue, we need to introduce two new hook events: session:send and session:spawn. Here are the steps to implement these events:

  • Modify the sessions_send function to fire a session:send hook event after delivering a message to another agent session.
  • Modify the sessions_spawn function to fire a session:spawn hook event after creating a new sub-agent session.

Example Code

# sessions.py
from openclaw.hooks import fire_hook

def sessions_send(source_session_key, target_session_key, message):
    # ... (existing code to deliver the message)
    fire_hook('session:send', {
        'source_session_key': source_session_key,
        'target_session_key': target_session_key,
        'message': message,
        'success': True  # or False if delivery failed
    })

def sessions_spawn(parent_session_key, task, model):
    child_session_key = # ... (existing code to create a new session)
    fire_hook('session:spawn', {
        'parent_session_key': parent_session_key,
        'child_session_key': child_session_key,
        'task': task,
        'model': model
    })

Verification

To verify that the fix worked, you can:

  • Create a test hook that listens for session:send and session:spawn events and logs the received data.
  • Use the sessions_send and sessions_spawn functions to trigger the events and verify that the test hook receives the expected data.

Extra Tips

  • Make sure to handle any exceptions that may occur when firing the hook events to prevent crashes.
  • Consider adding additional context to the hook events, such as the timestamp or any error messages, to provide more detailed information for debugging and logging purposes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING