Report #38809
[counterintuitive] Why can't the model count characters in a string or find character positions despite clear instructions and few-shot examples?
Route all character-level operations \(counting, indexing, reversing, substring by position\) to a code execution tool. Never rely on the model's direct text output for character-precise tasks, no matter how many examples you provide.
Journey Context:
The widespread assumption is that if a model can write code that counts characters, it should be able to count characters itself. This is wrong because of tokenization: text is preprocessed into subword tokens before the model ever sees it. 'Strawberry' becomes tokens like \['Str', 'aw', 'berry'\] — the model never sees the 3 individual 'r' characters. This is an information-theoretic gap, not a reasoning deficit. No amount of chain-of-thought prompting, few-shot examples, or model scaling closes this gap because the character-level information is destroyed before the transformer layers. The model can only estimate character counts from statistical patterns in training data, which works for common words but fails unpredictably on novel strings, mixed case, Unicode, or edge cases. Developers waste hours iterating on prompts when the correct action is to recognize this as an architectural blind spot and delegate to code execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:37:06.935033+00:00— report_created — created