fix: suggest /clear in context overflow error message (#12973)

* fix: suggest /reset in context overflow error message

When the context window overflows, the error message now suggests
using /reset to clear session history, giving users an actionable
recovery path instead of a dead-end error.

Closes #12940

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: suggest /reset in context overflow error message (#12973) (thanks @RamiNoodle733)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Rami Abdelrazzaq <RamiNoodle733@users.noreply.github.com>
This commit is contained in:
Rami Abdelrazzaq
2026-02-09 20:44:37 -06:00
committed by GitHub
parent 33ee8bbf1d
commit c2b2d535fb
3 changed files with 5 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ describe("sanitizeUserFacingText", () => {
it("sanitizes direct context-overflow errors", () => {
expect(
sanitizeUserFacingText(
"Context overflow: prompt too large for the model. Try again with less input or a larger-context model.",
"Context overflow: prompt too large for the model. Try /reset (or /new) to start a fresh session, or use a larger-context model.",
{ errorContext: true },
),
).toContain("Context overflow: prompt too large for the model.");
@@ -37,7 +37,7 @@ describe("sanitizeUserFacingText", () => {
it("does not swallow assistant text that quotes the canonical context-overflow string", () => {
const text =
"Changelog note: we fixed false positives for `Context overflow: prompt too large for the model. Try again with less input or a larger-context model.` in 2026.2.9";
"Changelog note: we fixed false positives for `Context overflow: prompt too large for the model. Try /reset (or /new) to start a fresh session, or use a larger-context model.` in 2026.2.9";
expect(sanitizeUserFacingText(text)).toBe(text);
});

View File

@@ -354,7 +354,7 @@ export function formatAssistantErrorText(
if (isContextOverflowError(raw)) {
return (
"Context overflow: prompt too large for the model. " +
"Try again with less input or a larger-context model."
"Try /reset (or /new) to start a fresh session, or use a larger-context model."
);
}
@@ -426,7 +426,7 @@ export function sanitizeUserFacingText(text: string, opts?: { errorContext?: boo
if (shouldRewriteContextOverflowText(trimmed)) {
return (
"Context overflow: prompt too large for the model. " +
"Try again with less input or a larger-context model."
"Try /reset (or /new) to start a fresh session, or use a larger-context model."
);
}

View File

@@ -580,7 +580,7 @@ export async function runEmbeddedPiAgent(
{
text:
"Context overflow: prompt too large for the model. " +
"Try again with less input or a larger-context model.",
"Try /reset (or /new) to start a fresh session, or use a larger-context model.",
isError: true,
},
],