# language_model_core: Classify Anthropic prompt-too-long 400s as context overflow \(\#63596\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/6309c722133cb05146e22151567fe21a2bbc8cde)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 6309c722133cb05146e22151567fe21a2bbc8cde

Requested commit: 6309c722133cb05146e22151567fe21a2bbc8cde

Commit: 6309c722133cb05146e22151567fe21a2bbc8cde

Tree: 07020f68ced08d1d7e3d48b352fcfa69375c2bad

Author: Richard Feldman

Committer: GitHub

## Message

```
language_model_core: Classify Anthropic prompt-too-long 400s as context overflow (#63596)

Anthropic reports a context-window overflow with HTTP 400 and a message
of the form `prompt is too long: N tokens > M maximum`. The
`BAD_REQUEST` arm of `ProviderErrorCategory::from_http_status` only
recognized OpenAI's phrasings (`context_length_exceeded`, "exceeds the
context window"), and `parse_prompt_too_long` only ran for HTTP 413, so
these rejections were classified as `InvalidRequest` instead of
`PromptTooLarge`. This affects every wire path that classifies by
upstream HTTP status, including Zed cloud's `upstream_http_400` code,
and it silently disables any downstream handling keyed on the
`PromptTooLarge` category. This change sniffs the Anthropic phrasing on
400 responses too, carrying the provider-reported token count.

Closes AI-462

Release Notes:

- Fixed Anthropic "prompt is too long" errors reported with HTTP 400 not
being recognized as context-window overflows.
```

## Parents

- [dbfeae7735ece8f929244744c219ace6c02f0dc5](https://git.cafe/gitcafe/zed/commit/dbfeae7735ece8f929244744c219ace6c02f0dc5?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/6309c722133cb05146e22151567fe21a2bbc8cde?format=markdown)
