Merge 8528ab61107b047263f20c5377cbc55116bb1b7e into 598f1826d8b2bc969aace2c6459824737667218c
This commit is contained in:
commit
82a30c9b6c
@ -190,6 +190,33 @@ describe("session_status tool", () => {
|
||||
expect(details.statusText).not.toContain("OAuth/token status");
|
||||
});
|
||||
|
||||
it("includes ISO-8601 and Unix timestamps for scheduling", async () => {
|
||||
loadSessionStoreMock.mockReset();
|
||||
updateSessionStoreMock.mockReset();
|
||||
loadSessionStoreMock.mockReturnValue({
|
||||
main: {
|
||||
sessionId: "s1",
|
||||
updatedAt: 10,
|
||||
},
|
||||
});
|
||||
|
||||
const tool = createOpenClawTools({ agentSessionKey: "main" }).find(
|
||||
(candidate) => candidate.name === "session_status",
|
||||
);
|
||||
expect(tool).toBeDefined();
|
||||
if (!tool) {
|
||||
throw new Error("missing session_status tool");
|
||||
}
|
||||
|
||||
const result = await tool.execute("call-time", {});
|
||||
const details = result.details as { ok?: boolean; statusText?: string };
|
||||
expect(details.ok).toBe(true);
|
||||
// ISO-8601 format: YYYY-MM-DDTHH:MM:SS.sssZ
|
||||
expect(details.statusText).toMatch(/ISO-8601: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);
|
||||
// Unix timestamp (seconds since epoch)
|
||||
expect(details.statusText).toMatch(/Unix: \d+/);
|
||||
});
|
||||
|
||||
it("errors for unknown session keys", async () => {
|
||||
resetSessionStore({
|
||||
main: { sessionId: "s1", updatedAt: 10 },
|
||||
|
||||
@ -390,7 +390,7 @@ describe("buildAgentSystemPrompt", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("hints to use session_status for current date/time", () => {
|
||||
it("hints to use session_status for current date/time with scheduling formats", () => {
|
||||
const prompt = buildAgentSystemPrompt({
|
||||
workspaceDir: "/tmp/clawd",
|
||||
userTimezone: "America/Chicago",
|
||||
@ -398,6 +398,9 @@ describe("buildAgentSystemPrompt", () => {
|
||||
|
||||
expect(prompt).toContain("session_status");
|
||||
expect(prompt).toContain("current date");
|
||||
expect(prompt).toContain("ISO-8601");
|
||||
expect(prompt).toContain("Unix");
|
||||
expect(prompt).toContain("scheduling");
|
||||
});
|
||||
|
||||
// The system prompt intentionally does NOT include the current date/time.
|
||||
|
||||
@ -506,7 +506,7 @@ export function buildAgentSystemPrompt(params: {
|
||||
: "",
|
||||
params.modelAliasLines && params.modelAliasLines.length > 0 && !isMinimal ? "" : "",
|
||||
userTimezone
|
||||
? "If you need the current date, time, or day of week, run session_status (📊 session_status)."
|
||||
? "If you need current date, time, or day of week (includes ISO-8601 and Unix for scheduling), run session_status (📊 session_status)."
|
||||
: "",
|
||||
"## Workspace",
|
||||
`Your working directory is: ${displayWorkspaceDir}`,
|
||||
|
||||
@ -413,10 +413,13 @@ export function createSessionStatusTool(opts?: {
|
||||
|
||||
const userTimezone = resolveUserTimezone(cfg.agents?.defaults?.userTimezone);
|
||||
const userTimeFormat = resolveUserTimeFormat(cfg.agents?.defaults?.timeFormat);
|
||||
const userTime = formatUserTime(new Date(), userTimezone, userTimeFormat);
|
||||
const now = new Date();
|
||||
const userTime = formatUserTime(now, userTimezone, userTimeFormat);
|
||||
const iso = now.toISOString();
|
||||
const unix = Math.floor(now.getTime() / 1000);
|
||||
const timeLine = userTime
|
||||
? `🕒 Time: ${userTime} (${userTimezone})`
|
||||
: `🕒 Time zone: ${userTimezone}`;
|
||||
? `🕒 Time: ${userTime} (${userTimezone})\n ISO-8601: ${iso} | Unix: ${unix}`
|
||||
: `🕒 Time zone: ${userTimezone}\n ISO-8601: ${iso} | Unix: ${unix}`;
|
||||
|
||||
const agentDefaults = cfg.agents?.defaults ?? {};
|
||||
const defaultLabel = `${configured.provider}/${configured.model}`;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user