library / AI and blockchain / SI0016
llms.txt for agents
You get a script that prints an llms.txt for a Solana agent: a title, a summary, live slot facts, the commitment rule, one line per account you name, and a docs list. Run it on a schedule and serve its output.
What an llms.txt file is
llms.txt is a convention from 2024: a markdown file at the root of a site, such as /llms.txt, that tells a language model what the site holds and where to read more. No client has to fetch it, and which agents do depends on their tooling. Treat it as context you hand over, and check that your own agent reads it. You write one for your own agent project, and the script below builds it.
The format has a fixed order. An H1 with the name is the only required part. A blockquote with a short summary follows. After that come paragraphs and lists with no headings, then H2 sections that are link lists, each line written as [name](url): note. A section named Optional holds links an agent can skip when its context is short. Some sites also publish a longer llms-full.txt with the full text inline.
For a Solana agent the open question is what to say about the chain. Documentation links stay true for months. A statement about slots or commitment goes stale when the network changes.
Why chain facts need a live read
Since the Alpenglow switch on mainnet (2026-10-21) a slot is about 200 ms and finalized sits 0 to 1 slots behind processed. Before it, finalized trailed by about 32. A file written in that era may tell an agent that finalized is far behind and that blocks carry vote transactions. Both are out of date: mainnet blocks carry no vote transactions since Alpenglow.
Agents also get one more fact wrong, which is the commitment a call uses. The JSON-RPC server defaults to finalized. @solana/kit 8.6.0 fills in confirmed when a call leaves commitment out. The same call can return different data depending on whether your agent speaks raw JSON-RPC or goes through kit. The generator passes commitment on every read and writes the rule into the file.
Even with explicit commitments, one read of processed, confirmed and finalized can show two of them equal or briefly out of order. The script prints the gap as a plain number and does not clamp it, so an agent sees what the chain said.
The generator
It is one file with one dependency, @solana/kit 8.6.0, and Node 24 runs the TypeScript directly. Set CARBIUM_KEY first; the script exits with a message when it is unset. CARBIUM_RPC_URL overrides the endpoint, which defaults to https://services.carbium.sh. The script prints a fixed H1, # Solana agent context, so swap your project name into the first string of the array that console.log joins.
// SI0016 · llms.txt for agents// https://carbium.sh/library/si/llms-txt-for-agents// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Build an llms.txt for a Solana agent from live reads. Run: CARBIUM_KEY=... node main.ts label=address ...import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, isAddress } from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) { console.error("Set CARBIUM_KEY to your Carbium API key."); process.exit(1);}const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const accounts = process.argv.slice(2).map((arg) => { const [label = "", value = ""] = arg.split("="); return { label, value };});if (accounts.length === 0 || accounts.some((a) => !a.label || !isAddress(a.value))) { console.error("Usage: node main.ts label=address [label=address ...]"); process.exit(1);}// A failed read prints its label and message, and the exit code 1 keeps the publish step from using this build.function fail(label: string, e: unknown) { console.error(`${label}: ${e instanceof Error ? e.message : String(e)}`); process.exitCode = 1;}// Every read names its commitment: the server defaults to finalized, @solana/kit fills in confirmed.async function slot(commitment: "processed" | "finalized") { try { return await rpc.getSlot({ commitment }).send(); } catch (e) { fail(`getSlot ${commitment}`, e); return undefined; }}const processed = await slot("processed");const finalized = await slot("finalized");const lines: string[] = [];for (const { label, value } of accounts) { try { const { value: info } = await rpc.getAccountInfo(address(value), { commitment: "confirmed", encoding: "base64" }).send(); lines.push( info ? `- ${label} ${value}: owner ${info.owner}, executable ${info.executable}, ${info.space} bytes of data, ${info.lamports} lamports` : `- ${label} ${value}: no account at this address`, ); } catch (e) { fail(label, e); lines.push(`- ${label} ${value}: read failed`); }}const slots = processed === undefined || finalized === undefined ? "Slots when built: read failed." : `Slots when built: processed ${processed}, finalized ${finalized}, a gap of ${processed - finalized}.`;const docs = "https://carbium.sh/docs";console.log( [ "# Solana agent context", "> Read-only facts about Solana mainnet, read through Carbium when this file was built. Check the chain before you answer from memory.", "", slots, "Reads here use confirmed. A call that leaves commitment out reads finalized on the JSON-RPC server and confirmed in @solana/kit 8.6.0.", "Never sign or send from this context. Some methods are not served: check the RPC page before you call one.", "", "Accounts, read at confirmed:", ...lines, "", "## Docs", `- [RPC methods and costs](${docs}#rpc): cells per call by method, req/s by plan, and the methods that are not served`, `- [Errors](${docs}#errors): what each error code means and which calls to retry`, `- [Limits](${docs}#limits): req/s and cells by plan, and what a 429 means`, ].join("\n"),);
run: node main.ts usdc-mint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
Name accounts as label=address arguments. The run reads the processed slot and the finalized slot, then each account at confirmed, and prints the file to stdout. The chain line reads like processed 123, finalized 123, a gap of 0, and on current mainnet the gap is 0 to 1. For the USDC mint, the account line shows the token program as owner, executable false and 82 bytes of data.
Each read sits in its own try. When one fails, the script prints the failed label and the error message to stderr, sets process.exitCode to 1 and carries on with the other reads. Each address goes through isAddress before any request, so a typo costs nothing. An address with no account prints no account at this address and the run goes on. To publish, redirect stdout to a temporary name and move it over llms.txt only when the run exits 0: node main.ts usdc-mint=<address> > llms.txt.tmp && mv llms.txt.tmp llms.txt.
What goes in each part
| Part of the file | What it holds | How often it changes |
|---|---|---|
| H1 and blockquote | The project name and one sentence on what the agent may do, read-only included | Rarely |
| Chain paragraph | Processed and finalized slot, the gap, the commitment rule | Every build |
| Account list | Owner, executable flag and data size of addresses the agent will meet | Every build; owners rarely move |
| Docs list | Links to the pages that define methods, costs and errors | When the docs change |
| Optional | Long notes an agent can skip; you add this by hand, the script does not print it | Rarely |
Put the rules an agent keeps breaking in the static part. Three Carbium rules fit well. getSignaturesForAddress pages come from Carbium's own address index, which keeps up to 30 days; an empty page past that is the index's age limit, and the address may have older transactions. Some methods, getTokenLargestAccounts among them, are not served and answer -32601, method not served, which an agent must not retry. And accountSubscribe stays silent for a plain SOL wallet, so the agent should use logsSubscribe with mentions plus getBalance.
Keep the account list short. It is a map of the addresses an agent will meet, such as a token mint and the program that owns it, and an agent reads every line of it each time.
Regenerate, publish, count the cost
A build makes two slot reads and one read per account. Slot reads are cached reads at 1 cell each. Account reads cost 10 cells each, and the per-second rates by plan differ a lot. Limits are per account and an account's keys share one budget, so a build draws on the same budget as your agent's own calls.
On Free, account reads run at 0.5 req/s, so a long account list built there can hit a 429. Keep the list short on that plan. getMultipleAccounts fits a long list into one call and still charges 10 cells per pubkey. A call takes up to 300 pubkeys on Pro; below Pro the 1024-cell burst caps a call at 100.
Run the build from a schedule, write to a temporary name, and move the file into place when the run exits 0, so nobody is served half a file. A build with a failed read exits 1 and leaves the previous file in place. The slot lines are a snapshot of the moment of the build. An agent that needs the current slot should call getSlot itself.
Where it ends
- llms.txt is a convention and no agent or crawler is bound to fetch it, so check the one you use.
- The slot lines go stale within seconds and an account line goes stale when the account changes. The file is a briefing, and the agent still has to read the chain for anything that matters.
- Owner, executable flag and size describe the outside of an account. What its bytes mean needs the program's layout.
- getSignaturesForAddress on Carbium reaches back 30 days at most, so the file cannot promise older history to an agent.
- The script only reads: no signing and no sending. To hold the agent to reads only, give it the tool allowlist from Read-only model tools.
- An RPC error fails only that read, and the exit code 1 makes the publish step skip that build. There is no retry loop here.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| The file says finalized is far behind processed. | Print the gap from a live read, as the generator does, and drop any fixed number of slots from the static text. Since the Alpenglow switch finalized sits 0 to 1 slots behind. |
| The agent reads the same account differently from your code. | A call that leaves commitment out reads finalized on the JSON-RPC server and confirmed in @solana/kit 8.6.0. Pass commitment on every call and state it in the file. |
| A build reports a 429 on Free and exits 1. | Account reads run at 0.5 req/s on Free. Name fewer accounts, build on a plan with a higher rate, or retry after the retry-after hint. The exit code 1 keeps the previous file in place. |
| The agent retries a method and gets -32601 every time. | Write in the static text that -32601 means method not served or not found and must not be retried, and list the methods your agent is meant to call. |
| An empty getSignaturesForAddress page is read as a wallet with no history. | Say in the file that the index keeps 30 days at most and that an empty page past it is the index's age limit. |
| The published file is cut off in the middle. | Write the build to a temporary name and rename it when the run exits 0. |
Questions
Why build my own llms.txt?
Its slot and account lines come from live reads made at build time, so they match the chain when you publish. The static rules come from Carbium's published limits and errors.
Which commitment does the generator read at?
It passes processed and finalized for the two slot reads and confirmed for the account reads, each explicitly. A call that leaves it out would read confirmed in kit and finalized on the JSON-RPC server.
How do I add an Optional section or more docs links?
Add strings to the array that console.log joins. The script prints only what the array holds, so hand-written parts go in as plain lines.
How many accounts can the file list?
Each account costs 10 cells, and getMultipleAccounts takes up to 300 pubkeys per call at 10 cells per pubkey, though below Pro the 1024-cell burst limits a call to 100 pubkeys. The practical cap is your plan's rate and how long a list an agent can use well.
Does the script need a signer?
No. It reads slots and accounts and nothing else. The only secret involved is your Carbium key, and it goes into no output.