Context & Logic Errors

Claude Cowork's context window is large — 200K tokens on standard plans, up to 1M on Enterprise — but it is not infinite. As a conversation grows, the oldest messages fall off the sliding window. When that happens, Claude forgets earlier instructions, reverts fixed code, or invents file paths that never existed. This page groups every context-and-logic error we have documented so you can recognize the symptom and jump to the right fix.

How Context Errors Differ from System Errors

Context errors happen inside the model's reasoning, not in the file system or network. The agent is technically running fine — it just does not have the right information anymore. The telltale sign is that the same task worked perfectly 20 minutes ago, and now Claude is making mistakes that feel like amnesia.

Errors in This Category

Context Window Exceeded

You uploaded too many large files, asked Claude to read a massive codebase, or the conversation history simply grew too long. The request now exceeds the token limit and the API rejects it outright.

Typical message: Request too large or Context window exceeded

Quick check: How long is this conversation? If you have been chatting for an hour with multiple file uploads, a session reset is the fastest fix.

Full fix: Context Window Exceeded →

Stale Context Warning

Claude starts suggesting changes that revert previous fixes, asks "What file were we working on?", or hallucinates function names that do not exist. The context window has not overflowed — it has just drifted. The oldest, most important instructions (like "don't touch the config file") have scrolled off.

Typical symptom: Claude undoes a fix you applied 30 messages ago, or forgets which file is the active one.

Quick check: Ask Claude to summarize your current progress. If the summary is missing key decisions, you have stale context.

Full fix: Stale Context Warning →

Hallucinated File Paths

The agent tries to edit src/utils/helper.ts — a file that does not exist in your project. After a long session, Claude may "remember" a file structure from a previous project or assume a conventional layout (src/components) that your project does not use.

Typical message: ENOENT: no such file or directory or Cannot write to src/utils/helper.ts (directory does not exist)

Quick check: Does the path Claude is trying to use match your actual project structure? Run ls -R src/ and compare.

Full fix: Hallucinated File Paths →

General Prevention Strategy

Context errors are easier to prevent than to fix. Build these habits into your workflow:

  1. Start fresh for each major task. Do not pile five unrelated tasks into one conversation. A new chat costs nothing and resets the context to zero.
  2. Summarize before restarting. Before you start a new session, ask Claude: "Summarize our current progress, the files we changed, and the decisions we made." Paste that summary into the new chat.
  3. Pin critical instructions. On Enterprise plans, use Project Knowledge to pin README.md or coding-standards.md so they never scroll off. On other plans, re-state critical constraints every 10–15 messages.
  4. Use targeted reads, not bulk reads. Instead of "read every file in my project," say "read only the files related to authentication." This keeps the context window lean.
  5. Create a .coworkignore file. List directories like node_modules, .git, and dist so Claude never wastes tokens reading junk.

The "Context Budget" Mental Model

Think of the context window as a budget. Every message, every file read, every tool output spends from that budget. When the budget runs out, the oldest spending is "forgotten." The table below shows rough token costs:

ActionApproximate Token Cost
One chat message (your prompt)50–500 tokens
Claude's response200–2000 tokens
Reading a 500-line source file~3,000 tokens
Reading a 50-page PDF~15,000 tokens
A single sub-agent tool call~12,000 tokens overhead

If you are on a 200K-token plan and you have read 10 source files plus a PDF, you have already spent ~45,000 tokens — nearly a quarter of your budget — before counting conversation history. This is why long sessions degrade: the budget silently runs out.

Understanding Context Windows

A context window is the total amount of text the model can hold in its working memory at one time. For Claude Cowork, that window is 200,000 tokens on standard plans and up to 1,000,000 tokens on Enterprise. A token is roughly four characters of English text, so 200K tokens is approximately 150,000 words — about the length of a 600-page book.

The window is not a permanent archive. It operates as a sliding window: when new content enters (a new file read, a new tool output, a new response from Claude), the oldest content scrolls off the back end and is gone. Claude cannot retrieve it. This is not a bug — it is a fundamental constraint of how transformer-based language models process input.

Why This Matters for Coding Tasks

Coding tasks are unusually context-hungry. A single React component file can be 300 lines (~2,000 tokens). A typical debugging session might involve reading the component, its test file, a shared utility, a types definition, and a configuration file — 10,000 tokens before you have written a single prompt. Add a 20-message conversation history and you are at 30,000 tokens. On a 200K plan this sounds comfortable, but a complex task that spans multiple modules can easily push past 100,000 tokens in an hour.

The danger is not hitting the hard limit (the API will reject the request and tell you). The danger is silent drift: the important instruction you gave at message 3 ("do not modify the database schema") scrolls off at message 45, and Claude proceeds to modify the schema because it no longer remembers the constraint.

Context vs. Long-Term Memory

Cowork does not have persistent memory across sessions in the way a database does. Project Knowledge files (on Enterprise plans) are re-injected into each session, but everything else — conversation history, file contents read during the session, decisions made — lives only within the current session's context window. When you start a new chat, you start from zero.

Symptoms: How to Recognize This Error

Context errors are sneaky because the agent keeps running. There is no error popup. Instead, the quality of output degrades gradually. Watch for these signals.

Early Warning Signs

  • Claude asks "Which file are we working on?" in a session where you already told it multiple times.
  • Claude reverts a fix it applied earlier in the same conversation.
  • Claude suggests importing a module that does not exist in your project.
  • Claude repeats a question it already asked and you already answered.
  • Generated code references variable names from a different part of the codebase that are not in scope.

Mid-Session Degradation

  • Claude's responses become shorter and less detailed, as if it is losing track of the task.
  • Claude starts hedging: "I believe the function is called..." instead of stating it confidently.
  • Claude proposes solutions that contradict decisions made earlier in the session.
  • File edits target the wrong file or the wrong function within a file.

Late-Stage Failure

  • Claude produces code that looks plausible but references APIs or files from a completely different project.
  • The agent enters a loop, re-reading the same files repeatedly without making progress.
  • You receive an explicit Context window exceeded error and the request is rejected.

If you observe two or more early warning signs, stop and start a new session with a summary. Waiting for late-stage failure means you will spend tokens fixing mistakes that context drift caused.

Prevention Strategies

Context errors are preventable with disciplined session management. These strategies cost no tokens and prevent the majority of context-related failures.

1. One Task Per Session

The single most effective prevention habit. Do not ask Cowork to fix a bug, then refactor a module, then write tests for a third feature — all in one chat. Each task has its own context requirements, and stacking them guarantees that early instructions scroll off before the later tasks complete.

Start a new chat for each task. If tasks are related, paste a one-paragraph summary from the previous session as the opening message.

2. Write a Session Brief

Before starting a complex task, write a 3–5 sentence brief that includes:

  • The goal ("Fix the login redirect bug in the auth module").
  • The relevant files ("src/auth/redirect.ts, src/auth/session.ts").
  • The constraints ("Do not modify schema.prisma").
  • The definition of done ("All existing auth tests pass").

Paste this brief as your first message. If context drifts, the brief is the first thing to scroll off — but re-pasting it at any point in the session instantly restores the key constraints.

3. Use .coworkignore Aggressively

Create a .coworkignore file in your project root with at minimum:

node_modules/
dist/
build/
.git/
*.log
*.min.js
coverage/
.next/

This prevents Cowork from accidentally reading generated or dependency files, which waste tokens and pollute context with irrelevant code.

4. Targeted File Reads

Instead of "read my src folder," say "read src/auth/login.ts and src/auth/session.ts." Explicit file paths keep the context window lean and prevent the agent from reading files you do not need.

5. Checkpoint with Summaries

Every 15–20 messages, ask Claude: "Summarize the files we have changed, the decisions we made, and the remaining steps." This does two things: it forces Claude to restate the current state (which refreshes the context), and it gives you a summary you can paste into a new session if needed.

6. Pin Critical Constraints on Enterprise

If you are on an Enterprise plan, use Project Knowledge to pin files like coding-standards.md or architecture.md. These files are injected into every session and never scroll off. On other plans, re-state critical constraints every 10–15 messages.

Recovery Steps

When you recognize that context has drifted or the window is full, follow this sequence to recover without losing your work.

Step 1: Stop the Agent

Do not let the agent continue running with degraded context. Hit Ctrl+C in the CLI or click Stop in the UI. Every additional message with bad context produces more errors to clean up.

Step 2: Generate a Summary

In the same session (before it scrolls further), ask Claude: "Summarize our progress so far: files changed, decisions made, current blocker, and next steps." Copy the response into a text file. This summary is your bridge to the new session.

Step 3: Check Your Git State

Run git status and git diff. If Claude made changes before the context degraded, review them now. Commit the good changes with a descriptive message:

git add -A
git commit -m "WIP: partial auth refactor before context reset"

If the changes are broken, stash them:

git stash push -m "broken auth refactor attempt"

Step 4: Start a New Session

Open a new chat. Paste your summary as the first message, followed by your session brief (goal, files, constraints, definition of done). This gives the fresh context window everything it needs in a compact form — typically 500–1,000 tokens instead of the 50,000+ that the old session had accumulated.

Step 5: Verify State

Before asking Claude to continue, have it read the files you were working on and confirm the current state matches your summary. If there is a mismatch, resolve it before proceeding. Do not let Claude assume the state — make it verify.

Step 6: Resume the Task

With a clean context, a verified state, and a clear brief, resume the task. The fresh session will typically complete the remaining work faster than the degraded session would have, because it is not fighting context drift.

Related Errors

Context and logic errors overlap with several other error categories. If the fix above did not resolve your issue, check these related pages:

  • Stale Context Warning — The specific failure mode where old instructions scroll off and Claude reverts earlier fixes.
  • Hallucinated File Paths — Claude invents file paths that do not exist, often caused by context drift mixing in patterns from other projects.
  • Context Window Exceeded — The hard limit error where the API rejects the request outright.
  • Git Merge Conflict Loop — A workflow error that context drift can trigger: Claude forgets the resolution strategy it already tried and repeats it.
  • Workflow & Runtime Errors — The parent category for execution-time failures that are not caused by context limits.