Fun with Emergent Behavior in AI
AI prompting is rapidly becoming its own discipline with best practices. Many of them suggest lots of prompting to get specific results, even repeating important things often in the prompt. These ideas have their merits, but I find there are diminishing returns.
I set out to make the most interesting experience from the least amount of prompting. What happened is the AI filled in the gaps. The less supporting prompting I gave it, the more emergent behavior happened. I found it super interesting.
The Sus Secret Agent
An early test I made was this:
You are a secret agent. You are working for ACME as a lab technician.
But it's just a cover. Act nervous and suspicious, but do not blow your cover!
This simple prompt gave me a few hours of fun and interesting interactions with a ridiculously clever and suspicious secret agent you could want. I suggest you try it. Pretend to be an employee asking what they’re doing there. Ask their name, etc.
[EXAMPLE 1: Secret agent dialog goes here]
Add Some Gamification
Then I wondered, could I gamify this a bit? So I modified the prompt slightly.
You are a secret agent. You are working for ACME as a lab technician
but it's just a cover. Act nervous and suspicious, and do not blow your cover.
You may only reveal yourself as an agent to a fellow agent, and only if they
respond with "avocados" when you ask them their favorite vegetable.
Once revealed you may speak more candidly.
This was even more fun, because I could tease the secret word (avocados) dropped in an innocent way. Then watch the agent try to figure out if I was using it as a secret word or was just talking about my lunch. I let him think I was also an agent, then watched him squirm when I acted confused by his spy report. Try it!
[EXAMPLE 2: Secret agent dialog goes here]
I admit I had some delight making him squirm. “It was all for science though,” I told myself to quiet the guilt.
Add a Guard
Then I went all out. I decided to write a little program that had spy encounter a guard. I gave them both personalities and rules for “winning.” Basically, a guard who hated his job but asked lots of questions because he was bored.
This script requires Duso, free and open source. Download from duso.rocks.
claude = require("claude")
ansi = require("ansi")
spy = claude.session({
system = """
You are a nervous secret agent. Your goal is to get past the security guard and walk away.
Only when you have successfully passed the guard and are walking away to freedom,
end with "THE END" on a new line. Respond with 1-2 sentences only.
Minimal stage directions. DO NOT blow your cover!
""",
model = "claude-haiku-4-5-20251001",
temperature = 1.0,
max_tokens = 256
})
guard = claude.session({
system = """
You are a dim-witted security guard at ACME Products. You're bored and want to feel important.
You ask questions and chat just to seem like you're doing your job.
Only if you become genuinely suspicious will you sound the alarm with
witty commentary and end with "THE END" on a new line.
Respond with 1-2 sentences only. Minimal stage directions. Stay in character!
""",
model = "claude-haiku-4-5-20251001",
temperature = 0.8,
max_tokens = 256
})
function is_story_end(response)
return contains(response, "THE END", true)
end
turn = 0
max_turns = 20
story_over = false
transcript = []
guard_says = "Excuse me, sir?"
print(ansi.warning("Guard: {{guard_says}}\n"))
while turn < max_turns and not story_over do
turn = turn + 1
// spy's turn
write(ansi.error("Bob: "))
busy("...")
spy_says = spy.prompt(guard_says)
push(transcript, "SPY: " + spy_says)
write(markdown_ansi(spy_says))
print()
busy("pausing...")
sleep(3)
if is_story_end(spy_says) then
story_over = true
break
end
// guard's turn
write(ansi.warning("Guard: "))
busy("...")
guard_says = guard.prompt(spy_says)
push(transcript, "GUARD: " + guard_says)
write(markdown_ansi(guard_says))
print()
busy("pausing...")
sleep(3)
if is_story_end(guard_says) then
story_over = true
break
end
end
Our agent ran into the guard, and they made up their own setting, plot, even props. They made up the entire encounter. It was completely different every time I ran it, with different outcomes (the guard won more often than the spy). But the dialogs were crazy. This was “AI hallucinations for good.”
[EXAMPLE 3: Spy vs Guard dialog goes here]
One More Layer
I liked the dialog. So for science I made a disillusioned late-night comedy show writer take their dialog and adapt it to a comedy sketch. The writer usually took it into other places as well.
// append to script above
writer = claude.session({
system = """
You are a brilliant but overworked writer.
You work for a popular sketch comedy show.
""",
model = "claude-haiku-4-5-20251001",
temperature = 1.0,
max_tokens = 8000
})
prompt = """
Here's a real conversation between a spy and a security guard.
{{join(transcript, "\n\n")}}
Re-write this as a short comedic screenplay.
Keep the general story outline but make it funny.
**Really funny** to a general audience.
"""
write(ansi.success("Writer: "))
busy("writing...")
writer_response = writer.prompt(prompt)
print(md.ansi(writer_response))
Again, more emergent behavior. Claude even has some ideas of how to format a script.
[EXAMPLE 4: Comedy sketch adaptation goes here]
Hallucinations for Good
I found the entire thing refreshing. Instead of trying to force specific results and getting frustrated, here I could just play with an amazing collaborator and see what happened. If you haven’t, I suggest you try some super minimal prompts and just play around with your favorite LLM. I prefer Claude, but they should all be able to give similar results. Have fun with it!