From f2de7aa10881b358c74cf464792523975fe33286 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 16 Jan 2026 06:02:30 +0000 Subject: [PATCH] fix: improve reminder context plumbing (#993) (thanks @cpojer) --- CHANGELOG.md | 1 + src/agents/clawdbot-tools.ts | 1 + src/agents/tools/cron-tool.test.ts | 2 +- src/agents/tools/cron-tool.ts | 7 +++++-- ...r.runs-legacy-state-migrations-yes-mode-without.test.ts | 2 +- ...or.warns-per-agent-sandbox-docker-browser-prune.test.ts | 2 +- .../doctor.warns-state-directory-is-missing.test.ts | 2 +- src/commands/sandbox-explain.test.ts | 2 +- 8 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dff875b75..21ef55c3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Docs: clarify multi-gateway rescue bot guidance. (#969) — thanks @bjesuiter. - Agents: add Current Date & Time system prompt section with configurable time format (auto/12/24). - Agents: avoid false positives when logging unsupported Google tool schema keywords. +- Agents: include recent context in reminder cron payloads. (#993) — thanks @cpojer. - Status: restore usage summary line for current provider when no OAuth profiles exist. - Tools: normalize Slack/Discord message timestamps with `timestampMs`/`timestampUtc` while keeping raw provider fields. - Docs: add Date & Time guide and update prompt/timezone configuration docs. diff --git a/src/agents/clawdbot-tools.ts b/src/agents/clawdbot-tools.ts index 28e71bf19..fde14b6ab 100644 --- a/src/agents/clawdbot-tools.ts +++ b/src/agents/clawdbot-tools.ts @@ -77,6 +77,7 @@ export function createClawdbotTools(options?: { createNodesTool(), createCronTool({ agentSessionKey: options?.agentSessionKey, + config: options?.config, }), createMessageTool({ agentAccountId: options?.agentAccountId, diff --git a/src/agents/tools/cron-tool.test.ts b/src/agents/tools/cron-tool.test.ts index b162ce41a..1bc5d934d 100644 --- a/src/agents/tools/cron-tool.test.ts +++ b/src/agents/tools/cron-tool.test.ts @@ -99,7 +99,7 @@ describe("cron tool", () => { }) .mockResolvedValueOnce({ ok: true }); - const tool = createCronTool({ agentSessionKey: "main" }); + const tool = createCronTool({ agentSessionKey: "main", config: {} }); await tool.execute("call3", { action: "add", job: { diff --git a/src/agents/tools/cron-tool.ts b/src/agents/tools/cron-tool.ts index 75af0becd..663e336d4 100644 --- a/src/agents/tools/cron-tool.ts +++ b/src/agents/tools/cron-tool.ts @@ -1,6 +1,6 @@ import { Type } from "@sinclair/typebox"; import { normalizeCronJobCreate, normalizeCronJobPatch } from "../../cron/normalize.js"; -import { loadConfig } from "../../config/config.js"; +import { loadConfig, type ClawdbotConfig } from "../../config/config.js"; import { truncateUtf16Safe } from "../../utils.js"; import { optionalStringEnum, stringEnum } from "../schema/typebox.js"; import { type AnyAgentTool, jsonResult, readStringParam } from "./common.js"; @@ -38,6 +38,7 @@ const CronToolSchema = Type.Object({ type CronToolOptions = { agentSessionKey?: string; + config?: ClawdbotConfig; }; type ChatMessage = { @@ -86,10 +87,11 @@ function extractMessageText(message: ChatMessage): { role: string; text: string async function buildReminderContextLines(params: { agentSessionKey?: string; gatewayOpts: GatewayCallOptions; + config?: ClawdbotConfig; }) { const sessionKey = params.agentSessionKey?.trim(); if (!sessionKey) return []; - const cfg = loadConfig(); + const cfg = params.config ?? loadConfig(); const { mainKey, alias } = resolveMainSessionAlias(cfg); const resolvedKey = resolveInternalSessionKey({ key: sessionKey, alias, mainKey }); try { @@ -160,6 +162,7 @@ export function createCronTool(opts?: CronToolOptions): AnyAgentTool { const contextLines = await buildReminderContextLines({ agentSessionKey: opts?.agentSessionKey, gatewayOpts, + config: opts?.config, }); if (contextLines.length > 0) { const baseText = stripExistingContext(payload.text); diff --git a/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.test.ts b/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.test.ts index c00121a6d..48f944c22 100644 --- a/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.test.ts +++ b/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.test.ts @@ -374,7 +374,7 @@ describe("doctor command", () => { expect(runLegacyStateMigrations).toHaveBeenCalledTimes(1); expect(confirm).not.toHaveBeenCalled(); - }, 20_000); + }); it("skips gateway restarts in non-interactive mode", async () => { readConfigFileSnapshot.mockResolvedValue({ diff --git a/src/commands/doctor.warns-per-agent-sandbox-docker-browser-prune.test.ts b/src/commands/doctor.warns-per-agent-sandbox-docker-browser-prune.test.ts index a88e5e316..3e848ddfc 100644 --- a/src/commands/doctor.warns-per-agent-sandbox-docker-browser-prune.test.ts +++ b/src/commands/doctor.warns-per-agent-sandbox-docker-browser-prune.test.ts @@ -372,7 +372,7 @@ describe("doctor command", () => { ); }), ).toBe(true); - }, 10_000); + }); it("warns when extra workspace directories exist", async () => { readConfigFileSnapshot.mockResolvedValue({ diff --git a/src/commands/doctor.warns-state-directory-is-missing.test.ts b/src/commands/doctor.warns-state-directory-is-missing.test.ts index dfaa40181..cef390196 100644 --- a/src/commands/doctor.warns-state-directory-is-missing.test.ts +++ b/src/commands/doctor.warns-state-directory-is-missing.test.ts @@ -343,7 +343,7 @@ describe("doctor command", () => { const stateNote = note.mock.calls.find((call) => call[1] === "State integrity"); expect(stateNote).toBeTruthy(); expect(String(stateNote?.[0])).toContain("CRITICAL"); - }, 20_000); + }); it("warns about opencode provider overrides", async () => { readConfigFileSnapshot.mockResolvedValue({ diff --git a/src/commands/sandbox-explain.test.ts b/src/commands/sandbox-explain.test.ts index d3e5ea2ee..3fec0f172 100644 --- a/src/commands/sandbox-explain.test.ts +++ b/src/commands/sandbox-explain.test.ts @@ -42,5 +42,5 @@ describe("sandbox explain command", () => { expect(Array.isArray(parsed.fixIt)).toBe(true); expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off"); expect(parsed.fixIt).toContain("tools.sandbox.tools.deny"); - }, 15_000); + }); });