Skip to content

bug: most traces show 0ms duration — inbound/outbound correlation failing #12

@maxdraki

Description

@maxdraki

Problem

The majority of traces show 0ms duration. A small number show correct durations (18.3s, 78.6m etc). The 0ms traces mean a message:sent event fired with no matching entry in pendingConversations.

Root causes (likely multiple)

1. Heartbeat SKIP filter asymmetry

handler.ts skips message:received events matching /^Read HEARTBEAT\.md/ etc., but the subsequent message:sent (the HEARTBEAT_OK reply) still fires and tries to correlate — finding nothing, producing a 0ms trace.

Fix: also check SKIP on message:sent, or remove the pending entry on skip.

2. conversationId mismatch between receive and sent

If OpenClaw uses a different conversationId on the outbound event than the inbound (e.g. the reply gets a new ID), correlation fails. The sessionKey fallback in index.ts was added for webchat (#8) but handler.ts uses conversationId directly.

Fix: mirror the correlationKey() helper from index.ts into handler.ts — prefer conversationId, fall back to sessionKey.

3. System/gateway messages with no inbound pair

Announcements, cron outputs, proactive WhatsApp messages — these are outbound-only with no corresponding inbound event.

Fix: these are expected; filter them from the Traces view or mark them as type: outbound-only.

Suggested fix priority

  1. Port correlationKey() fallback to handler.ts
  2. Add SKIP check to the message:sent branch
  3. Consider suppressing 0ms traces from the main Traces view (or show with a distinct label)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions