Skip to content
InnovateTechie
Claude Troubleshooting

Claude 'Prompt Is Too Long' Error: Shrink What You Send

EdithBy Edith12 min read
Share
Claude showing the prompt is too long error with a full context window

Quick answer

The 'prompt is too long' error in Claude means your input filled the context window. Here's exactly why it happens and how to fix it fast.

Key takeaways

  • The error means your combined input — new message, full conversation history, and attached files — overflowed the model's context window; it is never about the length of Claude's reply.
  • Claude re-reads the entire thread on every turn, so a long-running chat can trigger the error even when your newest message is a single short sentence.
  • The fastest fixes are starting a fresh chat for a new topic, removing large attachments, and summarizing earlier turns into a new thread — most take under 30 seconds.
  • In Claude Code, the /compact command condenses the conversation history in place, so you can keep working in the same session without losing the thread.
  • On the API the error surfaces as an HTTP 400 invalidrequesterror; the free counttokens endpoint lets you catch over-limit prompts before you send them.

When Claude says your "prompt is too long," it means everything you sent — your new message plus the entire conversation and any attached files — no longer fits in the model's context window. It's an input-size problem, not a limit on Claude's answer. The fix is to shrink what you're sending in.

Context-window behaviour and API error codes verified 31 July 2026 against Anthropic's context windows documentation.

That one distinction clears up most of the confusion. The "prompt is too long" error is not Claude refusing to write a long reply, and it is not a bug in your wording. Claude reads your whole chat every single time it responds, so a conversation that started small can quietly grow until the combined input overflows the space available. This guide explains exactly why the message appears and gives you a clean, ordered set of fixes for the web app, the desktop app, and the API. Claude currently spans models like Opus 5 and Sonnet 5, each with its own context window, and this guide is reviewed regularly so the fixes stay accurate — most of them take under 30 seconds to apply. This reflects real hands-on time with the feature, not just its documentation.

Key takeaway

The "prompt is too long" error means your combined input — new message plus the full conversation and any attached files — overflowed the model's context window, not that Claude's reply is too long; on the API it surfaces as an HTTP 400 invalid_request_error, and most fixes take under 30 seconds.

What "prompt is too long" actually means

Your combined input overflowed the model context window — system instructions, every earlier message, uploaded files, and the new text all have to fit at once. Claude refuses rather than silently dropping any of it.

Every Claude model has a fixed context window — the maximum amount of text (measured in tokens) it can hold in working memory at once. That window has to fit all of your input: the system instructions, every previous message in the thread, any files or images you've uploaded, and the new thing you just typed. When the total crosses the ceiling, Claude can't load the request, so it stops and tells you the "prompt is too long."

Think of it like a desk with a fixed surface area. Each message, each pasted log, each uploaded PDF takes up space. For a while there's room to spare. Then one more document lands on the pile and something has to fall off the edge — except Claude won't silently drop your data, so instead it refuses and surfaces the error. The trigger is almost always cumulative size, which is why the message often appears mid-conversation rather than on your first prompt.

It helps to know how tokens work here. A token is roughly three-quarters of a word in English, so a few thousand words of pasted text, a long code file, or a dense PDF can consume a surprising share of the window. If you want the deeper mechanics, our guide to Claude's token limits breaks down how tokens are counted and where they add up fastest.

Diagram of the prompt is too long error filling Claude's context window

Why the error happens

Four causes, usually overlapping: a conversation long enough to fill the window on its own, large attachments, one enormous paste, or a model with a smaller window. Reply length is never the cause.

There are only a handful of real causes, and they usually overlap. Once you can spot which one is driving your case, the fix is obvious.

A very long conversation. This is the most common trigger. Because Claude re-reads the full thread on every turn, a chat that has run for dozens of back-and-forth messages eventually fills the window on its own — even if your latest message is a single short sentence. This is closely related to the conversation length limit people hit in long sessions.

Large attachments or files. Uploading a big PDF, a spreadsheet, or several images at once can eat a large chunk of the window in one move. A handful of long documents can push you over before you've asked anything substantial. If you frequently bump into caps here, see how the upload limit works.

A huge paste. Dropping thousands of lines of logs, an entire codebase file, or a long transcript directly into the message box is a fast way to overflow the window in a single prompt.

A smaller model. Different Claude models ship with different window sizes. If you're on a model with a smaller context window, you'll hit the "prompt is too long" wall sooner than you would on a larger one.

Notice what is not on this list: the length of Claude's reply. Output length is governed separately and produces different behavior — Claude cutting a response short is a distinct issue from this one, which is purely about the size of what you send in.

How to fix the "prompt is too long" error

Start a fresh chat for a new topic, remove or trim attachments, summarise earlier turns into a new thread (or run /compact in Claude Code), split huge inputs across messages, and move standing reference material into a Project.

Work down this table roughly in order. The earlier fixes are the fastest and solve the majority of cases; the later ones are for genuinely large workloads.

CauseFix
Long-running chat on a new topicStart a fresh chat. A new conversation resets the window to empty, so a new subject rarely needs the old history.
Big attachments piling upRemove or replace large files. Delete attachments you no longer need, or upload a trimmed excerpt instead of the whole document.
Earlier turns no longer neededSummarize the conversation so far into a few lines, paste that into a new chat, and drop the rest. In Claude Code, run /compact to condense the history in place.
One enormous inputSplit it into parts. Feed a long document or dataset in sections across separate messages instead of one giant paste.
Reference material you reuse oftenPut it in a Project. Store standing context as knowledge in Claude Projects so it doesn't ride inside every prompt.
A very long pasteShorten it. Send only the relevant section, function, or error — not the entire file or log.
Model window too smallSwitch to a model with a larger context window for the heavy task, then go back to your default for everyday work.

Start a fresh chat

If you've simply moved on to a new topic, the cleanest fix is the simplest: open a new conversation. The old thread's history is what filled the window, and a new subject rarely needs it. This alone resolves a large share of these reports, because people keep one endless chat open for weeks. Starting fresh at natural task boundaries is a good habit regardless. New here? Our how to use Claude AI walkthrough covers the basics of managing chats.

Trim or remove attachments

If the error appeared right after you uploaded files, they're the likely culprit. Remove attachments you no longer need, or swap a full document for just the pages that matter. Ten screenshots and three PDFs can consume more of the window than an hour of typed conversation.

Summarize or compact earlier turns

For a long but still-relevant conversation, condense it. Ask Claude to summarize the discussion so far, copy that summary into a new chat, and continue from there — you keep the thread of the work without dragging every earlier word along. In Claude Code, the built-in /compact command does this automatically, replacing the raw history with a compressed summary so you can keep going in the same session.

We run into this constantly, because building and maintaining this site means long Claude Code sessions on native Windows that slowly accumulate a full repository's worth of context. The habit that saved us the most rework was compacting proactively at natural task boundaries rather than waiting for the wall — once a session is already over the ceiling, you have lost the room you needed to summarize cleanly. Now we treat /compact the way we treat a git commit: a small, deliberate checkpoint between chunks of work, not an emergency button.

Split a huge input into parts

When a single document or dataset is too big to send at once, break it up. Feed it in labeled sections across several messages ("Part 1 of 4…"), and ask Claude to hold each piece before you send the next. This keeps any one prompt under the ceiling while still getting the whole thing in.

Use a Project for standing reference material

If you keep pasting the same background — style guides, specs, a knowledge base — stop putting it in the prompt. Load it once as Project knowledge instead. That way the reference lives outside the conversation and doesn't count against every message, which is exactly the pattern that prevents the "prompt is too long" error from recurring.

Comparison of fixes for the prompt is too long error in Claude

Fixing the error on the API

It arrives as HTTP 400 invalid_request_error. Prune the messages array, confirm the exact context limit for the model you are calling, pre-flight with the free count_tokens endpoint, and leave headroom for the response.

Developers see the same problem, just wearing different clothes. On the API, an over-sized request typically comes back as an HTTP 400 invalid_request_error, and the root cause is identical: the combined input tokens exceeded the model's context window. Anthropic's error reference documents the 400 family for malformed or over-limit requests.

The fixes map cleanly to the chat-side advice:

  • Reduce input tokens. Trim the messages array, drop stale turns, and don't resend context the model doesn't need for the current call. If you're managing a growing thread, the same discipline as the conversation length limit applies — prune as you go.
  • Check the model's context limit. Confirm the window size for the exact model you're calling and keep your total prompt comfortably under it. Anthropic's context windows documentation lists how the window is shared across input and output, and how larger-window options work.
  • Count before you send. Estimate token usage before firing the request so you can catch an over-limit prompt in your own code rather than round-tripping to a 400. The free count_tokens endpoint returns an exact input figure, and our guide to Claude token counting shows how to wire it up as a pre-flight check.
  • Leave room for the response. The window is shared between what you send and what Claude generates, so budget space for the output too — fill the window entirely with input and there's nothing left for the answer.

Because the API gives you direct control over the messages you include, it's often easier to fix there than in a chat UI: you decide precisely what history travels with each call.

Prevention: keep prompts under the limit

One topic per chat, attach only what you will reference, summarise at milestones, keep standing context in Project knowledge rather than in every prompt, and reach for a larger-window model only when the task genuinely needs it.

A few habits make the "prompt is too long" error rare:

  • One topic per chat. Spin up a new conversation when the subject changes instead of extending an endless thread.
  • Upload lean. Attach only the documents you'll actually reference, and prefer excerpts over entire files.
  • Summarize milestones. In long projects, periodically capture a short summary and continue from it.
  • Store the stable stuff in a Project. Standing context belongs in Project knowledge, not in every prompt.
  • Match the model to the job. Reach for a larger-window model when a task is genuinely huge, and use your default the rest of the time.

Do these and you'll spend far less time bumping into the ceiling — and when you do, you'll know exactly which lever to pull.

Frequently Asked Questions

It means the total input you sent — your new message plus the entire conversation history and any attached files — exceeded the model's context window. Claude has to load all of that at once to respond, and when the combined size crosses the limit it stops rather than dropping your data.

Because Claude re-reads the whole conversation on every turn, not just your latest line. A long-running chat or a few big earlier uploads can fill the window on their own, so even a one-word new message tips it over the edge. Starting a fresh chat usually fixes it instantly.

No. It's purely about the size of your input. A truncated or cut-off answer is a separate output issue with different causes — this error fires before Claude even begins writing, because the request itself won't fit.

Ask Claude to summarize the conversation so far, copy that summary into a new chat, and continue from there. In Claude Code, run /compact to condense the history in place. Either way you keep the important context while shedding the bulk that filled the window.

Not directly. The trigger is the context window of the specific model, not your subscription tier. What helps is switching to a model with a larger window for big tasks, or trimming your input — a higher plan on its own doesn't enlarge a given model's window.

On the API, an over-sized request surfaces as an HTTP 400 invalidrequesterror because the input tokens exceed the model's context window. Reduce the tokens you send, verify the model's context limit, and leave headroom for the response, and the request will go through.
Edith

Written by

Edith

Writing about Claude and the Anthropic toolkit — models, Claude Code, pricing, features, and fixes, in clear, practical, hands-on guides tested by daily use.

View all posts →