openclaw - 💡(How to fix) Fix [Feature Request] Add agent:turn:complete hook event for notification/sound playback [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#59199Fetched 2026-04-08 02:27:37
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
1
Participants
Timeline (top)
subscribed ×1

Fix Action

Fix / Workaround

Looking at the hooks documentation, the available events are:

  • Command events: command:new, command:reset, command:stop
  • Session events: session:compact:before, session:compact:after, session:patch
  • Agent events: agent:bootstrap
  • Gateway events: gateway:startup
  • Message events: message:received, message:sent

Code Example

agent:turn:complete

---

{
  type: 'agent',
  action: 'turn:complete',
  sessionKey: string,
  sessionId: string,
  timestamp: Date,
  context: {
    messageCount: number,      // Number of message chunks sent
    toolCalls: string[],       // List of tools called during the turn
    duration: number,          // Time taken for the turn (ms)
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Currently, there is no hook event that fires when an agent completes a response (turn). This makes it impossible to implement task completion notifications (like playing a sound) that trigger after all streaming content has been delivered to the user.

Current Hook Events

Looking at the hooks documentation, the available events are:

  • Command events: command:new, command:reset, command:stop
  • Session events: session:compact:before, session:compact:after, session:patch
  • Agent events: agent:bootstrap
  • Gateway events: gateway:startup
  • Message events: message:received, message:sent

Gap

  • message:sent fires for every message chunk during streaming, not when the entire response is complete
  • No event exists for "agent finished responding" or "turn complete"

Proposed Solution

Add a new hook event:

agent:turn:complete

This event would fire when:

  • The agent has finished generating its response
  • All streaming content has been delivered
  • The turn is truly complete

Event Context

{
  type: 'agent',
  action: 'turn:complete',
  sessionKey: string,
  sessionId: string,
  timestamp: Date,
  context: {
    messageCount: number,      // Number of message chunks sent
    toolCalls: string[],       // List of tools called during the turn
    duration: number,          // Time taken for the turn (ms)
  }
}

Use Cases

  1. Task Completion Notification: Play a sound when the agent finishes a task
  2. Usage Tracking: Log turn completion for analytics
  3. Automation: Trigger follow-up actions when the agent is done
  4. Accessibility: Notify users who may not be watching the screen

Alternative Considered

I considered using message:sent, but this fires for every streaming chunk, not when the response is complete. This doesn't solve the use case.

Environment

  • OpenClaw version: 2026.4.1-beta.1
  • Platform: Windows

Thanks for considering this feature request!

extent analysis

TL;DR

Implementing a new hook event agent:turn:complete would allow for task completion notifications and other use cases that require detection of when an agent has finished responding.

Guidance

  • Review the proposed event context to ensure it meets the requirements for task completion notifications and other desired use cases.
  • Consider the potential impact of adding a new hook event on existing code and integrations.
  • Evaluate the feasibility of implementing the agent:turn:complete event in the current version of OpenClaw (2026.4.1-beta.1).
  • Discuss the proposal with the development team to determine the best approach for implementation.

Example

// Example event listener for the proposed agent:turn:complete event
const handleTurnComplete = (event: {
  type: 'agent',
  action: 'turn:complete',
  sessionKey: string,
  sessionId: string,
  timestamp: Date,
  context: {
    messageCount: number,
    toolCalls: string[],
    duration: number,
  },
}) => {
  // Play a sound or trigger other actions when the agent finishes a turn
  console.log('Agent turn complete:', event);
};

Notes

The implementation of the agent:turn:complete event may require significant changes to the underlying architecture of OpenClaw. It is essential to carefully evaluate the proposal and consider potential alternatives before proceeding.

Recommendation

Apply workaround: Implement a custom solution using existing events, such as message:sent, to approximate the desired behavior, while waiting for the agent:turn:complete event to be officially implemented. This approach allows for some functionality to be achieved, even if it's not ideal, until a more comprehensive solution is available.

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

openclaw - 💡(How to fix) Fix [Feature Request] Add agent:turn:complete hook event for notification/sound playback [1 participants]