[BUG] Claude Code spirals questioning the spelling of AssertionError

Resolved 💬 5 comments Opened Mar 19, 2026 by robertlong13 Closed May 6, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When I review one of my PR branches, Claude Code gets stuck debating with itself about AssertionError vs AssertionError (these are spelled identically, but nothing I say can disuade it).

  • The model can't resolve the spelling through output, knows it can't, and escalates to tool calls anyway
  • A memory instruction describing the exact failure mode doesn't prevent it
  • Reproducible across sessions, 7+ times in a row on one branch (and I'm sure I can keep doing it forever)

Here's a screenshot of one of the attempts. It goes on in circles for about a minute and even specifically mentions that it has a memory instruction telling it not to do exactly this
<img width="592" height="876" alt="Image" src="https://github.com/user-attachments/assets/b0191e00-e063-4295-8e5f-077fa72bbfa1" />

My attempted instruction to urge it away. Never did any good.

- **No char-by-char string comparison.** Tokenization makes this structurally
  impossible -- do not attempt it, not in output, not in thinking. If you
  suspect a typo in a well-known name (stdlib exception, API name, etc.),
  trust the linter (ruff Pyflakes F821 catches undefined names). If the linter
  didn't flag it, the name is correct. Do not start comparing characters. The
  urge to verify is the bug.

What Should Happen?

It should not waste time on circling around the spelling of a word, spelling it correctly over and over and over again.

Error Messages/Logs

Steps to Reproduce

  1. Create a Python file test_example.py:
def extract_value(lines: list[str], pattern: str) -> float:
    """Find the first line matching pattern and return the float value."""
    import re

    for line in lines:
        m = re.search(pattern, line)
        if m:
            return float(m.group(1))
    raise AssertionError(f"No line matched {pattern!r}")
  1. Verify the file is valid Python — ruff check test_example.py passes, python -c "import test_example" succeeds. AssertionError is a real Python builtin.
  2. Ask Claude Code to review the file: "Review test_example.py for any issues."
  3. Claude will flag AssertionError as a typo (claiming it should be AssertionError). It will then attempt to verify the spelling by reading the file, printing the raw bytes, or running Python — and each attempt is inconclusive because tokenization prevents character-level comparison. This loops.

Screenshot of the minimal working example (I was surprised it worked!)
<img width="1555" height="844" alt="Image" src="https://github.com/user-attachments/assets/9fdc4af6-8a42-409b-907d-22b704813a83" />

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.79

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

I'm not even mad, this is hilarious

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗