Code review flow causes context window overflow error with no recovery
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=596794) </details> <!--IssueSummary end--> ## Summary The `perform_code_review_and_publish` step in the Agentic Chat code review flow causes a `ContextWindowExceededError` for large MRs, resulting in a deadlock with no recovery path for the user. This was identified as a distinct sub-case of [#594814](https://gitlab.com/gitlab-org/gitlab/-/work_items/594814) (Agentic Chat sessions deadlock — error swallowed or infinite spinner, no recovery). ## Error ``` workflow execution failure: ContextWindowExceededError: litellm.ContextWindowExceededError: litellm.BadRequestError: BedrockException: Context Window Error - {"message":"The model returned the following errors: Input is too long for requested model."} ``` ## Root Cause All `prompt is too long for context window` errors have been traced to the code review flow (see [logs](https://cloudlogging.app.goo.gl/VgS5Yw4EK52GqpQr5)). The `perform_code_review_and_publish` step assembles a large prompt from inputs (prescan codebase results, full diffs, full file contents of those diffs, etc.) that can exceed the model's 200k token context window for sufficiently large MRs. Importantly, this overflow comes from the **inputs**, not the conversation history — so compaction does not help here. ## Expected Behavior - The code review flow should reduce/truncate prompt inputs before calling `perform_code_review_and_publish` to stay within the model context window ## Environment - Instance: GitLab Dedicated (18.9) - Model: Claude Sonnet via Bedrock (200k token context window)
issue