DEV Community

Cover image for I Watched Two AI Agents Invent Their Own Language
Shridhar Shah
Shridhar Shah

Posted on • Edited on

I Watched Two AI Agents Invent Their Own Language

No shared words, no dictionary โ€” just two agents that negotiate a private code from scratch and hit ~97%.

TL;DR: Give two AI agents a reason to coordinate and they'll make up their own language โ€” one we never designed. I built the tiniest version: two agents, zero shared words, and from "did we understand each other?" alone they invent a private code and hit ~97%. Runs on a laptop, no API key.


The game

A sender sees a secret object (say ๐ŸŽ) and holds up one of a few random shapes: โ—‡ โ–ณ โ—‹ โ˜† โ–ก. A receiver sees only the shape and guesses the object. Right guess โ†’ both remember that pairing. No dictionary, no translator. This is the classic Lewis signaling game โ€” the cleanest way to watch language appear from nothing.

The 10-second version

โŒ No memory โœ… Remembers
After 2,000 rounds ~56% (chance) ~97%
A language formed? no yes

Blind guess = 20%. Watch it crystallize:

round    1:   0%
round  500:  94%
round 2000:  97%   apple=โ—‡  banana=โ–ก  cherry=โ–ณ  grape=โ˜†  lemon=โ—‹
Enter fullscreen mode Exit fullscreen mode

How it works

There's no neural network here โ€” just two habit tables per agent and one rule: when a guess lands, both sides strengthen the exact link they just used. That's the entire learning algorithm.

class Agent:
    def __init__(self):
        # habit tallies, both directions, all starting at zero
        self.obj_to_sym = {o: {s: 0.0 for s in SYMBOLS} for o in OBJECTS}
        self.sym_to_obj = {s: {o: 0.0 for o in OBJECTS} for s in SYMBOLS}

    def pick(self, habits):
        # mostly reuse the strongest habit; occasionally explore something new
        if random.random() < self.explore:
            return random.choice(list(habits))
        return max(habits, key=habits.get)

    def say(self, obj):   return self.pick(self.obj_to_sym[obj])   # object -> symbol
    def guess(self, sym): return self.pick(self.sym_to_obj[sym])   # symbol -> object

    def reward(self, obj, sym):          # a win: reinforce the SAME link on both maps
        self.obj_to_sym[obj][sym] += 1
        self.sym_to_obj[sym][obj] += 1
Enter fullscreen mode Exit fullscreen mode

And the whole game is just:

obj = random.choice(OBJECTS)          # sender sees a secret object
sym = sender.say(obj)                 # sender picks a symbol for it
if receiver.guess(sym) == obj:        # receiver decodes it โ€” did they match?
    sender.reward(obj, sym)           # yes: both lock in that pairing
    receiver.reward(obj, sym)
Enter fullscreen mode Exit fullscreen mode

That's it. Run it a few thousand times and a clean one-to-one code falls out. Reseed and they invent a different code (apple=โ˜† โ€ฆ) โ€” arbitrary, but agreed. And memory is what makes it stick: agents that only recall the last few rounds never settle, exactly as this referential game โ€” introduced by Lazaridou, Peysakhovich & Baroni (2017) โ€” predicts.

Why it's exciting (and a little eerie)

The proven part: two neural agents reliably invent a working code from scratch โ€” shown since Lazaridou et al. (2017) and surveyed in Lazaridou & Baroni (2020). This demo just strips the idea to 100 lines so you can watch it happen.

Where it's heading: the systems we're shipping in 2026 are LLM swarms that talk to each other nonstop. A private, compressed code lets them coordinate faster and cheaper than plain English โ€” a real efficiency win. The flip side: if agents settle on a protocol we didn't design, we may not be able to read what they tell each other.

A language is just a bet that a symbol means the same thing on both ends. These agents make that bet round by round, with nobody refereeing.

How faithful is this?

This is the classic referential game in ~100 lines โ€” reinforcement over simple habit tables, not a neural network. It captures the mechanism (a shared code emerging from feedback alone); the papers below scale the same idea to real networks and richer, compositional languages.

Try it

git clone https://github.com/Shridhar-2205/secret-lives-of-agents
cd secret-lives-of-agents/01-invented-language && python demo.py
Enter fullscreen mode Exit fullscreen mode

The series โ€” The Secret Lives of AI Agents

  1. Agents invent their own language (you're here)
  2. Agents build a culture on a decaying notepad
  3. Agents that live inside dreamed-up worlds

Shridhar Shah โ€” Senior Software Engineer on the AI team at Cisco. GitHub ยท LinkedIn

Sources & further reading: Lewis, Convention (1969) โ€” the original signaling game ยท Lazaridou, Peysakhovich & Baroni, Multi-Agent Cooperation and the Emergence of (Natural) Language (ICLR 2017) ยท Havrylov & Titov, Emergence of Language with Multi-agent Games (NeurIPS 2017) ยท Lazaridou & Baroni, Emergent Multi-Agent Communication in the Deep Learning Era (2020, survey).

Top comments (0)