fix: substitute YYYY-MM-DD at session startup and post-compaction (#32363) (#32381)

Merged via squash.

Prepared head SHA: aee998a2c1
Co-authored-by: chengzhichao-xydt <264300353+chengzhichao-xydt@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
chengzhichao-xydt
2026-03-03 22:21:26 +08:00
committed by GitHub
parent 3fe4c19305
commit 53727c72f4
10 changed files with 140 additions and 13 deletions

View File

@@ -525,8 +525,13 @@ describe("gateway agent handler", () => {
{ reqId: "4" },
);
const call = await expectResetCall(BARE_SESSION_RESET_PROMPT);
await vi.waitFor(() => expect(mocks.agentCommand).toHaveBeenCalled());
expect(mocks.sessionsResetHandler).toHaveBeenCalledTimes(1);
const call = readLastAgentCommandCall();
// Message is now dynamically built with current date — check key substrings
expect(call?.message).toContain("Execute your Session Startup sequence now");
expect(call?.message).toContain("Current time:");
expect(call?.message).not.toBe(BARE_SESSION_RESET_PROMPT);
expect(call?.sessionId).toBe("reset-session-id");
});

View File

@@ -1,7 +1,7 @@
import { randomUUID } from "node:crypto";
import { listAgentIds } from "../../agents/agent-scope.js";
import type { AgentInternalEvent } from "../../agents/internal-events.js";
import { BARE_SESSION_RESET_PROMPT } from "../../auto-reply/reply/session-reset-prompt.js";
import { buildBareSessionResetPrompt } from "../../auto-reply/reply/session-reset-prompt.js";
import { agentCommandFromIngress } from "../../commands/agent.js";
import { loadConfig } from "../../config/config.js";
import {
@@ -351,7 +351,9 @@ export const agentHandlers: GatewayRequestHandlers = {
} else {
// Keep bare /new and /reset behavior aligned with chat.send:
// reset first, then run a fresh-session greeting prompt in-place.
message = BARE_SESSION_RESET_PROMPT;
// Date is embedded in the prompt so agents read the correct daily
// memory files; skip further timestamp injection to avoid duplication.
message = buildBareSessionResetPrompt(cfg);
skipTimestampInjection = true;
}
}