fix: recover from compaction overflow

This commit is contained in:
Peter Steinberger
2026-01-13 08:02:58 +00:00
parent 365cbe8d50
commit 9faa95d558
5 changed files with 87 additions and 5 deletions

View File

@@ -370,8 +370,8 @@ export function formatAssistantErrorText(
// Check for context overflow (413) errors
if (isContextOverflowError(raw)) {
return (
"Context overflow: the conversation history is too large. " +
"Use /new or /reset to start a fresh session."
"Context overflow: prompt too large for the model. " +
"Try again with less input or a larger-context model."
);
}

View File

@@ -362,6 +362,10 @@ export type EmbeddedPiRunMeta = {
durationMs: number;
agentMeta?: EmbeddedPiAgentMeta;
aborted?: boolean;
error?: {
kind: "context_overflow" | "compaction_failure";
message: string;
};
};
function buildModelAliasLines(cfg?: ClawdbotConfig) {
@@ -1976,12 +1980,15 @@ export async function runEmbeddedPiAgent(params: {
if (promptError && !aborted) {
const errorText = describeUnknownError(promptError);
if (isContextOverflowError(errorText)) {
const kind = isCompactionFailureError(errorText)
? "compaction_failure"
: "context_overflow";
return {
payloads: [
{
text:
"Context overflow: the conversation history is too large for the model. " +
"Use /new or /reset to start a fresh session, or try a model with a larger context window.",
"Context overflow: prompt too large for the model. " +
"Try again with less input or a larger-context model.",
isError: true,
},
],
@@ -1992,6 +1999,7 @@ export async function runEmbeddedPiAgent(params: {
provider,
model: model.id,
},
error: { kind, message: errorText },
},
};
}