🔧 ProgrammierungWebKit Features for Safari 27.0(17.09.2026 um 13:30 Uhr)
🔧 ProgrammierungWebKit Features for Safari 27.0(17.09.2026 um 13:30 Uhr)
🔧 Programmierung 🕛 vor 1 Monat 5 Min Lesezeit
0

Smash Stories: The Bug That Whispered for Two Weeks Before I Heard It

↗ Quelle (dev.to)
🗣️ Stimme:

This is a submission for .



My AI agent was misreading financial data 1 in 5 times. No crashes. No exceptions. Just quiet, dangerous wrong numbers.



Some bugs scream. Null pointer exceptions. Segmentation faults. Crash logs that light up your screen like a Christmas tree.



This one whispered.



The Setup



I'm building an AI agent that controls Android phones using Gemma 4. Natural language commands get parsed into structured JSON, translated into ADB instructions, and executed on-device. No cloud. No API keys. Just a phone that does what you tell it.



By Day 16, I'd hit a milestone: the agent completed its first multi-app workflow. "Copy my bank balance and send it to Mom on WhatsApp."



Three apps. Banking → WhatsApp. Seven steps. Success.



I celebrated. Shipped the code. Published the build log. Went to sleep feeling like an engineer.



Then I tested it again the next morning. And again. And again.



The Whisper



Out of 50 test runs, the balance was wrong 10 times. Twenty percent.



The agent wasn't crashing. No exceptions were thrown. The logs showed success. But "₦15,000" was quietly becoming "₦15.000" or "₦15,00" or "₦15000." A currency symbol mistaken for a digit. A comma parsed as a decimal. A zero dropped from the end.



The wrong number was being sent to Mom. And I had no idea for two weeks because nothing was failing loudly enough to make me look.



The Root Cause



I traced the problem to a single bad assumption: I was treating OCR output as ground truth.



Banking apps scored F on my accessibility audit. Zero UI labels. The agent had to rely entirely on optical character recognition to read anything on screen. And banking apps are a hostile environment for OCR:




  • Condensed fonts designed for dense data, not readability

  • Grey text on slightly-darker-grey backgrounds

  • Currency symbols (₦) that OCR models frequently confuse with digits

  • Commas in large numbers that OCR sometimes parses as decimal points



One screenshot. One OCR pass. One number stored in memory. No verification. No double-check. No sanity check. I had built a pipeline that trusted a single, unreliable data source with financial information.



The Fix: Defense in Depth



I didn't try to make the OCR better. Tesseract and ML Kit are what they are. Instead, I built a three-layer verification system that treats every financial number as unverified until proven otherwise.



Layer 1: Format Validation



Before a number is accepted, it must match a valid currency pattern. The regex checks for currency symbols (₦, $, £, €) followed by properly formatted digits. Anything that doesn't match gets rejected instantly.






CODE

python
pattern = r'[₦$£€]?\s?\d{1,3}(?:,\d{3})*(?:\.\d{2})?'
matches = re.findall(pattern, extracted_text)
if not matches:
return False, "", "No currency values found"

This alone catches about half the errors garbled text, partial reads, and non-numeric data that OCR sometimes returns.

Layer 2: Double-Read Confirmation

The agent captures two separate screenshots and runs OCR on both independently. If the numbers match, the value is accepted with high confidence. If they differ, a third screenshot is captured and the best-of-three wins.

# Read twice
text1 = extract_text(screenshot1)
text2 = extract_text(screenshot2)

num1 = extract_number(text1)
num2 = extract_number(text2)

if num1 == num2:
return True, num1, "High confidence"

# Tiebreaker
text3 = extract_text(screenshot3)
num3 = extract_number(text3)

if num1 == num3:
return True, num1, "Medium confidence (2/3)"
elif num2 == num3:
return True, num2, "Medium confidence (2/3)"

This catches transient OCR errors—pixel-level variations between screenshots that produce different readings. The cost is 4-6 extra seconds per financial read. The benefit is catching errors that would otherwise silently corrupt data.

Layer 3: Range Validation

Even a correctly formatted, double-confirmed number can be nonsensical. A balance of "₦0" might mean an empty account—or it might mean the OCR failed completely and returned nothing. A balance of "₦999,999,999,999" is almost certainly an error.

if 1 <= value <= 1_000_000_000:
return True
else:
return False # Suspicious. Re-read.

This catches the edge cases—numbers that pass format and double-read checks but are clearly wrong in context.

The Celebration

After implementing all three layers, I re-ran the 50-test battery. The error rate dropped from 20% to 6%. For the specific "₦15,000" test case, 20 out of 20 reads were correct with double-read confirmation.

The agent now succeeds 19 times out of 20 on multi-app financial tasks. The one failure is a timeout (banking app loads slowly on an old device), not a misread. And critically, when verification fails, the agent now knows it failed. It reports low confidence and aborts the task instead of silently sending wrong data.

What This Taught Me

The bug wasn't in the OCR engine. It was in my architecture. I had built a system that trusted a single, unreliable data source with financial information. That wasn't a Tesseract problem. That was a design problem.

The fix wasn't a better model. It was a better process. Three cheap, fast checks that together create confidence where no single check could. Defense in depth applied to data integrity.

This changed how I think about every feature I build. I now ask: "If this component silently returns wrong data, will I know? If not, where's the verification?"

The Code

The full verification system is open source on GitHub:

👉 github.com/Dexter2344/phone-agent

vision.py contains the verify_financial_data() function. agent.py calls it before storing any financial value in task memory.

The Build Log

I've been documenting this project publicly for 17 days on Dev.to. Every breakthrough, every dead end, every "why is this broken" debugging session at 1 AM.

This bug was Day 17. The one that almost shipped. The one that whispered.

It's not the loudest bug I've ever caught. But it's the one that taught me the most.

This is my entry for the Dev.to Smash Stories contest. The Gemma 4 model powers the agent's command parsing and reasoning. The verification layer is my own work.



Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
2 Quellen
The amount of e-waste caused by AI is underestimated: we can’t only include the servers
1 Quelle
Crusoe raises $3.9B to build massive data centers and small modular “AI factories”
1 Quelle
GitHub Release: openai/codex vrust-v0.156.0-alpha.1 (18.09.2026)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Smash Stories: The Bug That Whispered for Two Weeks Before I Heard It

Thematisch verwandte Begriffe: Smash, Stories, That, Whispered · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...