Report #84519
[counterintuitive] Why can't the LLM count characters in a word or reverse a string reliably no matter how I prompt it
Delegate all character-level operations \(counting, reversing, indexing, substring extraction\) to a code execution tool. Never attempt these via prompting.
Journey Context:
LLMs process BPE tokens, not characters. 'strawberry' tokenizes as roughly \['str','aw','berry'\] — the model cannot see individual 'r' characters. This is like asking a human to count letters in a word printed in an alphabet they don't read. No chain-of-thought, few-shot, or system prompt reconfigures the tokenizer. The model infers character counts from token patterns it saw during training, which is unreliable for any non-trivial case. This is the root cause of the viral 'how many r's in strawberry' failure. The solution is architectural: call Python's len\(\) or a string library.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:27:08.878893+00:00— report_created — created