Skip to content

Comments

fix(agent): emit assistant events for webchat message content#27

Closed
Nachx639 wants to merge 2 commits intoopenclaw:mainfrom
Nachx639:fix/webchat-agent-events
Closed

fix(agent): emit assistant events for webchat message content#27
Nachx639 wants to merge 2 commits intoopenclaw:mainfrom
Nachx639:fix/webchat-agent-events

Conversation

@Nachx639
Copy link
Contributor

Summary

  • Fix webchat receiving empty messages by passing onAgentEvent callback to runCommandReply in agentCommand

Problem

The webchat was showing "chat timed out" or empty responses because:

  1. agentCommand calls runCommandReply but didn't pass the onAgentEvent callback
  2. Without this callback, assistant text events (stream: "assistant") were never emitted
  3. The gateway accumulates assistant text in chatRunBuffers and includes it in the chat event with state: "final"
  4. Since no assistant events were emitted, the buffer was empty and message was undefined

Solution

Pass onAgentEvent to runCommandReply so that assistant stream events are properly emitted:

onAgentEvent: (evt) => {
  emitAgentEvent({
    runId: sessionId,
    stream: evt.stream,
    data: evt.data,
  });
},

Test plan

  • Send message via webchat → response now shows correctly
  • WhatsApp continues to work as before

🤖 Generated with Claude Code

contributor and others added 2 commits December 13, 2025 22:53
The webchat was receiving empty messages because agentCommand didn't pass
the onAgentEvent callback to runCommandReply. This caused assistant text
events to never be emitted, resulting in the gateway broadcasting chat
events with no message content.

This fix passes onAgentEvent to runCommandReply so that assistant stream
events are properly emitted and the webchat receives the actual response text.

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <[email protected]>
The webchat sends an idempotencyKey with chat.send requests and expects
events to arrive with that same runId. Previously, the gateway was using
the internal sessionId as runId, causing a mismatch that prevented the
webchat from correlating responses with pending requests.

Changes:
- chatRunSessions now stores {sessionKey, clientRunId} instead of just sessionKey
- Chat events use clientRunId so webchat can match them to pending promises
- Response payload includes the original clientRunId from idempotencyKey

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@Nachx639 Nachx639 force-pushed the fix/webchat-agent-events branch from 520bd0a to ead932f Compare December 13, 2025 21:53
@steipete
Copy link
Contributor

Appreciate the fix! I went all choa-monkey on this while working on 2.0, so this was fixed without reviewing the PR in time.
Once the project stabilizes a bit I'll defo be better - thanks for the effort and testing!

@steipete steipete closed this Dec 14, 2025
dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 2, 2026
…ategories

feat(ui): add category filtering to command palette
alexprime1889-prog pushed a commit to alexprime1889-prog/moltbot that referenced this pull request Feb 8, 2026
centminmod added a commit to centminmod/clawdbot that referenced this pull request Feb 9, 2026
frodo-harborbot pushed a commit to harborworks/openclaw that referenced this pull request Feb 16, 2026
Navbar, admin panel, and CRUD for users/orgs/members/harbors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants