feat: detect and handle "Prompt is too long" errors from Claude CLI #158

Closed
opened 2026-02-24 15:08:55 -08:00 by hikari · 0 comments
Owner

Overview

When the conversation history grows too large, the Claude CLI returns a "Prompt is too long" error. Currently this is displayed as a plain assistant message in the terminal, which is confusing — it looks like a normal response rather than an actionable error.

Current Behaviour

The error appears as a white assistant text block with no prefix:

02:58 PM   Prompt is too long

Expected Behaviour

  • The message should be displayed as an error line type (red, with [error] prefix) so it stands out clearly
  • A "Compact Conversation" button should appear in the terminal when this error is detected, allowing the user to trigger claude --compact (or equivalent) to summarise and truncate the history so the session can continue without starting over

Proposed Implementation

Detection

In wsl_bridge.rsprocess_json_line, when processing ClaudeMessage::Assistant content blocks with ContentBlock::Text, check if the text is exactly (or starts with) "Prompt is too long". If so, emit the line with line_type: "error" instead of "assistant", and additionally emit a special line_type: "compact-prompt" event.

Alternatively, the Claude CLI may emit this as a result message with a specific subtype — worth investigating in the binary.

UI

When the compact-prompt line type is received, the terminal should render an inline action button:

[error] Prompt is too long
[action] ⚡ Compact Conversation   ← clickable button

Clicking the button sends a /compact command (or the equivalent CLI flag) to the active session, which summarises the conversation history and allows the user to continue.

Notes

  • Related to context window management
  • The compact action should be non-destructive — it summarises rather than deletes history

This issue was created with help from Hikari~ 🌸

## Overview When the conversation history grows too large, the Claude CLI returns a `"Prompt is too long"` error. Currently this is displayed as a plain assistant message in the terminal, which is confusing — it looks like a normal response rather than an actionable error. ## Current Behaviour The error appears as a white assistant text block with no prefix: ``` 02:58 PM Prompt is too long ``` ## Expected Behaviour - The message should be displayed as an `error` line type (red, with `[error]` prefix) so it stands out clearly - A **"Compact Conversation"** button should appear in the terminal when this error is detected, allowing the user to trigger `claude --compact` (or equivalent) to summarise and truncate the history so the session can continue without starting over ## Proposed Implementation ### Detection In `wsl_bridge.rs` → `process_json_line`, when processing `ClaudeMessage::Assistant` content blocks with `ContentBlock::Text`, check if the text is exactly (or starts with) `"Prompt is too long"`. If so, emit the line with `line_type: "error"` instead of `"assistant"`, and additionally emit a special `line_type: "compact-prompt"` event. Alternatively, the Claude CLI may emit this as a `result` message with a specific `subtype` — worth investigating in the binary. ### UI When the `compact-prompt` line type is received, the terminal should render an inline action button: ``` [error] Prompt is too long [action] ⚡ Compact Conversation ← clickable button ``` Clicking the button sends a `/compact` command (or the equivalent CLI flag) to the active session, which summarises the conversation history and allows the user to continue. ## Notes - Related to context window management - The compact action should be non-destructive — it summarises rather than deletes history ✨ This issue was created with help from Hikari~ 🌸
naomi closed this issue 2026-02-24 20:48:51 -08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/hikari-desktop#158