Skip to content
docsv0.42.1

ContextExceededException

The provider answered the ONE 4xx a budgeted agent leg can govern: an HTTP 400 whose body carries `"type":"exceed_context_size_error"` — the OpenAI-compat exceed-context error, measured verbatim on greenhouse fixture run 12 («request (33246 tokens) exceeds the available context size (32768)») one step from the first full completion. It extends `RuntimeException` and keeps the exact `"$provider API Error: HTTP 400 - ..."` message the untyped path produced, so every consumer that catches the base class sees zero change; the type exists so {@see AgentOrchestrator} — the owner of re-projection — can distinguish this failure and heal it: shrink the leg budget by the provider's own measured overage, re-project from full history, retry. Every OTHER 4xx stays the plain `RuntimeException` it always was, surfacing verbatim un-retried. The provider's numbers ride along when the body carried them: `n_prompt_tokens` (what the provider counted in the rejected request) and `n_ctx` (its window). `null` means «not said», never a fabricated zero — the healer falls back conservatively.

ContextExceededException::__construct()

public function __construct(string $message, ?int $nPromptTokens = null, ?int $nCtx = null):

Parameters

Parameters of __construct()
NameTypeDescription
$messagestringThe same `"$provider API Error: HTTP 400 - ..."` line the untyped path would have thrown, verbatim.
$nPromptTokens(int | null)The provider's own count of the rejected request, when the body named it.
$nCtx(int | null)The provider's declared context window, when the body named it.