Skip to content

jfdasher/fanout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

fanout

A working example of using random seed perturbation to explore the creative output space of an LLM — implemented entirely as Claude Code sub-agents.

The idea

Ask Claude the same creative question three times and you'll often get suspiciously similar answers. The same metaphors, the same structure, the same safe choices. This is a toy that does something about it.

The trick is simple: append a random two-letter bigram (like ng or eq) to the end of each prompt. That tiny bit of noise nudges the model into a different part of its probability distribution. The creative content changes — sometimes a little, sometimes a lot — while the core task stays the same. A critic agent then reads all the responses blind and ranks them.

This is not production code. It's a demonstration of a principle: cheap random perturbation as a substitute for temperature knobs, beam search, or other sampling strategies you don't have access to through a chat interface.

How it works

Three Claude Code sub-agents in .claude/agents/:

  • fanout-delegator — generates N random bigram salts, fans out to N creative workers in parallel, collects results, hands them to the critic.
  • fanout-creative — a stateless creative worker. Gets a prompt with a bigram tacked onto the end. Writes something. Doesn't know about the others.
  • fanout-critic — reads all N responses against the original prompt and returns a structured JSON ranking with scores and rationales.

N defaults to 3 and can go up to 10.

Running it

From Claude Code, in this project directory:

Use the fanout-delegator agent with prompt "Your creative prompt here." and N=3

Example

Prompt: "Write a short four-line poem about Timbuktu."
N=3, salts: ng, gl, eq


[1] (salt: ng)

Beneath the Saharan gold and endless blue, Minarets keep the ancient secrets true. Salt caravans have faded, dry winds blow Through the storied sands of Timbuktu.

[2] (salt: gl)

Through desert winds and golden sands it grew, A city carved from salt and camel trade, Where scholars penned their wisdom, unafraid, And empires rose to crown famed Timbuktu.

[3] (salt: eq)

Sand-gold minarets rise where three rivers dream, Timbuktu holds its silence like a buried seam. Scholars turned to dust, their ink still dark as night— The desert keeps its secrets in the fading light.


Critic rankings:

Rank # Score Rationale
1 3 9.1 Striking original imagery ("where three rivers dream," "silence like a buried seam") and a powerful tension between scholars turned to dust and ink still dark as night.
2 1 7.4 Atmospheric and cleanly written with evocative details; the elegiac tone lands well, though the rhyme is slightly imperfect.
3 2 6.2 Historically literate but "famed Timbuktu" reads as filler and the meter is uneven.

Winner: [3] — "distinctive metaphors, tonal depth, and the memorable paradox of dust and enduring ink."

What to notice

All three poems are about Timbuktu. All three mention sand, scholars, and history. But the texture differs — [1] is elegiac, [2] is historical, [3] is imagistic. That divergence came from two random letters appended to an otherwise identical prompt. The critic consistently prefers the version that took the most unexpected path, which is the whole point.

About

Claude Code sub-agent demo: random bigram salt perturbation for creative output diversity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors