Skip to content

Handle "Prompt is too long" error gracefully #389

@fenix011

Description

@fenix011

Summary

When resuming a session whose context exceeds the model's limit, the JSON-RPC layer returns a raw error:

{"jsonrpc":"2.0","id":4,"error":{"code":-32603,"message":"Internal error: Prompt is too long"}}

agent-shell displays this as a generic error dialog:

╭─
  ⚠ Error (-32603) ⚠
  Internal error: Prompt is too long
  [Details]
╰─

This is confusing — the user doesn't know what happened or how to recover.

By contrast, the Claude Code CLI handles the same situation with a friendly message ("Context is too long...") and offers the /compact command to summarize and continue.

Proposed improvement

Detect this specific error (code -32603, message matching "Prompt is too long") and provide an actionable recovery path, for example:

  • Show a clearer message: "Context too long — compact the conversation to continue"
  • Add a clickable button to trigger compaction (if the agent supports a compact/summarize operation via ACP)
  • Or automatically compact and retry

Steps to reproduce

  1. Open a session in agent-shell and have a long conversation
  2. Close/kill the buffer
  3. Resume the same session — the accumulated context triggers the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions