Context Economics
Token counts tell you how big the prompt was. Context economics tells you what each part of it cost: the system prompt, replayed conversation history, retrieved documents, tool outputs, memory reads and the user’s current input. It also marks which parts are candidates to trim, so you can tell whether an agent is getting better or just getting more expensive.
It is on every agent’s Context & Memory tab, in the Where your input spend goes panel.
What you see
- The split. Input spend for the window, divided into buckets, with the change against the previous window of the same length.
- Top contributors. For the system prompt, which prompt version, named by kind with the hash after it, such as “System prompt (a9b84bbb)”. For tool outputs and retrieved documents, which tool or retriever produced them.
- Coverage by path. How much of the input spend has a breakdown, per ingestion path (SDK adapter, framework, plain OTLP). Calls with no segment data are shown as Not broken down, never spread over the other buckets.
- Candidates. When one bucket takes at least 30% of input spend and at least $5 in the window, the panel shows it as a candidate to test, with the dollar figure and how it was computed.
Method
For every priced model call:
- Sizes. Each context segment’s size is estimated with a tokenizer, then scaled so the segments add up to the input tokens the provider billed. When a segment was too long to store in full, the measured remainder goes to it, which is exact when one segment per call was cut.
- Cache tiers. Provider prompt caches match from the start of the prompt. Morse walks the prompt in that order (tool definitions, system prompt, then messages): the first tokens are priced as cache reads, the next as cache writes, the rest at the standard input rate.
- Price. Each piece is priced with the same catalog row (including your custom rates) that priced the call, so the buckets add up to the call’s input cost exactly. Output tokens are not included.
Calls whose estimated sizes are far from the billed count (more than 1.5x apart) are marked low confidence. Candidates are held back when less than 70% of input spend has a breakdown, or when 25% or more of it is low confidence. The panel says which condition held them back and what lifts it.
Only sizes, hashes, sources and span names are used. Segment text is never read for this.
Test it as a change
A candidate is not a recommendation that quality will hold. It is what that part of the context costs. To find out whether trimming it is safe, make the change in your agent (for example, send the last 10 turns instead of the full history), then press Test it as a change on the candidate. Morse records a change dated today, and change verdicts compare the runs before and after on cost and on confirmed outcomes. The candidate then shows that it is being tracked.
Does the extra context help?
When enough runs have confirmed outcomes, this section compares success rates inside one prompt version of the agent (the one with the most runs in the window):
- by the size of the largest model call (under 2k, 2k–8k, 8k–32k, 32k or more input tokens), and
- by whether a segment was present: conversation history, retrieved documents, tool outputs or memory reads.
Each row shows both success rates, how many labeled runs each side has, and the difference with a 95% interval. A success rate counts only confirmed outcomes: unlabeled runs are left out, never counted as failures. Each side needs at least 20 labeled runs; until then the section shows what is missing and when it is likely to fill in.
These are associations, not causes. Runs with long history may simply be harder conversations. When a row is clearly lower, it offers the same Test it as a change button, so the change is judged before and after rather than assumed.
Limits
- Few-shot examples inside the prompt are not detected separately. They count toward the bucket of the message that carries them.
- Memory reads and retrieved documents are detected from the LangGraph Python adapter and from retrieval-shaped messages. Other paths may show them under history or tool outputs.
- One-hour cache writes are priced at the five-minute write rate.