Skip to content

Commit 071f4eb

Browse files
connermoclaude
andcommitted
fix(status): return current time from session_status and harden time-hint prompt
The session_status status card had a timeLine render slot that was never populated, so the model was told to call session_status for the date/time yet got none back and would guess (time hallucination). Derive the live Current time line from now + config timezone in buildStatusMessage so both the /status command and session_status tool surface it, and strengthen the system-prompt hint to forbid guessing the current time. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 1d9fb27 commit 071f4eb

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/agents/system-prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ export function buildAgentSystemPrompt(params: {
11521152
: "",
11531153
params.modelAliasLines && params.modelAliasLines.length > 0 && !isMinimal ? "" : "",
11541154
userTimezone
1155-
? "If you need the current date, time, or day of week, run session_status (📊 session_status)."
1155+
? "Never assume or guess the current date, time, or day of week; your training data is stale. Whenever anything depends on the present moment (scheduling, deadlines, age/elapsed math, or words like today/now/tomorrow/this week), first run session_status (📊 session_status) and use its `Current time` value."
11561156
: "",
11571157
"## Workspace",
11581158
`Your working directory is: ${displayWorkspaceDir}`,

src/status/status-message.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ afterEach(() => {
2020
cliBackendsTesting.resetDepsForTest();
2121
});
2222

23+
describe("buildStatusMessage current time", () => {
24+
it("surfaces a live current-time line so session_status returns the date/time", () => {
25+
// 2025-07-03T08:00:00Z; the Reference UTC line is timezone-independent.
26+
const now = 1_751_529_600_000;
27+
const text = buildStatusMessage({
28+
now,
29+
config: { agents: { defaults: { userTimezone: "UTC", timeFormat: "24" } } },
30+
agent: { model: "anthropic/claude-haiku-4-5" },
31+
sessionKey: "agent:main:main",
32+
sessionScope: "per-sender",
33+
queue: { mode: "steer", depth: 0 },
34+
modelAuth: "api-key",
35+
});
36+
37+
expect(text).toContain("Current time:");
38+
expect(text).toContain("(UTC)");
39+
expect(text).toContain("Reference UTC: 2025-07-03 08:00 UTC");
40+
});
41+
});
42+
2343
describe("buildStatusMessage context window", () => {
2444
it("ignores stale runtime context after a manual session model switch", () => {
2545
const text = buildStatusMessage({

src/status/status-message.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
normalizeOptionalString,
88
} from "@openclaw/normalization-core/string-coerce";
99
import { resolveContextTokensForModel } from "../agents/context.js";
10+
import { resolveCronStyleNow } from "../agents/current-time.js";
1011
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
1112
import { resolveExtraParams } from "../agents/embedded-agent-runner/extra-params.js";
1213
import { resolveFastModeState } from "../agents/fast-mode.js";
@@ -563,6 +564,12 @@ function hasUserPinnedModelSelection(entry: SessionEntry | undefined): boolean {
563564

564565
export function buildStatusMessage(args: StatusArgs): string {
565566
const now = args.now ?? Date.now();
567+
// Live wall-clock line for the status card. The field/render slot existed but
568+
// was never populated, so the model (told to call session_status for the date/
569+
// time) got none back and would guess. Derive from `now` + config timezone so
570+
// every render path (/status command and session_status tool) surfaces it.
571+
const timeLine =
572+
args.timeLine ?? (args.config ? resolveCronStyleNow(args.config, now).timeLine : undefined);
566573
const entry = args.sessionEntry;
567574
const selectionConfig = {
568575
agents: {
@@ -1113,7 +1120,7 @@ export function buildStatusMessage(args: StatusArgs): string {
11131120

11141121
return [
11151122
versionLine,
1116-
args.timeLine,
1123+
timeLine,
11171124
args.uptimeLine,
11181125
...modelLines,
11191126
configuredFallbacksLine,

0 commit comments

Comments
 (0)