bug: handle LLM context length overflow gracefully #19

Closed
opened 2026-05-02 01:08:15 +00:00 by rodin · 0 comments
Owner

Problem

When the prompt (diff + conventions + patterns) exceeds the model's context window, review-bot crashes with a non-actionable error.

Example: gargoyle PR #508 with patterns/ directory fetched from 2 repos + CLAUDE.md + diff = 134K tokens, exceeding GPT-4.1's 128K limit.

Current Behavior

LLM API error (status 400): context_length_exceeded

CI job fails, no review posted.

Expected Behavior

review-bot should:

  1. Detect context overflow (either pre-calculate or catch the 400)
  2. Progressively trim context: patterns first, then conventions summary, then chunk the diff
  3. Retry with reduced context
  4. If still too large, post a comment explaining the PR is too large for automated review

Acceptance Criteria

  • No crash on context overflow
  • Graceful degradation: try with less context before giving up
  • Informative output when review cannot be completed
  • Tests cover the overflow path
## Problem When the prompt (diff + conventions + patterns) exceeds the model's context window, review-bot crashes with a non-actionable error. Example: gargoyle PR #508 with `patterns/` directory fetched from 2 repos + CLAUDE.md + diff = 134K tokens, exceeding GPT-4.1's 128K limit. ## Current Behavior ``` LLM API error (status 400): context_length_exceeded ``` CI job fails, no review posted. ## Expected Behavior review-bot should: 1. Detect context overflow (either pre-calculate or catch the 400) 2. Progressively trim context: patterns first, then conventions summary, then chunk the diff 3. Retry with reduced context 4. If still too large, post a comment explaining the PR is too large for automated review ## Acceptance Criteria - [ ] No crash on context overflow - [ ] Graceful degradation: try with less context before giving up - [ ] Informative output when review cannot be completed - [ ] Tests cover the overflow path
rodin closed this issue 2026-05-02 03:07:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rodin/review-bot#19