fix(session): prevent silent overflow on parent thread forks (#26912)

Lands #26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates.

Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-02-25 23:53:43 +00:00
parent 8d1481cb4a
commit eb73e87f18
11 changed files with 211 additions and 14 deletions

View File

@@ -572,6 +572,22 @@ export async function runAgentTurnWithFallback(params: {
}
}
// If the run completed but with an embedded context overflow error that
// wasn't recovered from (e.g. compaction reset already attempted), surface
// the error to the user instead of silently returning an empty response.
// See #26905: Slack DM sessions silently swallowed messages when context
// overflow errors were returned as embedded error payloads.
const finalEmbeddedError = runResult?.meta?.error;
const hasPayloadText = runResult?.payloads?.some((p) => p.text?.trim());
if (finalEmbeddedError && isContextOverflowError(finalEmbeddedError.message) && !hasPayloadText) {
return {
kind: "final",
payload: {
text: "⚠️ Context overflow — this conversation is too large for the model. Use /new to start a fresh session.",
},
};
}
return {
kind: "success",
runId,