← Back to PRs

#17017: feat(auto-reply): make agent time-aware with message timestamps

by liuy open 2026-02-15 09:53 View on GitHub →
size: XS
Add human-readable timestamp field to the Conversation info JSON block. **Before:** ```json { "conversation_label": "D id:123" } ``` **After:** ```json { "conversation_label": "D id:123", "timestamp": "Sun 2026-02-15 13:35 GMT+8" } ``` **Benefits:** - Better time awareness for time-related questions - Understand conversation gaps and response delays - Handle delayed message delivery - Context for relative time references ("just now", "later") Applies to all channels that provide message timestamps (Telegram, Discord, Slack, Signal, LINE, iMessage). **Testing:** - Build: passed - Check: passed - Test: passed <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds a human-readable `timestamp` field to the conversation info JSON block in `buildInboundUserContextPrefix`, giving the LLM agent time awareness when processing inbound messages. The timestamp is formatted as `"Sun 2026-02-15 13:35 GMT+8"` by combining a weekday from `Intl.DateTimeFormat` with the existing `formatZonedTimestamp` utility. - Input is properly guarded with `Number.isFinite()` before formatting, consistent with the pattern used elsewhere in `dispatch-from-config.ts` - The `Timestamp` field (milliseconds) is sourced from each channel adapter (Telegram, Slack, Discord, etc.) and flows through `TemplateContext` - Applies to all channels that populate `ctx.Timestamp`; gracefully produces `undefined` (omitted from JSON) when no timestamp is available - No new test coverage for the timestamp formatting path in `inbound-meta.test.ts` <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it adds a well-guarded, non-breaking field to an existing JSON block. - Single-file change with minimal surface area. The timestamp is properly validated with Number.isFinite() before use, formatZonedTimestamp already handles edge cases by returning undefined, and the new field is added to an existing object that already filters out undefined values. No breaking changes to existing behavior — existing tests remain valid since the timestamp field is omitted when not provided. - No files require special attention. <sub>Last reviewed commit: 3ef5349</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs