From 3696532f040d7bca49dd5637828bbb5063af030e Mon Sep 17 00:00:00 2001 From: Conroy Whitney Date: Wed, 28 Jan 2026 21:34:53 -0500 Subject: [PATCH] feat(gateway): inject timestamps into chat.send (webchat/TUI) The chat.send handler (used by webchat and TUI) is a separate path from the agent handler. Inject timestamp into BodyForAgent (what the model sees) while keeping Body raw for UI display. This completes timestamp coverage for all non-channel paths: - agent handler: spawned subagents, sessions_send, heartbeats - chat.send: webchat, TUI --- src/gateway/server-methods/chat.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gateway/server-methods/chat.ts b/src/gateway/server-methods/chat.ts index 9010a6f21..53a992d3d 100644 --- a/src/gateway/server-methods/chat.ts +++ b/src/gateway/server-methods/chat.ts @@ -5,6 +5,7 @@ import path from "node:path"; import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent"; import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { resolveEffectiveMessagesConfig, resolveIdentityName } from "../../agents/identity.js"; +import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; import { resolveThinkingDefault } from "../../agents/model-selection.js"; import { resolveAgentTimeoutMs } from "../../agents/timeout.js"; import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; @@ -443,9 +444,14 @@ export const chatHandlers: GatewayRequestHandlers = { ); const commandBody = injectThinking ? `/think ${p.thinking} ${parsedMessage}` : parsedMessage; const clientInfo = client?.connect?.client; + // Inject timestamp so agents know the current date/time. + // Only BodyForAgent gets the timestamp — Body stays raw for UI display. + // See: https://github.com/moltbot/moltbot/issues/3658 + const stampedMessage = injectTimestamp(parsedMessage, timestampOptsFromConfig(cfg)); + const ctx: MsgContext = { Body: parsedMessage, - BodyForAgent: parsedMessage, + BodyForAgent: stampedMessage, BodyForCommands: commandBody, RawBody: parsedMessage, CommandBody: commandBody,