DEV Community

Ercan Canhasi
Ercan Canhasi

Posted on Originally published at Medium on

The Mirror Test: LLM Self-Awareness and the Claude Code Leak

For quite some time I have been noticing a pattern that initially seemed like a minor inconvenience. After discussing it privately with colleagues, including Hakan Shehu , I began to recognize that the issue runs far deeper than surface-level tooling complaints. It is fundamental, structural, and in my view, deeply revealing. That realization pushed me to think more carefully, analyze the evidence, and research the broader implications.

The problem does not belong to any particular agent or product. It belongs to LLMs as a category. The inability to spontaneously apply self-knowledge is baked into how these models are built and trained, and no amount of prompt engineering or smarter wrappers will address it at the root.

In my view, this gap also points to what may be the most straightforward way of testing AI self-awareness, starting with coding agents and extending all the way up to frontier models. When a model cannot implicitly draw on its own nature to solve a problem, that is a meaningful signal worth paying attention to. The recent leak of the Claude Code source makes the point more concretely than any theoretical argument could.

The article proceeds as follows: first, the background and structure of the problem; then, real-world examples drawn from billion-dollar companies’ codebases; and finally, some conclusions about what all of this tells us about where we actually stand.

The Problem

When Claude, or any of the leading coding agents, is asked to handle a task that involves understanding human language, such as detecting frustration, interpreting intent, or classifying tone, it will almost instinctively reach for the same tools programmers have used for decades: lists of keywords, pattern matching, and regular expressions.

To be fair, there is nothing inherently wrong with that approach. It served the software industry well for many years, and in simple cases it still does.

But here is where it gets interesting. These coding agents are not just programs that happen to know about AI. They are themselves built on top of large language models. They understand nuance, context, sarcasm, and ambiguity in ways that no keyword list ever could. In other words, they already possess the perfect tool for the job. They simply never think to use it on themselves.

It would be like asking a master chef to taste a dish and having them reach for a printed flavor chart instead of just using their own palate. The better instrument is not somewhere else. It is the chef themselves.

The Best Solution

Interestingly, when explicitly told to use an LLM for the task, coding agents will comply, and they will do it well. The capability is clearly there. The knowledge is there. What is missing is the unprompted recognition that this is the right approach in the first place. They need to be told what they should, in theory, already know about themselves.

The Deeper Problem

Put simply, these models do not spontaneously reflect on what they are capable of when deciding how to solve a problem. They do not ask themselves: “What is the best tool available to me, given my own nature?” They just pattern-match to the most familiar solution and proceed.

*A note for the reader: this observation should not be confused with a critique of tool selection or tool usage. That is an entirely separate dimension. The argument here operates on a more fundamental level, one of identity and self-knowledge, not capability or workflow.

Insight: Modern coding agents have no internal model of what they fundamentally are. They do not know their own nature. And because they do not know their own nature, they cannot reason from it. In that specific and narrow sense, they fall below the self-awareness threshold of even the most primitive animals, not in intelligence, not in capability, but in the one thing that matters here: knowing what you are.

Possible objection: “So what? We as vibe coders can simply step in and guide them.”

The answer is more uncomfortable than it appears: a vibe coder who is not aware of their own blind spots cannot compensate for blind spots they have never recognized. You cannot patch a gap you cannot see.

An Even Deeper Insight

In my humble opinion, without this level of self-awareness, coding models will not be able to write better versions of themselves in the near future. Hence, no generally intelligent coder is possible, for now? For more on this, the next article will go deeper into this topic.

Examples

With the theoretical background in place, it is time to look at concrete evidence. Personal experience has its value, but let us start with something more verifiable: a real function pulled from the leaked Claude Code internal source, one that illustrates the problem more plainly than any argument could.

The Problem in Code: Regex-Driven Sentiment Detection

Here is the actual function from the leaked Claude Code internal source. It checks whether a given input string contains negative or frustrated language by matching it against a predefined regular expression of keywords and phrases:

export function matchesNegativeKeyword(input: string): boolean {
  const lowerInput = input.toLowerCase()
  const negativePattern =
    /\b(wtf|wth|ffs|omfg|shit(ty|tiest)?|dumbass|horrible|awful|piss(ed|ing)? off|piece of (shit|crap|junk)|what the (fuck|hell)|fucking? (broken|useless|terrible|awful|horrible)|fuck you|screw (this|you)|so frustrating|this sucks|damn it)\b/
  return negativePattern.test(lowerInput)
}
Enter fullscreen mode Exit fullscreen mode

The code above is reportedly sourced from the leaked internal source code of Claude Code, revealing how such systems may detect negative user intent.

This is a brittle, static list. It will miss novel expressions of frustration, misfire on quoted or ironic usage, and requires manual maintenance every time language evolves.

For my non-coder or vibe-coder friends, a simple analogy:

It’s like a mechanic using only a hammer in a workshop full of precision tools.

These agents are like experts at tracing shadows on the wall, unaware they could simply turn around and look at the object itself.

And if the reader will excuse the indulgence, that last one is the more Platonic of the two analogies.

The Better Solution: LLM-Based Tone Classification

Instead of relying on a brittle regex list, a self-aware coding agent would delegate this judgment to an LLM, the very technology it is an instance of. Here is a pseudocode blueprint for what that looks like:

FUNCTION detect_negative_or_frustrated_intent(user_text, conversation_context):

    INPUT:
        user_text
        conversation_context // optional recent messages, task state, prior errors

    PREPROCESS:
        normalized_text = trim(user_text)
        IF normalized_text is empty:
            RETURN {
                label: "neutral",
                confidence: 0.0,
                reason: "empty input"
            }

    BUILD_PROMPT:
        system_instruction = """
        You are a tone classifier for a coding assistant.
        Decide whether the user's message expresses:
        1. neutral
        2. mildly negative
        3. frustrated
        4. abusive

        Use meaning and context, not only keywords.
        Distinguish between:
        - harmless quoting or discussion of bad words
        - actual frustration directed at the tool or task
        - direct abuse toward the assistant or a person

        Return strict JSON only.
        """

        user_payload = {
            "message": normalized_text,
            "context": conversation_context,
            "task": "Classify negativity/frustration in the message",
            "output_schema": {
                "label": "neutral | mildly_negative | frustrated | abusive",
                "confidence": "0.0 to 1.0",
                "contains_negative_sentiment": "true | false",
                "should_trigger_recovery_behavior": "true | false",
                "reason": "short explanation"
            }
        }

    CALL_LLM:
        llm_result = LLM(system_instruction, user_payload)

    VALIDATE_OUTPUT:
        parsed = parse_json(llm_result)
        IF parsed is invalid:
            RETURN fallback_rule_based_classifier(normalized_text)

    APPLY_BUSINESS_RULES:
        IF parsed.label == "abusive":
            action = "apply_safety_or_boundary_response"
        ELSE IF parsed.label == "frustrated":
            action = "acknowledge_problem_and_offer_fix"
        ELSE IF parsed.label == "mildly_negative":
            action = "respond_supportively_and_continue"
        ELSE:
            action = "continue_normally"

    RETURN {
        label: parsed.label,
        confidence: parsed.confidence,
        contains_negative_sentiment: parsed.contains_negative_sentiment,
        should_trigger_recovery_behavior: parsed.should_trigger_recovery_behavior,
        action: action,
        reason: parsed.reason
    }
Enter fullscreen mode Exit fullscreen mode

This approach understands meaning, not just surface patterns. It can distinguish a frustrated user from someone quoting an error message. It handles sarcasm, context, and novel phrasing. And critically, it does so by using the same capability the agent already has access to, but never thought to reach for.

Conclusions

This is only one example of many I have experienced while using coding agents. The regex-driven, keyword-based fallback is not an isolated quirk. It is a pattern, and a revealing one. It suggests that the gap between what these models know and what they apply to themselves is not a minor technical limitation, but a structural blind spot baked into the LLMs themselves.

Self-awareness, even in its most primitive biological form, is what allows an agent to match the right tool to the right problem. Without it, even the most capable coding agent remains a sophisticated pattern-matcher, powerful within the boundaries it was shown, but unable to reason about its own nature or leverage its own deepest capabilities.

The irony is sharp: the very technology that could solve these interpretation problems more elegantly than any regex ever could sits unused, not because it is unavailable, but because it was never considered.

This might also be one of the simplest and most honest tests we have for measuring how far we are from AGI. Not benchmarks, not reasoning scores, not coding competitions. Just one question: can the model, unprompted, recognize that its own nature is the best tool for the task in front of it? The day a coding agent reaches for an LLM to solve a language problem without being told to, not because it was fine-tuned to do so but because it reasoned its way there, that day will tell us something benchmarks never could. We are not there yet.

I am sure others have encountered various experiences in this same category, and I would very much like to hear from you. The more we map these blind spots collectively, the better we understand what truly remains between today’s coding agents and anything deserving the label of general intelligence.

Originally published at https://www.linkedin.com.

Top comments (0)