openclaw - 💡(How to fix) Fix Feature request: Add Gateway received timestamp to inbound metadata for accurate latency tracking [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#53678Fetched 2026-04-08 01:24:58
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Code Example

Message sent (source_timestamp)[35s long-poll wait]Gateway receives → Agent processes → Response sent

---

{
  "timestamp": "Tue 2026-03-24 20:41 GMT+8",  // Source channel timestamp
  "receivedAt": "Tue 2026-03-24 20:41:37.123 GMT+8"  // Gateway received timestamp
}
RAW_BUFFERClick to expand / collapse

Feature Request: Add Gateway Received Timestamp to Inbound Metadata

Problem

Currently, the inbound metadata only includes the message timestamp from the source channel (e.g., WeChat message timestamp). This makes it impossible to calculate accurate end-to-end processing latency.

For channels using long-polling (e.g., openclaw-weixin with 35s timeout), the current calculation current_time - source_timestamp includes the long-poll wait time, which is not the actual processing time.

Example Flow:

Message sent (source_timestamp) → [35s long-poll wait] → Gateway receives → Agent processes → Response sent

Current calculation measures: Response time - Message sent time = Includes long-poll wait

Desired Behavior

Add a new field to inbound metadata:

  • receivedAt (or gatewayReceivedAt): Timestamp when Gateway actually receives the message

Expected Inbound Metadata:

{
  "timestamp": "Tue 2026-03-24 20:41 GMT+8",  // Source channel timestamp
  "receivedAt": "Tue 2026-03-24 20:41:37.123 GMT+8"  // Gateway received timestamp
}

Then agents can calculate accurate latency:

  • Processing latency: response_time - receivedAt (actual agent processing time)
  • Channel latency: receivedAt - timestamp (channel delivery time, including long-poll wait)

Use Cases

  1. Performance monitoring: Track actual agent processing time
  2. Debugging: Identify bottlenecks (channel vs. agent)
  3. Channel comparison: Compare long-poll vs. WebSocket latency characteristics

Alternative Solutions

  1. Add processingStartedAt timestamp (when agent starts processing)
  2. Add both gatewayReceivedAt and agentProcessingStartedAt

Priority

Medium - Improves observability and user experience, especially for long-poll channels.

Additional Notes

  • This is particularly important for channels with long-poll timeouts (WeChat, etc.)
  • The timestamp format should be consistent (ISO 8601 with timezone)
  • Should work across all channel types (WebSocket, HTTP webhook, long-poll)

extent analysis

Fix Plan

To add the Gateway Received Timestamp to Inbound Metadata, follow these steps:

  • Update the gateway to capture the current timestamp when a message is received.
  • Add a new field receivedAt to the inbound metadata.
  • Ensure the timestamp format is consistent (ISO 8601 with timezone).

Example Code (Node.js)

// Assuming an Express.js server
const express = require('express');
const app = express();

// Middleware to capture received timestamp
app.use((req, res, next) => {
  req.metadata = {
    ...req.metadata,
    receivedAt: new Date().toISOString()
  };
  next();
});

// Example inbound metadata
const metadata = {
  timestamp: '2026-03-24T20:41:00.000Z',
  receivedAt: '2026-03-24T20:41:37.123Z'
};

Verification

To verify the fix, check the inbound metadata for the receivedAt field and ensure it matches the expected timestamp format. You can also test the calculation of processing latency and channel latency using the new receivedAt field.

Extra Tips

  • Ensure the gateway clock is synchronized with a reliable time source to maintain accurate timestamps.
  • Consider adding logging or monitoring to track any discrepancies between the receivedAt timestamp and the timestamp field.

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 Gateway received timestamp to inbound metadata for accurate latency tracking [1 participants]