-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Context window exhaustion returns status 'failed' instead of 'exhausted' #977
Copy link
Copy link
Open
Labels
Description
Environment
@github/copilot-sdk: 0.1.32@github/copilot(CLI): 1.0.6
Description
The OrchestratorResult type defines an 'exhausted' status, but when the Anthropic API returns "prompt is too long: N tokens > 200000 maximum", the GHCP orchestrator maps this to status: 'failed' with the raw API error string. There's no way to distinguish context exhaustion from other failures without parsing the error message.
Impact
Consumers must use fragile regex matching on result.error to detect context exhaustion, instead of checking result.status === 'exhausted'. This is error-prone and breaks if the API error message format changes.
Expected behavior
When the API returns a context window / token limit error (HTTP 400 with invalid_request_error containing "prompt is too long" or similar), the SDK should set status: 'exhausted' on the result.
Current workaround
Regex matching:
const isContextExhausted = result.error
? /\b(prompt\s+is\s+too\s+long|input\s+tokens\s+exceed|context\s+limit)\b/i.test(result.error)
: false;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.