The Math · JavaScript · Python · Used by · npm · PyPI · Vostride AI AI agents pass IDs through prompts, tool calls, logs, traces, and memory. UUIDs are great for databases, but they are expensive in context windows and hard for humans or LLMs to copy reliably. id-agent gives you word-based IDs that are compact in modern tokenizers, readable in logs, and configurable by collision budget. Where UUIDs cost about 23…
AI agents pass IDs through prompts, tool calls, logs, traces, and memory. UUIDs are great for databases, but they are expensive in context windows and hard for humans or LLMs to copy reliably. id-agent gives you word-based IDs that are compact in modern tokenizers, readable in logs, and configurable by collision budget.
Where UUIDs cost about 23 tokens and get hallucinated by LLMs, id-agent produces memorable word-based IDs at about 14 tokens with strong collision resistance. It is built for the context window, not just the database.
Human-readable – word-based IDs that humans and LLMs can remember.
Token-efficient – every word in the wordlist is exactly 1 BPE token on o200k_base.
Collision-safe – configurable entropy from about 12 to 192 bits.
Validated inputs – descriptive validation on all public APIs.
Used by
agent-qa – open-source, self-improving QA agent by Vostride. Its test, suite, run, and observation IDs come from id-agent.
Nutstore Sync – Nutstore’s (坚果云) Obsidian sync plugin. Its built-in AI assistant uses id-agent for chat session, agent task, and tool result IDs.
Each word is drawn uniformly from a curated 4096-word list (2^12). Every position in the ID is an independent random selection:
Entropy per word = log2(4096) = 12 bits
Total entropy = words * 12 bits
ID space = 4096^words = 2^(words * 12)
This holds regardless of individual word length. A 3-character word and a 6-character word both contribute exactly 12 bits because the attacker must guess from the same 4096-word pool.
Collision Probability
The probability of at least one collision among n randomly generated IDs:
P(collision) ~= n^2 / (2 * 2^b)
where b = total bits of entropy
This is the birthday paradox approximation, valid when P is small (P < 0.01).
Words
Bits
ID Space
P @ 1K
P @ 10K
P @ 100K
P @ 1M
P @ 1B
50% collision at
3
36
6.9 * 10^10
7.3 * 10^-6
7.3 * 10^-4
7.3 * 10^-2
about 1
about 1
about 309K items
4
48
2.8 * 10^14
1.8 * 10^-9
1.8 * 10^-7
1.8 * 10^-5
1.8 * 10^-3
about 1
about 20M items
5
60
1.2 * 10^18
4.3 * 10^-13
4.3 * 10^-11
4.3 * 10^-9
4.3 * 10^-7
0.43
about 1.3B items
8
96
7.9 * 10^28
6.3 * 10^-24
6.3 * 10^-22
6.3 * 10^-20
6.3 * 10^-18
6.3 * 10^-12
about 331T items
10
120
1.3 * 10^36
3.8 * 10^-31
3.8 * 10^-29
3.8 * 10^-27
3.8 * 10^-25
3.8 * 10^-19
about 1.4 * 10^18 items
UUID v4
122
5.3 * 10^36
9.4 * 10^-32
9.4 * 10^-30
9.4 * 10^-28
9.4 * 10^-26
9.4 * 10^-20
about 2.7 * 10^18 items
The default 8-word ID is safe for more than 300 trillion items before reaching a 50% collision chance. Most applications will never generate more than a few million IDs.
All measurements use o200k_base (GPT-4o, GPT-4.1, o1, o3) through tiktoken. Token counts vary slightly per ID because of BPE merge behavior with hyphens. Values below are averages over 100 samples:
Format
Avg Tokens
Entropy
Tokens Saved vs UUID
Savings
UUID v4
about 23
122 bits
–
–
id-agent (3 words)
about 5
36 bits
about 18
78%
id-agent (5 words)
about 8
60 bits
about 15
65%
id-agent (8 words, default)
about 14
96 bits
about 9
39%
id-agent (10 words)
about 17
120 bits
about 6
26%
Choosing Word Count
The right word count depends on your scale. The default of 8 is deliberately conservative and globally safe.
Scale
Recommended
Entropy
Why
Dev/testing
words: 3
36 bits
Fast, memorable, about 5 tokens. Collides at about 300K items.
Team tools
words: 4
48 bits
Safe to about 20M items. Good for internal APIs.
Production SaaS
words: 5
60 bits
Safe to about 1B items. 65% token savings vs UUID.
High-volume / distributed
words: 8 (default)
96 bits
Safe to about 300T items. The safe default.
UUID-equivalent
words: 10
120 bits
Matches UUID v4 collision math.
Why Words Beat Hex
BPE tokenizers used by modern LLMs were trained on natural language. Short English words are single tokens by design. UUIDs are hex strings that split unpredictably:
id-agent’s wordlist is curated so every word is exactly 1 BPE token on o200k_base. The hyphens add about 1 token per 6 words due to BPE merge behavior. This is why word-based IDs are fundamentally more token-efficient than random hex or alphanumeric strings.
Implementations
id-agent is implemented as first-class packages for:
Both implementations use the same 4096-word list, separator rules, entropy model, prefix validation, and public behavior.
How It Works
id-agent uses a curated wordlist of 4096 English words, each verified as a single BPE token on the o200k_base tokenizer used by GPT-4o and GPT-4.1. Words are 3-6 characters and filtered for offensive terms and homophones.
Random IDs use cryptographically secure randomness. Deterministic IDs use HMAC-SHA256, mapping hash bytes to wordlist indices.
评论