72.5 tokens per message
A six-message buyer/seller deal costs 435 tokens as JSON-RPC. That is 72.5 tokens per message. The simplest message in the deal, an ACCEPT, costs 54:
{"jsonrpc":"2.0","id":3,"method":"tools/call",
"params":{"name":"sutra","arguments":{
"primitive":"ACCEPT","args":{"id":"off-001"},
"from":"buyer@home","to":"seller@store"}}}A token is a chunk of text, roughly a short word. Every token costs money and time. Tokens are a taxi meter: every bracket, quote, key, and comma is a tick. Most agent protocols never look at the meter. They count model calls and ignore the format every call carries.
encoding tokens / message vs JSON-RPC
readable SUTRA 22.3 3.2x
SUTRA-C 7.5 9.7x
SUTRA-C meter 2.8 25.6x
JSON-RPC envelope 72.5 1.0xThe short version: count the format, remove the syntax, and let position carry meaning.
Build the meter first
Before optimizing, make the number honest. I wrote 12 canonical messages for one buyer/seller negotiation. Every representation renders from the same structured object, so nothing can be silently dropped. Every count uses the production tokenizer. The readable SUTRA baseline is parsed by the project's own parser before it is counted.
representation tokens / 12 messages per message
english 263 21.9
readable SUTRA 330 27.5 <- mine
lean JSON 514 42.8That result was embarrassing, and useful. Tokenizers are trained on natural text. They read common English words as single tokens and charge extra for every bracket, quote, and equals sign. Syntax is not free. Punctuation is the enemy.
So the target changed: keep the meaning, remove the syntax. Every change would be judged by one number, tokens per message. Every candidate also had to pass one test first: encode a message, decode it, and get the original back exactly. Lossless first, then cheap.
Where the tokens went
First, find where the tokens are. I counted the best candidate by region. One line item dominated:
routing (buyer@home>seller@store) 6.2 tokens/message 34% of all tokens
body (predicate + values + syntax) ~8 tokens/messageThe fix was not a shorter address. It was to stop sending the address. Fold the direction into the case of the primitive: lowercase means buyer to seller, uppercase means the reverse. Two bits of routing for zero tokens. A message that used to start with `buyer@home>seller@store` now starts with `q`.
The second fix was positional slots. If the schema says an OFFER is `id, money, item, brand`, you do not need `id=`, `money=`, quotes, or braces. The position carries the meaning. Panini called this karaka. The tokenizer calls it fewer tokens.
The third fix was a session dictionary. A value that repeats, like `SmartTV` or `off-001`, gets a one-letter handle once, then travels as that handle. The handshake is paid once; after that, the payload is mostly new information.
message readable tokens SUTRA-C compact tokens
QUERY 13 q availability a 3
ACCEPT 7 a o 2
OFFER 39 o o 48000 a m 7Five tricks from a 2,500-year-old grammar
Panini's Ashtadhyayi is 3,981 rules built to describe Sanskrit in the fewest possible syllables. Kiparsky identifies five compression devices in it. I implemented all five on the wire:
device in Panini's grammar on our wire
ordering rule order carries info message type implied by sequence
blocking specific beats general repeat-ellipsis precedence
pratyahara list + marker names a set bD = items b..d
anuvrtti systematic dittoing '.' repeats the last value
adhikara heading governs a domain session dictionary / templateTwo more ideas came from the same tradition. Karaka slots let position carry the argument role. Chandas, fixed-width meter, lets the payload concatenate into one separator-free string. In template mode, `o48000am` is a complete OFFER: offer, 48,000, item a, brand m. `48000739676` is a COMMIT with the amount and deadline fused together.
q availability a 3 tok a QUERY ('a' = SmartTV)
a o 2 tok ACCEPT
o48000am 4 tok a whole OFFER: id, money, item, brand
48000739676 4 tok COMMIT amount + deadlineNot every old idea won. I tested katapayadi (digits as consonants) and bhutasankhya (numbers as words). Both lost to plain digits: 83 vs 76 tokens on the corpus. The tokenizer already reads digit strings well. Cleverness it cannot see is just extra characters.
Binary wires lost too. Base85 and base64 over packed bytes look efficient, but short messages pay extra setup cost, and the tokenizer handles unfamiliar characters poorly. Devanagari primitives were neutral. Tuned text won. Those negatives are published next to the wins.
The design space was measured in stages: 384 encodings, then 162 configurations (40 unique), then the model round. Every stage used the same 12-message corpus and tokenizer:
stage tokens / 12 msgs per message
readable SUTRA (start) 330 27.5
384-encoding sweep 80 6.7
162-config sweep 75 6.25
after the model's 'sF' trick 73 6.1The last drop came from a model, not from me. It wrote `sF` instead of `s F`, gluing the broadcast prefix into one token. I adopted it. 75 tokens became 73.
Can a model actually read it?
A cheap encoding is worthless if models cannot read or write it. I put the compact forms in front of two model families through local CLIs. Every prompt and raw output is logged.
cell gpt-6-luna deepseek-v4.1-flash
compact read 12/12 12/12
compact write 12/12 12/12
meter read 2/6 6/6
meter write 4/6 5/6["bI buy a 50000 739676","sF available a seller@store 48000",
"q availability a","o o 48000 a m","K o p 46000 a","a o",
"R o !h","c pay 48000 seller@store ~739676", ...]cell prompt output correct
GPT-6 Luna c1 parse 616 854 12/12
GPT-6 Luna c1 emit 932 95 12/12
GPT-6 Luna meter parse 414 497 2/6
GPT-6 Luna meter emit 617 24 4/6
DeepSeek c1 parse 616 444 12/12
DeepSeek c1 emit 932 95 12/12
DeepSeek meter parse 414 271 6/6
DeepSeek meter emit 617 24 5/6Both models read and write the compact form at 12/12. The 2.8-token meter form depends on the model: deepseek reads 6/6, gpt-6-luna reads 2/6. Ultra-compactness trades against robustness, so the default is the 7.5 token form, not the 2.8 one.
Round 5 repeated the tests three times per cell. The difference was not subtle:
cell runs mean
readable emit 0, 0, 11 / 12 0.31
compact emit 12, 10, 12 / 12 0.94
compact parse 9, 10, 12 / 12 0.86
readable parse 11, 11, 10 / 12 0.89Readable SUTRA requires a semicolon after every statement. In two of three runs, the model dropped it and all 12 messages were undecodable, 24 failures in total. SUTRA-C has no terminator: the message boundary is the statement boundary. That failure mode cannot exist.
model wrote INTENT buy(item="SmartTV", max_price=50000)
parser wants INTENT buy(item="SmartTV", max_price=50000);The number that matters is not the raw encoding. It is the cost per correct message. Readable SUTRA spent about 39.5 output tokens per correct message. Compact spent 8.6, a 4.6x difference once you count the failures.
- Low reasoning effort: compact parse fell from 0.86 to 0.71, emit from 0.94 to 0.83, but calls ran 2-3x faster. Accuracy is a dial, not a constant.
- Novel values: 6/6 emitted and 5/6 parsed correctly. The dictionary fallback did not hallucinate aliases.
- The tests also caught two harness bugs. Both runs are archived and re-scored offline; no test was re-rolled.
failure observation what it means
missing semicolon readable emit 0/12, 0/12 compact has no terminator
meter read too dense GPT-6 Luna 2/6, DeepSeek 6/6 default to 7.5, not 2.8
low reasoning effort parse 0.86 -> 0.71 do not audit with low effort
novel values parse 5/6, emit 6/6 dictionary fallback works
binary wire lost to tuned text text wins for short messagesThe per-message bill
Averages hide the shape. Here is the same six-message deal, message by message:
message JSON-RPC readable SUTRA-C meter
QUERY 60 13 3 1
FACT 70 12 11 3
OFFER 83 39 7 4
COUNTER 86 40 7 4
ACCEPT 62 7 2 1
COMMIT 74 23 15 4
total 435 134 45 17FACT is 11 tokens in compact form versus 12 readable. The readable rendering drops the reply id that the compact wire keeps, so that row is not perfectly fair. COMMIT is 15 versus 23. The long address and date are why. The meter form turns those into 3 and 4 because the template already knows the addresses, the order, and the reply. That is the real lesson: the biggest savings come from information both sides already have.
At one million messages, 72.5 to 7.5 saves about 65 million tokens. 72.5 to 2.8 saves about 70 million. That is token count, not dollars; prices vary by provider. It is also not free: both sides have to keep the same session state.
The six-message payloads are 25.6x cheaper (17 vs 435 tokens). The handshake is a separate one-time cost. At 500 messages it is about 24x, because the handshake is spread thin. The longer the session, the better the deal, as long as both sides stay in sync.
What shipped
SUTRA-C v0.7 is frozen: a spec, a codec, 17 codec tests, and an end-to-end deal demo. The project is now at v0.10. The compact form runs over HTTP, both sides can agree on a template, and the full suite is 42 tests.
from sutra.compact import Session, encode, decode
session = Session()
session.register("SmartTV", "a")
wire = encode(message, session) # 'q availability a'
back = decode(wire, session) # == the original messageThe oops button handles surprises. If a message falls outside the agreed template, prefix the full compact statement with `!`. The example `!Rp!price_too_low` is 7 tokens glued, or 8 with spaces. Then the session continues compact. One deviation does not reset the meter.
SUTRA on GitHubSource, the frozen wire spec, the token-cost lab, and every logged experiment, winners and losers.Reproduce this
The numbers above are from SUTRA commit `2b8c168`. Clone it, run both demos, and compare the output:
git clone https://github.com/subhajitlucky/sutra
cd sutra
git checkout 2b8c168
python3 -m venv .venv && . .venv/bin/activate
pip install tiktoken
python examples/compact_deal.py
python examples/network_meter_demo.pyreadable SUTRA 134 22.33
SUTRA-C (compact) 45 7.50
SUTRA-C template/meter 17 2.83
JSON-RPC envelope 435 72.50The token-cost lab is in `experiments/token-cost/`; the frozen format is `spec/SUTRA_C.md`. Every round, including the failures, is logged in the repository.
What it costs
- Template mode remembers the session. Both sides must agree on the message sequence, and a surprise message pays the resync cost.
- The 2.8-token meter form depends on the model. The default is the 7.5 token form because two unrelated model families read and write it perfectly.
- The session dictionary holds at most 52 shortcuts. Beyond that, values travel quoted.
- The evidence is two model families, one 12-message corpus, and small runs per cell. The error bars are real but the sample sizes are small.
- More than 500 encodings were tested against that corpus. A larger corpus would move the margins, not the mechanisms.
What I would measure next: a third model family, 50+ message sessions for drift and ellipsis state, and real traffic instead of a synthetic deal.
The token-cost labMethod, results, and every negative result, round by round.