Skip to content
Redgold.AI Blog

· 8 min read · LLM gateway, storage, Postgres, deduplication

Storing Every LLM Request From a Coding-Agent Fleet: 28 GB of Raw Payloads, 0.37 GB of New Messages a Day

In one day our model gateway recorded 44,983 calls whose request and response records took 28.23 GB to store. Deduplicated by conversation position, the same calls added 0.37 GB of messages. Here is why the gap is so large, how the dedup key works and what the raw records cost the exporter.

Every model call our coding agents make passes through one gateway, and the gateway stores each call as a record holding the full request body and the response. A downstream extract stage parses those records into two smaller datasets: one row of call metadata per call (model, latency, token counts, message count) and one row per conversation message, deduplicated by a primary key.

We measured one day of it, the 24 hours from 28 October, 16:00 UTC. The gateway wrote 44,983 call records, which Postgres stored in 28.23 GB after its own compression. Those requests carried 7,645,525 messages between them. The extract stage stored 129,889 message rows, about one for every 59 messages sent, in 0.37 GB, plus 0.056 GB of call metadata. Per call, that is 628 KB of raw record, 8.2 KB of new messages and 1.2 KB of metadata.

Gateway calls by number of messages in the request010k20k0: 8 calls1: 6.1k calls2–4: 108 calls5–9: 830 calls10–19: 1.8k calls20–49: 5.2k calls50–99: 7.4k calls100–199: 8.7k calls200–499: 12k calls500–999: 2.7k calls1,000+: 79 calls02–410–1950–99200–4991,000+
Gateway calls by number of messages in the request. Source: the per-call metadata rows the extract stage wrote for 44,983 model-gateway calls in the 24 hours from 28 October 2026, 16:00 UTC to 29 October 2026, 16:00 UTC (written time), decoded from the hot Postgres store on 29 October 2026, 16:12–16:20 UTC. “Messages in request” is the parsed message count of each request body, including the system prompt and tool results. 83 calls reported no token counts and are kept in this chart.
Show the data
calls
08
16.1k
2–4108
5–9830
10–191.8k
20–495.2k
50–997.4k
100–1998.7k
200–49912k
500–9992.7k
1,000+79

Each request resends the conversation

Chat-style model APIs are stateless: every request carries the whole conversation so far, including the system prompt, earlier tool calls and their outputs. A coding agent working through a task makes one call per step, so the same history goes out again on each step with one or two new messages at the end. The median request in this window carried 107 messages, the 90th percentile 425, and the longest 1,217.

Token counts show the same shape. The calls reported 4.09 billion prompt tokens against 16.6 million completion tokens, 246 input tokens for every token generated. Median prompt size by message count, over calls that reported token counts:

  • Requests with 1 message: 1,069 tokens (6,021 calls).
  • Requests with 20–49 messages: 43,956 tokens (5,237 calls).
  • Requests with 100–199 messages: 111,253 tokens (8,685 calls).
  • Requests with 200–499 messages: 162,123 tokens (12,003 calls).
  • Requests with 500–999 messages: 195,109 tokens (2,747 calls).

Our inference, from the request shape rather than a per-conversation measurement: if a conversation grows by a roughly fixed number of messages per step, the bytes stored for it grow with the square of its length, while the new content grows linearly. Long agent sessions account for most of the raw volume for that reason. Prompt growth flattens above a few hundred messages in the list above, which is consistent with agent harnesses compacting or truncating long histories.

Where the raw bytes are

Stored size of gateway records, by record size010201–3 KB: 0 GB3–10 KB: 0 GB10–32 KB: 0 GB32–100 KB: 0.1 GB100–316 KB: 2.2 GB316 KB–1 MB: 10.4 GB1–3.2 MB: 14.3 GB3.2–10 MB: 0.6 GB10–32 MB: 0.6 GB1–3 KB10–32 KB100–316 KB1–3.2 MB10–32 MB
Stored size of gateway records, by record size. Source: the raw request/response records for the same 44,983 calls and the same 24-hour window, grouped by stored size in half-decade buckets (each bucket spans a factor of about 3.16). Sizes are as stored by Postgres, which compresses large values with pglz; a 200-record sample from the preceding hour averaged 3.24 MB of encoded record against 0.81 MB stored. Queried 29 October 2026, 16:12–16:20 UTC.
Show the data
GB
1–3 KB0
3–10 KB0
10–32 KB0
32–100 KB0.1
100–316 KB2.2
316 KB–1 MB10.4
1–3.2 MB14.3
3.2–10 MB0.6
10–32 MB0.6

The median record was 421 KB stored and the largest 17.3 MB. Records of 1 MB or more were 9,835 of the calls, 22%, and held 15.5 GB, 55% of the day’s bytes. At the other end, 5,053 records fell between 3 and 10 KB. The window also had 4,661 calls, 10%, that carried no conversation id and almost always a single message; we take those to be the single-prompt completion calls that show up as the 1-message column above, without having matched them record by record.

These sizes are after Postgres compresses large values with pglz. A 200-record sample from the hour before the window averaged 3.24 MB of encoded record and 0.81 MB stored, roughly 4 to 1. Repeated history compresses within a record; pglz cannot share bytes between two records.

Deduplicating by conversation position

The extract stage gives each message a primary key built from four values: a scope, the message role, its turn index in the request and a hash of its content. The key is encoded as canonical CBOR, and its BLAKE3 hash is the row identity, so when the next request in a conversation resends turn 12 unchanged, the extract produces the same key and the engine keeps one row.

let scope = if conversation_id.is_empty() {
    format!("call:{source_call_id}")
} else {
    conversation_id.to_string()
};
encode_identity(&MessageIdentityV2 {
    version: 2,
    scope: &scope,
    role,
    turn_index,
    content_hash,
})
The message identity used by the live extract stage, from the conversation extract crate at revision fba2ddc926 (function signature and struct definition omitted).
  • Role and turn index stay in the key. Agents often send identical short messages at different points, such as the same tool result or a one-word user reply. Keeping the position in the key preserves each occurrence, while a resent history still lands on the same keys.
  • A request with no conversation id cannot dedup. The scope falls back to the call id, which is unique per call, so every copy gets a fresh key. A measurement recorded in the extract code, over 12 sampled hours of the archive, found that subset deduplicating at exactly 1.0x.
  • Dropping the scope would dedup much further, at a cost. In the same sample, the current key reduced rows 4.44 times. A key without the scope reduced them 20.21 times by rows and 5.94 times by content bytes, and 99.94% of the extra saving came from messages that lacked a conversation id. It also merges identical content at the same position across different conversations, so a row no longer names the conversation it came from. That key is used only to rebuild a search corpus from the archive; the live datasets keep the scoped key, and the metadata dataset keeps one uncollapsed row per call.

The 4.44 figure comes from older archive hours, when more traffic lacked conversation ids. In this window, only 10% of calls lacked one, and the extract stage stored one message row per 59 messages carried. We have not re-run the archive measurement to separate those two effects.

What the raw records cost the exporter

Raw records stay in the hot Postgres store for a day or two before an exporter moves them to columnar files in object storage. The hot record table, which holds every dataset, measured 439 GB at query time, 219 GB of it in Postgres’s out-of-line storage for large values and 142 GB in indexes. Most of the gateway rows in it were written in the last two days.

Record sizes this uneven broke the exporter twice on 3 October:

  • Indexes built per byte. The exporter builds membership indexes on nested columns so that queries can filter on list elements. The request and response bytes decode as lists of 8-bit integers, so the indexer created a posting for every byte, and the job ran out of its 2 GiB memory limit. The fix skips nested indexing for those two columns of the gateway dataset only.
  • Pages counted in rows. After that fix the job was still killed for memory. It fetched source rows in pages of 250, and the next 250 gateway records came to 2.7 GB, the largest 45 MB, all loaded before the stage that splits output into 64 MiB parts could run. The fix selects the next run of rows by cumulative stored size in a single SQL statement, and a row larger than the budget is exported alone.

A row-count page works for small, uniform rows. In the window measured here, gateway records ranged from a few kilobytes to 17.3 MB stored, so the memory a fixed page of them needs depends on which conversations it happens to reach.

What we would do again

Our inference from this data and the code, rather than measured results:

  • Keep the raw request and response. The extract stage has changed its message identity more than once, and the archive rebuild with a new key works only because the raw records exist. Store the small derived datasets for queries and treat the raw records as a replayable log.
  • Put a conversation id on every call at the gateway. Calls without one cannot be deduplicated by position, and they are also the ones that cannot be grouped back into a session later.
  • Size pages, batches and memory limits in bytes for any dataset that holds LLM payloads. One long agent session can make a single record thousands of times larger than a short completion.
  • Track prompt tokens against completion tokens per call. At 246 to 1, request size dominates storage and, without a prompt cache, cost.

Limits of this account: one 24-hour window from one development fleet, measured from Postgres stored sizes, which include record envelopes and depend on pglz. Message counts are parsed from request bodies, and the stored-row count may undercount new messages near the window’s start whose first copy arrived earlier. The compression ratio comes from a 200-record sample. The archive dedup ratios are quoted from the code, not reproduced. The exporter failures are taken from that day’s plans; we did not re-run them.