mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 16:03:43 +00:00
Agent: unify bootstrap truncation warning handling (#32769)
Merged via squash.
Prepared head SHA: 5d6d4ddfa6
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
3ad3a90db3
commit
e4b4486a96
@@ -651,6 +651,9 @@ export async function runEmbeddedPiAgent(
|
||||
const MAX_RUN_LOOP_ITERATIONS = resolveMaxRunRetryIterations(profileCandidates.length);
|
||||
let overflowCompactionAttempts = 0;
|
||||
let toolResultTruncationAttempted = false;
|
||||
let bootstrapPromptWarningSignaturesSeen =
|
||||
params.bootstrapPromptWarningSignaturesSeen ??
|
||||
(params.bootstrapPromptWarningSignature ? [params.bootstrapPromptWarningSignature] : []);
|
||||
const usageAccumulator = createUsageAccumulator();
|
||||
let lastRunPromptUsage: ReturnType<typeof normalizeUsage> | undefined;
|
||||
let autoCompactionCount = 0;
|
||||
@@ -774,6 +777,9 @@ export async function runEmbeddedPiAgent(
|
||||
streamParams: params.streamParams,
|
||||
ownerNumbers: params.ownerNumbers,
|
||||
enforceFinalTag: params.enforceFinalTag,
|
||||
bootstrapPromptWarningSignaturesSeen,
|
||||
bootstrapPromptWarningSignature:
|
||||
bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -784,6 +790,16 @@ export async function runEmbeddedPiAgent(
|
||||
sessionIdUsed,
|
||||
lastAssistant,
|
||||
} = attempt;
|
||||
bootstrapPromptWarningSignaturesSeen =
|
||||
attempt.bootstrapPromptWarningSignaturesSeen ??
|
||||
(attempt.bootstrapPromptWarningSignature
|
||||
? Array.from(
|
||||
new Set([
|
||||
...bootstrapPromptWarningSignaturesSeen,
|
||||
attempt.bootstrapPromptWarningSignature,
|
||||
]),
|
||||
)
|
||||
: bootstrapPromptWarningSignaturesSeen);
|
||||
const lastAssistantUsage = normalizeUsage(lastAssistant?.usage as UsageLike);
|
||||
const attemptUsage = attempt.attemptUsage ?? lastAssistantUsage;
|
||||
mergeUsageIntoAccumulator(usageAccumulator, attemptUsage);
|
||||
|
||||
Reference in New Issue
Block a user