mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 07:11:39 +00:00
Agents: preserve bootstrap warning dedupe across followup runs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||
import { resolveBootstrapWarningSignaturesSeen } from "../../agents/bootstrap-budget.js";
|
||||
import { estimateMessagesTokens } from "../../agents/compaction.js";
|
||||
import { runWithModelFallback } from "../../agents/model-fallback.js";
|
||||
import { isCliProvider } from "../../agents/model-selection.js";
|
||||
@@ -452,6 +453,10 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
|
||||
let activeSessionEntry = entry ?? params.sessionEntry;
|
||||
const activeSessionStore = params.sessionStore;
|
||||
let bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(
|
||||
activeSessionEntry?.systemPromptReport ??
|
||||
(params.sessionKey ? activeSessionStore?.[params.sessionKey]?.systemPromptReport : undefined),
|
||||
);
|
||||
const flushRunId = crypto.randomUUID();
|
||||
if (params.sessionKey) {
|
||||
registerAgentRunContext(flushRunId, {
|
||||
@@ -469,7 +474,7 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
try {
|
||||
await runWithModelFallback({
|
||||
...resolveModelFallbackOptions(params.followupRun.run),
|
||||
run: (provider, model) => {
|
||||
run: async (provider, model) => {
|
||||
const { authProfile, embeddedContext, senderContext } = buildEmbeddedRunContexts({
|
||||
run: params.followupRun.run,
|
||||
sessionCtx: params.sessionCtx,
|
||||
@@ -483,7 +488,7 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
runId: flushRunId,
|
||||
authProfile,
|
||||
});
|
||||
return runEmbeddedPiAgent({
|
||||
const result = await runEmbeddedPiAgent({
|
||||
...embeddedContext,
|
||||
...senderContext,
|
||||
...runBaseParams,
|
||||
@@ -493,6 +498,9 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
cfg: params.cfg,
|
||||
}),
|
||||
extraSystemPrompt: flushSystemPrompt,
|
||||
bootstrapPromptWarningSignaturesSeen,
|
||||
bootstrapPromptWarningSignature:
|
||||
bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
||||
onAgentEvent: (evt) => {
|
||||
if (evt.stream === "compaction") {
|
||||
const phase = typeof evt.data.phase === "string" ? evt.data.phase : "";
|
||||
@@ -502,6 +510,10 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
}
|
||||
},
|
||||
});
|
||||
bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(
|
||||
result.meta?.systemPromptReport,
|
||||
);
|
||||
return result;
|
||||
},
|
||||
});
|
||||
let memoryFlushCompactionCount =
|
||||
|
||||
Reference in New Issue
Block a user