From ab93415c8bd354fbdd7b8e7db76d96ec954d896d Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Fri, 3 Jul 2026 19:45:18 -0700 Subject: [PATCH] refactor(agents): trim soft resume drift note --- src/agents/cli-runner/prepare.test.ts | 1 - src/agents/cli-runner/prepare.ts | 37 ++++----------------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/agents/cli-runner/prepare.test.ts b/src/agents/cli-runner/prepare.test.ts index aa176f6ff489..88f71081b11c 100644 --- a/src/agents/cli-runner/prepare.test.ts +++ b/src/agents/cli-runner/prepare.test.ts @@ -2053,7 +2053,6 @@ describe("shouldSkipLocalCliCredentialEpoch", () => { "OpenClaw resumed this CLI session after prompt content changed.", ); expect(context.params.prompt).toContain("changed=system-prompt"); - expect(context.params.prompt).toContain("Current session context:\nnew stable prompt"); expect(context.params.prompt).toContain("latest ask"); } finally { fs.rmSync(dir, { recursive: true, force: true }); diff --git a/src/agents/cli-runner/prepare.ts b/src/agents/cli-runner/prepare.ts index 9b84a8685abc..60ad06c3ac80 100644 --- a/src/agents/cli-runner/prepare.ts +++ b/src/agents/cli-runner/prepare.ts @@ -134,43 +134,20 @@ function canApplySystemPromptOnResume(backend: CliBackendConfig): boolean { ); } -function buildCliSessionDriftUserContext(params: { - reusableCliSession: CliReusableSession; - extraSystemPrompt: string; - promptToolNames: string[]; -}): string | undefined { - const { reusableCliSession } = params; +function buildCliSessionDriftUserContext( + reusableCliSession: CliReusableSession, +): string | undefined { if (reusableCliSession.mode !== "reuse-with-drift") { return undefined; } - const lines = [ - `OpenClaw resumed this CLI session after prompt content changed. Follow the current turn's instructions; changed=${reusableCliSession.drift.reasons.join(",")}.`, - ]; - if (reusableCliSession.drift.reasons.includes("system-prompt") && params.extraSystemPrompt) { - lines.push(`Current session context:\n${params.extraSystemPrompt}`); - } - if (reusableCliSession.drift.reasons.includes("prompt-tools")) { - lines.push( - `Current prompt tool surface: ${ - params.promptToolNames.length > 0 ? params.promptToolNames.join(", ") : "none" - }`, - ); - } - return lines.join("\n\n"); + return `OpenClaw resumed this CLI session after prompt content changed. Follow the current turn's instructions; changed=${reusableCliSession.drift.reasons.join(",")}.`; } function prependCliSessionDriftUserContext( context: RunCliAgentParams["currentInboundContext"], reusableCliSession: CliReusableSession, - driftContext: { - extraSystemPrompt: string; - promptToolNames: string[]; - }, ): RunCliAgentParams["currentInboundContext"] { - const note = buildCliSessionDriftUserContext({ - reusableCliSession, - ...driftContext, - }); + const note = buildCliSessionDriftUserContext(reusableCliSession); if (!note) { return context; } @@ -889,10 +866,6 @@ export async function prepareCliRunContext( const currentInboundContext = prependCliSessionDriftUserContext( params.currentInboundContext, reusableCliSession, - { - extraSystemPrompt, - promptToolNames: promptTools.map((tool) => tool.name).toSorted(), - }, ); const fullCurrentInboundPrompt = buildCurrentInboundPrompt({ context: currentInboundContext,