Skip to content

Context compression does not prevent context overflow errors #4545

@dobesv

Description

@dobesv

When you have context compression enabled with a token limit lower than your model's limit, you can still get "stuck" with an error like:

litellm.ContextWindowExceededError: litellm.BadRequestError: AnthropicError - b'{"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 217388 tokens > 200000 maximum"},"request_id":"req_011CYGQ9pNMT8pdQbGzZcPUs"}'

This is because the context compression logic runs after the event is sent to the LLM. The context compression should either happen before running the LLM or detect an error like the above and compress and retry after.

See also

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions