Long sessions: context compaction silently drops a critical requirement and the model never warns (caused a production incident)

Open
#111,493 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
22/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

The report describes behavior only: no file, function or test is named, and the reproduction is explicitly non-deterministic, so the first step is locating where session compaction summaries are generated and where the model is (or is not) told it is working from a summary. Read that path, then build a repeatable scenario with a pinned early constraint and many forced compactions to observe when the constraint disappears. Done looks like a decision on the three requested behaviors (constraint pinning across compaction, a repeated-compaction warning, a guarantee-check before code deletion) plus a test that fails today. This is design work in an unfamiliar subsystem, not a first-contribution candidate.

Written by the indexing model from the issue text.

Description

area:core area:model bug platform:macos
Preflight Checklist
  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code
What's Wrong?

I'm a solo founder on the Ultra plan. I use Claude Code (Opus 5.5 and Fable 5.2, max effort) to build a standard SaaS with a WhatsApp booking assistant for short-term apartment rentals.

What happened, from Claude Code's own analysis of its session logs (times UTC+5):

  • Nov 19: in one long session, Claude Code rewrote the booking flow. The old code contained the only check that prevented booking a guest into an apartment that is still occupied (arrival time vs. the previous guest's checkout).
  • This requirement was present in the compaction summaries at 17:40 and 18:24, and missing from the summaries at 19:16, 20:20 and 20:45.
  • The new booking code was written right after the 20:20 compaction, without the check, and shipped at 22:15.
  • Nov 20: in the next session, the old code was deleted. In the compaction summaries, the file with the check was listed as unused code.
  • Nov 21, 06:51: the assistant booked a real guest into an occupied apartment. The guest arrived by taxi, and the apartment owner had to apologize.

Numbers from the logs:

  • Nov 19: 8 compactions in 7 hours.
  • Nov 20-21: 65 compactions in ~35 hours.
  • The model never told me it was working from summaries and never suggested splitting the work into smaller sessions.
  • After the incident: 44 test runs, 960 test conversations, many more compactions. My subscription limits ran out.
What Should Happen?
  • Compaction should not silently drop explicit requirements and constraints (for example, keep a pinned list of constraints across compactions).
  • After repeated compactions, Claude Code should warn the user and suggest starting a fresh session with a handoff.
  • Before deleting code, the model should list what that code guarantees and verify that every guarantee is preserved.
Error Messages/Logs
No error messages. The failure was silent: the model reported success each time.
Steps to Reproduce

Not deterministic. The pattern observed:

  1. Work in one long session (many hours) on a large codebase, with frequent auto-compaction.
  2. State an important constraint early in the session.
  3. After several compactions, the constraint disappears from the summary.
  4. The model then writes or deletes code that violates it, and reports success.
Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Latest (auto-updated), as of Nov 21, 2026

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

English isn't my native language, so Claude helped me translate this report. The analysis above comes from Claude Code's own review of its session logs.

Dominant language
TypeScript
Stars
156k
Forks
25k
Avg merge
16h 19m
Merged PRs (30d)
5

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.