fix(agent): inject Shanghai time into each reply message

103 goosed harness_remember returns remembered:false, so session memory
never carried the time anchor. Prepend buildCurrentTimeAgentPrefix on every
H5 /reply and WeChat agent prompt so the model sees Asia/Shanghai clock.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-01 08:40:27 +08:00
parent 75e5a56b86
commit de5fab370c
5 changed files with 59 additions and 11 deletions
+7 -3
View File
@@ -6,8 +6,8 @@ import { developerToolsFromPolicy } from './capabilities.mjs';
import { mergeMessageContent } from './message-stream.mjs';
import { reconcileAgentSession } from './session-reconcile.mjs';
import { isScheduleIntent, parseScheduleIntent, shouldUseScheduleAssistant } from './schedule-intent.mjs';
import { renderCurrentTimeAnchor } from './user-memory-profile.mjs';
import { materializeMissingPublicHtmlWrites } from './mindspace-public-finish-sync.mjs';
import { buildCurrentTimeAgentPrefix } from './user-memory-profile.mjs';
import { PUBLISH_ROOT_DIR } from './user-publish.mjs';
import { downloadTemporaryMedia, persistWechatImage } from './wechat-media.mjs';
import { buildAckText } from './wechat/ack/ack-provider.mjs';
@@ -1098,12 +1098,12 @@ export function buildWechatAgentPrompt(intent) {
].join('\n')
: '';
const scheduleTimezone = process.env.H5_DEFAULT_TIMEZONE || 'Asia/Shanghai';
const currentTimeHint = buildCurrentTimeAgentPrefix({ timezone: scheduleTimezone });
const scheduleAssistantHint = shouldUseScheduleAssistant(intent?.agentText ?? intent?.content)
? [
'【日程技能要求】这条消息涉及待办、提醒或日程。',
'开始前先加载 `schedule-assistant` skill,并严格按 skill 里的边界执行。',
'写入工具时优先使用 startLocal / endLocal / remindLocalYYYY-MM-DD HH:mm),不要自行估算 Unix 毫秒。',
renderCurrentTimeAnchor({ timezone: scheduleTimezone }),
'只有在 `schedule_create_item` / `schedule_create_reminder` 等工具成功返回后,才能告诉用户“已经设置好了”。',
intent?.msgId ? `调用 schedule_create_item 时必须传入 sourceMessageId: ${intent.msgId}` : '',
'',
@@ -1112,6 +1112,7 @@ export function buildWechatAgentPrompt(intent) {
if (msgType === 'voice') {
return [
docxDownloadHint,
currentTimeHint,
scheduleAssistantHint,
'【微信服务号语音消息】用户通过语音输入,以下是微信识别结果。',
'',
@@ -1123,6 +1124,7 @@ export function buildWechatAgentPrompt(intent) {
if (msgType === 'image') {
return [
docxDownloadHint,
currentTimeHint,
scheduleAssistantHint,
'【微信服务号图片消息】用户发送了图片。',
'如用户没有明确要求,请先根据图片内容给出简短理解,并询问下一步。',
@@ -1135,6 +1137,7 @@ export function buildWechatAgentPrompt(intent) {
if (msgType === 'location') {
const location = intent?.location ?? {};
return [
currentTimeHint,
scheduleAssistantHint,
'【微信服务号位置消息】用户发送了当前位置。',
location.label ? `地址:${location.label}` : '',
@@ -1152,6 +1155,7 @@ export function buildWechatAgentPrompt(intent) {
if (msgType === 'link') {
const link = intent?.link ?? {};
return [
currentTimeHint,
scheduleAssistantHint,
'【微信服务号链接消息】用户分享了链接。',
link.title ? `标题:${link.title}` : '',
@@ -1162,7 +1166,7 @@ export function buildWechatAgentPrompt(intent) {
.join('\n');
}
const content = String(intent?.agentText ?? intent?.content ?? '').trim();
const lines = [];
const lines = [currentTimeHint];
if (docxDownloadHint) lines.push(docxDownloadHint);
if (pagePublishHint) lines.push(pagePublishHint);
if (scheduleAssistantHint) lines.push(scheduleAssistantHint);