[GH-ISSUE #3176] Update context window management to avoid context shifts #48467

Open
opened 2026-04-28 08:32:28 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @jmorganca on GitHub (Mar 16, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3176

What are you trying to do?

Today, upon reaching the context window limit, a "context shift" occurs, effectively halving the number of tokens in the context window to make room for new generations. However, we should avoid this – OpenAI and other tools instead have token limits that, when reached, stop generation and let the user know.

How should we solve this?

A few ideas:

  • Make sure at least x% of the prompt is available for generation beyond the prompt
  • Add a reason or similar key to /api/generate and /api/chat so it's obvious when the token limit is hit

What is the impact of not solving this?

Possible run-ons and poorer responses from context shifting

Anything else?

No response

Originally created by @jmorganca on GitHub (Mar 16, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3176 ### What are you trying to do? Today, upon reaching the context window limit, a "context shift" occurs, effectively halving the number of tokens in the context window to make room for new generations. However, we should avoid this – OpenAI and other tools instead have token limits that, when reached, stop generation and let the user know. ### How should we solve this? A few ideas: * Make sure at least x% of the prompt is available for generation beyond the prompt * Add a `reason` or similar key to `/api/generate` and `/api/chat` so it's obvious when the token limit is hit ### What is the impact of not solving this? Possible run-ons and poorer responses from context shifting ### Anything else? _No response_
GiteaMirror added the feature request label 2026-04-28 08:32:28 -05:00
Author
Owner

@bdqfork commented on GitHub (Jan 7, 2025):

Any update?

<!-- gh-comment-id:2574280091 --> @bdqfork commented on GitHub (Jan 7, 2025): Any update?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#48467