refactor(agents): trim soft resume drift note

This commit is contained in:
Ayaan Zaidi
2026-07-03 19:45:18 -07:00
parent b332918a22
commit ab93415c8b
2 changed files with 5 additions and 33 deletions
-1
View File
@@ -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 });
+5 -32
View File
@@ -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,