AI & Engineering

How Py detects when you're frustrated — before you say a word

·· 8 min read

Last month, a MyPyMentor user sent Py three messages in a row. The first was about 60 words — a genuine question about list comprehensions with context and an example. The second was maybe 20 words. The third was: 'i dont get it'. No capital. No punctuation. No explanation of what 'it' referred to.

Py caught all of that — and changed how it responded. Not because we wrote a rule that says 'if message is short, be nicer'. Because there's a scoring system running on every message, in real time, that tries to estimate where a learner is emotionally.

The five signals

Frustration in text is hard to detect precisely because people expressing it rarely say 'I am frustrated'. They go quiet. They repeat themselves. Their messages get shorter. Here are the five signals we score, and why we chose them.

1. Frustration keywords (weight: 0.30)

The highest-weighted signal. We look for words and phrases that correlate strongly with cognitive overload or emotional frustration: 'confused', 'lost', 'don't understand', 'hate this', 'doesn't make sense', 'I give up', 'stuck'. Each keyword that appears increments the score. This is the most direct signal, which is why it carries the most weight.

2. Repeated questions (weight: 0.25)

If someone asks about the same concept twice in a session — even phrased differently — that's a strong signal the previous explanation didn't land. We do a rough semantic comparison of the current question against the last five questions in the session. A match bumps the frustration score.

3. Short responses (weight: 0.15)

When people are engaged, their messages have length. When they're losing the thread, messages get shorter. We track average message length over the last three exchanges. A sharp drop triggers this signal. The weight is lower because short messages can also just mean someone's asking a quick clarifying question.

4. ALL CAPS usage (weight: 0.10)

Capitalisation patterns correlate with emotional intensity. Someone writing 'WHY DOESN'T THIS WORK' is in a different place than someone writing 'why doesn't this work'. This signal has a low weight because it's a noisy indicator — some people just type in caps — but in combination with the others, it matters.

5. Multiple question marks (weight: 0.10)

Multiple question marks in a single message — 'why?? what?? I don't get it??' — are a subtle but consistent signal of mounting frustration. They tend to appear when someone isn't asking a specific question but expressing a feeling of being overwhelmed.

What Py does differently at high frustration scores

When the frustration score crosses a threshold, Py changes mode. It stops building on complexity. It goes back to the most recent concept that seemed unclear and re-explains it from a different angle. It asks questions instead of giving answers. It validates before it teaches — 'this is genuinely one of the trickier concepts, you're not missing something obvious'.

We also slow down the pacing signals. If Py was about to introduce a new concept, it waits. Getting through the moment of confusion matters more than covering more ground.

Why this matters more than it might seem

Frustration is the main exit ramp. People don't quit Python because they hit a wall. They quit because they hit a wall and nothing helped them over it. An AI that detects frustration and responds to it — rather than just powering forward with the next explanation — is meaningfully different from one that doesn't.

That's the design goal. Not smarter answers. A more attentive teacher.

AA

Ayodele Ayodeji

Founder, MyPyMentor

Founder of MyPyMentor. Building AI tools that help people learn Python without quitting.

Ready to start learning Python?

Free to start. Py is waiting.

Start learning free