Skip to content

A Combined LLM Workflow: Primer 1

Programmers setting function table switches on the ENIAC.
Table of contents

The Voodoo that you do

I'm always interested in the different ways people fold technology into their work, and I get to hear about it from every category of knowledge worker. Unsurprising, it seems like everyone has a different approach when it comes to LLMs. Some of that is preference. Most of it comes down to which layer of the stack you happen to be standing on.

This is primer one in a series on building a combined LLM workflow. I'll pull from recent research, best practices, and the tools I actually run, Zoo Code among them. The target is a workflow that holds up no matter how advanced the tooling gets, because the workflow considerations barely change: context, cache, messages, and the discipline of writing down what you actually want. Get those right and the model of the month matters less.

A Short History Lesson

When the U.S. Army funded ENIAC in the 1940s[1], the hardware engineers assumed programming was a clerical step: hand a math formula to an operator, flip some switches, and read the ballistic table off the output. They treated software as an afterthought to the hardware.

Instead, the six women recruited to run the machine found no operating instructions at all[2]. Security rules kept them out of the machine room, so they worked the programs out from blueprints and wiring diagrams alone.

  • No manuals, no teaching path. Nobody had written instructions for how to actually run complex workflows on the machine. The programmers had to reverse-engineer the wiring diagrams themselves, invent debugging methods from scratch, and build reusable subroutines.
  • Rewiring was expensive state-resetting. Changing a task on ENIAC meant physically unplugging cables and resetting dials across entire panels, often taking days before a single calculation could run. That maps directly to prefix caching: once you wire up a clean context prefix and keep it intact, you reuse the expensive setup. Rip out one cable in the middle and you are back to rewiring the board by hand.
  • To the engineers, ENIAC was vacuum tubes and accumulators. To the programmers holding bundles of patch cables, it was state management, sequencing, and knowing when a run was actually done. How people approach LLMs today depends entirely on which layer of the stack they inhabit. Also, people aren't walking spec writing machines by default.

ENIAC's designers assumed the hardware was the hard part and running jobs on it would be trivial. The programmers holding the patch cables quickly learned without clear specs, reusable state, and strict discipline around resets. The fastest machine in the world lost days between jobs to rewiring[3]. That is the thesis of this whole series.

The Vocabulary

Every tool names these things differently, and the marketing words drift. So here is the language this series uses. If a term shows up later, this table is what it means.

Term What it means here What you might call it
Request One round trip to the model API. The unit that gets billed. Call, turn, completion
Message One item in the conversation: your prompt, a tool result, or the model's reply. Turn, exchange
Session One continuous conversation and its message history. Everything in it re-sends on each request. Chat, thread, conversation
Task One unit of work with a finish line. A task may take many requests inside a session. Job, run
Agent Software that loops: it sends a request, runs tools on the reply, sends again, until the task is done. Assistant, copilot
Mode A named preset for one agent: its rules, tools, and reasoning effort. Code, Ask, Debug, Architect, Orchestrator. Profile, persona, configuration
Orchestrator An agent whose only job is breaking work up and handing tasks to other agents. Coordinator, supervisor, subagent runner
Spec The written statement of a task: context, inputs, outputs, constraints, and done conditions. Prompt brief, plan, requirements
Context Everything in the request window: system prompt, tool definitions, message history, your input. Prompt, window
Cache The provider's saved prefix state. Requests starting with the same bytes reuse it at a discount. Prompt caching, prefix cache

Two habits worth noting now. First, "mode" is the word I lean on most. A mode is not a different model. It is the same model with different instructions, tool access, and reasoning budget. That distinction is where most of the token savings in this series come from, because a cheap model in the right mode beats an expensive model in the wrong one. Second, keep session and task separate in your head. Sessions are where tokens pile up. Tasks are where work gets finished. The whole discipline in later primers is ending sessions when tasks end.

The Map: How People Actually Run LLMs

From a bird's eye view, an observant IT person can sort the usage patterns into buckets. Each bucket has its own pros and cons. Fair warning, a lot of these bleed into each other at the edges, so treat this as a working map and not gospel.

Bucket What it is The catch
Free web chat The chat box on a provider's site. Gemini, ChatGPT, Copilot, and friends. Rate limits, no automation. Copy and paste out of the web interface by hand.
Paid personal plan The same bots with more room. Personalization, integrations, sometimes API credits. The messiest tier. A Cursor subscription and a ChatGPT Plus plan are the same idea done differently, and what you get may change month to month.
Direct API A key or plan you wire up yourself. IDE extensions, CLI agents, scripts, MCP servers. You are the integration now. Costs need watching but you are in control of the API.
Team and org licensing Seats with pooled tokens, admin controls, SSO. Somebody else watches the spend and receives the notifications. You get whatever the vendor bundled.
Routers and hybrid gateways Cloud services fronting open weight models, escalating up to the big names when the job needs it. Optimization someone else owns. Great when it works, frustrating with frequent change.
Self hosted Open weight models on your own hardware, with your own routers and distribution. Maximum control and privacy. You are now the datacenter.

The buckets bleed, and that's fine. MCP servers and cross API shims sit across several levels at once. The polished consumer versions of the same machinery usually show up one tier above whatever the hobbyists built, offered exactly the way the company wants. Low code platforms like n8n, and the Microsoft Power Automate or Azure Logic apps, let you plug a provider in and wire flows without writing code. I keep the map anyway. Whenever I read about a workflow or a study, I ask which bucket it ran in. The answer changes how much of it applies to me.

Why Token Efficiency Comes First

We are quickly moving into a period where token costs are no longer subsidized like they once were, and that is expected to continue for the foreseeable future. Regardless, efficient use of compute resources is always welcome. So before the flashy parts of any workflow, I start with the meter: what gets sent, what gets billed, and what gets reused.

The Basics: What Gets Sent on Every Request

You may have heard that all context is sent on every request inside a session or task window. That's not entirely accurate, as we'll get into below, but it's a good baseline to think with when you start considering anything token related.

Here's what stacks up on a typical agent request:

  • Your message. The actual thing you asked for.
  • What the application sends for itself: system prompts, personas, output rules.
  • Rules and settings from your client, often shipped on every request, while skills load as needed.
  • Tool definitions. Every MCP server or plugin you have connected rides its schemas along.
  • The whole conversation so far: tool results, agent notes, every turn you have had.
  • Probably more. Every checkbox and slider in your client maps to tokens somewhere in here.

The stack grows every turn:

flowchart LR
    R1[Request 1: rules, tools, your message] --> R2[Request 2: all of request 1, plus turn 1 results] --> R3[Request 3: all of request 2, plus turn 2 results]

Much of this sits behind checkboxes and sliders, and it can feel like providers are sometimes purposefully obtuse. After all, the more tokens you use, the better for their service, and generally speaking the better your experience. Nobody is being sneaky exactly. It just pays to know the meter is running before you type the first word.

Model Caching

Model caching depends on whether your particular model supports it, and different rates apply to cached data. It usually shows up as a discounted usage rate on cache hits. The idea: the very big initial task context you send gets reused without being processed as if it were a brand new request. The spec for a task doesn't change much until the task is done, so we can leverage that.

The catch is how the match works. The cache is a prefix instrument. The provider holds the computed state of your request and reuses it as long as the next request starts with the exact same bytes. Change one character anywhere in that block and the match dies at that point. Everything after it processes at full price again.

Say you task an agent with changing one line in a specific file. Left alone, the agent may loop a few times like so, and the cache never breaks:

sequenceDiagram
    actor U as You
    participant A as Agent
    participant M as Model API
    U->>A: change line 42 in settings.php
    A->>M: request 1
    Note over M: cold write, cache saved
    M-->>A: tool call, list the files
    A->>M: request 2
    Note over M: cache hit, only the new tail billed
    M-->>A: file located, reading it
    A->>M: request 3
    Note over M: cache hit
    M-->>A: file is large, reading in sections
    A->>M: request 4
    Note over M: cache hit
    M-->>A: line 42 targeted and noted
    A->>M: request 5
    Note over M: cache hit
    M-->>A: edit applied
    A->>M: request 6
    Note over M: cache hit
    M-->>A: history reviewed, task confirmed
    A-->>U: done

Here's the token burn. The numbers are made up, not pulled from a study. Say the first request is 11k tokens, and each step adds a few thousand more of new work:

Request Sent Billed full price Served from cache
1 11k 11k 0
2 14k 3k 11k
3 19k 5k 14k
4 22k 3k 19k
5 24k 2k 22k
6 25k 1k 24k

Six requests, 115k tokens over the wire, and only 25k of them billed at the full input rate. The rest were cache hits. On providers where a cache read costs a fraction of a fresh token, the discount compounds fast. The research numbers below are the measured version of this same shape.

The Interrupt Problem

Interrupt that process before it completes and the picture changes. The agent is three steps in, reading the file, and you jump in: skip the search, the file you want is src/settings.php. Your note has to land somewhere. If the client wedges it into the working history, or compacts the context to make room, the cache match dies at the first changed byte, and everything after that point processes at full price again:

sequenceDiagram
    actor U as You
    participant A as Agent
    participant M as Model API
    U->>A: change line 42 in settings.php
    A->>M: request 1
    Note over M: cold write, cache saved
    M-->>A: tool call, list the files
    A->>M: request 2
    Note over M: cache hit
    M-->>A: file located, reading it
    U->>A: skip the search, use src/settings.php
    Note over A,M: the note lands in the history
    A->>M: request 3, note wedged in
    Note over M: cache miss, rebuilt from here
    M-->>A: re-reading, line 42 targeted
    A->>M: request 4
    Note over M: new cache, hits from here
    M-->>A: edit applied
    A->>M: request 5
    Note over M: cache hit
    M-->>A: history reviewed, task confirmed
    A-->>U: done

The front of the conversation still matches, so it isn't a total loss. But it did the same work twice. Now there's a new variable to weigh: is it worth interrupting this task right now? Sometimes yes. A wrong direction caught early is cheaper than letting it run to the end. Sometimes you're throwing away a warm cache to save one search step.

There's a time limit too. Cache entries expire, and TTLs run anywhere from five minutes to a day depending on the provider and the plan. Step away for coffee mid-task and you might come back to a cold cache no matter how careful you were. ProjectDiscovery, who I come back to below, leaned on a one hour TTL to keep their system prompt warm across users all day[4].

This significantly changes how I think about workflow, because caching generally can't be turned off. It's built into the model service and it is ever present. So we want to take advantage of it as much as possible.

What the Research Says

If you have the time, the referenced paper Don't Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks is a fantastic read on where we currently are with cache[5]. The team ran over 500 agent sessions on a multi-turn research benchmark, across GPT-5.2, Claude Sonnet 4.5, GPT-4o, and Gemini 2.5 Pro, with 10,000 token system prompts, and compared a no-cache baseline against three caching strategies. On the cost side:

All cache modes achieve cost savings compared to the no-cache baseline for all four models. Cost reductions range from 79-81% for GPT-5.2, 78-79% for Claude Sonnet 4.5, 46-48% for GPT-4o, and 28-41% for Gemini 2.5 Pro depending on the cache mode selected.

Model Cost cut First token speedup
GPT-5.2 79 to 81% 13%
Claude Sonnet 4.5 78 to 79% 21 to 23%
GPT-4o 46 to 48% 28 to 31%
Gemini 2.5 Pro 28 to 41% 6%

First token speedup is time to first token, how fast the answer starts streaming. The strategy that maximizes cost savings does not always maximize speed. Naive full context caching, just letting the provider cache everything, actually made GPT-4o's first token 8.8% slower. Caching dynamic junk can cost more than it saves.

Two of their practical findings matter most for the workflow. The system prompt drives the majority of the savings, so keep it stable. And dynamic values belong at the end, never the front:

Common patterns that inadvertently break the cache include timestamps, datetime strings, session identifiers, or user-specific information embedded in the system prompt. If such dynamic information is necessary, it should be placed at the end of the system prompt to maximize the cacheable prefix.

They also flag dynamic tool definitions. When your MCP servers connect and disconnect mid-session, the tool list near the front of the request changes, and the cache dies at that change. A fixed tool set beats a shifting one for cache health. MCP is exactly how a lot of us wire tools up. More on that in a later primer.

The tables you'll find in that research can also be improved on with a tightened workflow, while being aware of how your tools are interacting with the model. I have seen cache rates for heavy work land in the high 90th percentile averaged over weeks on my own accounts. In the last 7 days as of this writing, my own usage has run a 95.6% cache rate, only introducing new tokens in tasks when necessary. Even if cache changes in subtle ways in the future, the workflow habits that get you there should stay relevant for a long time.

Where the Cache Stops Helping: The Middle and the End

So the cache is a prefix instrument, and the stable front gets the discount. The middle and the end see diminishing returns, and ProjectDiscovery's writeup on their Neo platform shows the pattern in production[4]. Neo is an autonomous security testing agent. Their average task runs 26 steps with 40 tool calls, and a single complex task with Opus 4.5 could consume 60 million tokens.

The middle is where it begins to taper off. Their cache is strictly prefix based, so anything that changes in the middle of the prefix invalidates everything after it. Neo's agents carried working memory, skills context, and runtime state between the system prompt and the tool definitions. The working memory changed on nearly every step, and it was silently removing their cache hits. Their fix was to move all of that dynamic content out of the prefix and append it at the tail, as a final message. That change took their hit rate from under 8% to 74%.

The agentic tax: the cost of intelligence compounds quadratically with task complexity. Caching is the only structural fix.

The end is where the new tokens live. Each step only pays full price for what was added since the last cache breakpoint, but everything before it rides along again on every request. Step 40 of a task re-sends the entire conversation. The saving grace, and it's a real one, is that the hit rate climbs as tasks get longer, because more and more of the pile is stable history that matches:

Task length Average cache rate
1 step 35.5%
2 to 3 steps 30.0%
4 to 5 steps 42.8%
6 to 10 steps 53.6%
11 to 20 steps 63.9%
20+ steps 74.0%

Overall they landed at an 84% hit rate and 59% off their LLM bill, with 9.8 billion tokens served from cache. Same volume of work with less cost. The lesson for the workflow layer: freeze the front, keep the middle boring, and expect to pay full price for the tail.

Prompting: What Belongs in the Task

Context and cache are the supply side. Prompting is the demand side, the part where you decide what work actually happens. A different team of researchers took a run at what makes a code generation prompt work[6]. They pulled tasks from three Python benchmarks, kept the ones where four different models failed ten runs in a row, iterated until the code passed the tests, then asked what the winning prompts had added. Ten patterns fell out. The middle column is the share of optimized prompts that used each one:

Guideline Applied What it means
Algorithmic details 57% The actual method: formulas, definitions, supporting math.
Input and output format 44% Types, shapes, and structure of what goes in and comes out.
More examples 24% Concrete examples or doctests of expected behavior.
Post-conditions 23% What must be true after the code runs.
Requirements 19% Every dependency, with the role each one plays.
Exceptions and errors 12% Which exceptions, under which conditions, with which messages.
Assertive language 9% Must and is required to, instead of should and may.
Pre-conditions 7% What must hold before execution.
Variable mentioning 3% One consistent name per variable through the whole prompt.
Clarity in conditions 1% Both branches spelled out, no vague otherwise.

Then they asked 50 practitioners how often they use each pattern, and how useful they think it is. Input and output format won on both sides, with 88% finding it useful. Examples sat near the bottom of actual usage while ranking high in perceived usefulness. People know examples would help, and don't write them anyway. I'm including myself in that.

Writing a Basic Prompt Task

Before any of the fancy workflow stuff, you need to be able to hand over one well formed task. Here's the skeleton I'll build on for the rest of the series. Fill in every line, in this order:

Task: change one thing, stated in a single sentence
Context: the files, systems, and data involved, and where they live
Inputs: what goes in with assistive detail of what things should look like.
Outputs: what comes out, the format, and one example
Constraints: musts, must-nots, and the error cases to handle
Done when: the conditions that mean the task is finished

The order isn't decoration. Task first, so the model knows what it is reading for. Context second, so nothing gets guessed. Inputs and outputs before constraints, because the shape of the data decides which constraints even make sense. Done when is the line people skip and the one that saves the most tokens: a task without a finish line gets you an agent that keeps polishing. A finish line is cache friendly too. A task that ends lets you start the next one clean instead of dragging history forward.

I'll walk a real example through this skeleton in the next primer, including what tends to happen when you leave lines out.

Spec Writing

Spec writing can be difficult if you don't know exactly where you are already headed. The change to your workflow I would want anyone to make is that if they are struggling to write a portion of spec is to stop what they are doing. Begin researching, looking up source of truth documentation, read, and slow down a bit in considerations. Spend some time in a plain chat session on a cheap mode with another low cost LLM. Since the criteria combined with cache is where we can have some of the largest impact in saving tokens. There are many ways to improve your spec writing, acceptance criteria, scope boundaries, what not to touch, and how to verify with linters and such.

Messages and Session Hygiene

I'll say it again, between the prompt and the cache sits the message stream. What you keep, what you summarize, and when you cut it loose. Workflow discipline here is the fuzziest to figure out. Maybe you spent a lot of time already in a session exploring how to come to a solution and now you have that solution. The kneejerk reaction in that situation is often to stay with it. After all, the existing dialogue has every worry, solution, consideration, and you just spent a few hours working all of that out. We are all bad at predicting what those outcomes will be though. The right move that will pay over a longer period of time would be to switch to architect mode, high reasoning, take what you have and encode that to a new spec plan markdown file. Then fire up a new session and start again from that architected spec plan. Will you still have misses at the end? Yes, probably but they will be minor and usually easier to separate into yet another new session. I also find using orchestrators to build plans, spin up tiny sessions even with specs but they lose nuance between agents and broken up tasks quite often causing repeated tasking that happened in another agent. Predicting when to use orchestration or hand hold sessions manually is why I want you to think about your workflow actively while it's happening and it doesn't have to be complicated.

Do you have a great spec worked out with all of the criteria matching above? Orchestrator is going to eat that for breakfast efficiently.

Do you have a vague idea, and will likely need to stop along the way to do more research. Head into a single session and start exploring with an Ask mode.

Applying This: My Zoo Code Setup

This is the setup I run day to day with Zoo Code on Z.AI models. It's the workflow above translated into one tool. Take it as an example of the pattern rather than a recommendation of any particular provider. The full settings breakdown gets its own writeup later in the series, once the groundwork is in place.

One agent per job. I run five modes: Code, Ask, Debug, Architect, and Orchestrator. Each is differing models with different instructions, tool access, and reasoning budget, and each is bound to its own provider profile so the reasoning effort travels with the mode. Code, Ask, and Orchestrator run on a small cheap model with low reasoning: fast edits, lookups, and subtask routing don't need a big model's tokens. Debug gets high reasoning for the extra thinking room a root cause hunt needs. Architect alone gets the big expensive model, because deep planning up front is what keeps the execution modes from thrashing later.

That split is the framing for every token decision. Ask which agent the work belongs to before you start it, and the cheap path is usually obvious. Planning once on an expensive mode is cheaper than planning repeatedly on cheap ones, and routing subtasks through a small orchestrator keeps the big model out of work it doesn't need to see.

Prefix cache habits. The two that matter most: keep the prompt prefix stable, and scope tasks tightly. Same rules text on every request, so the byte for byte prefix match holds. Target specific files, functions, or schemas instead of broad repo sweeps. Start a fresh task once a subtask finishes instead of dragging stale tool outputs forward.

Where This Series Goes Next

Primer two picks up the demand side: prompting and spec writing in practice, with worked examples. After that, messages and session hygiene, then tool selection and MCP. The tools will keep changing. The layers in this primer won't. Figure out the context you send, keep the cache warm, and write tasks that know when they are done.

References

  1. [1] T. Haigh, M. Priestley, and C. Rope, ENIAC in Action: Making and Remaking the Modern Computer, MIT Press, 2016. [Online]. Available: https://archive.org/details/eniacinactionmak0000thom
  2. [2] K. Kleiman, Proving Ground: The Untold Story of the Six Women Who Programmed the World's First Modern Computer, Grand Central Publishing, 2022. [Online]. Available: https://www.goodreads.com/book/show/58340941
  3. [3] F. da Cruz, "Programming the ENIAC," Columbia University Computing History, 2011. [Online]. Available: https://www.columbia.edu/cu/computinghistory/eniac.html
  4. [4] "How We Cut LLM Costs by 59% With Prompt Caching," ProjectDiscovery Blog, 2026. [Online]. Available: https://projectdiscovery.io/blog/how-we-cut-llm-cost-with-prompt-caching
  5. [5] E. Lumer et al., "Don't Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks," arXiv, 2026. [Online]. Available: https://arxiv.org/html/2601.06007v2
  6. [6] A. Midolo, A. Giagnorio, F. Zampetti, R. Tufano, G. Bavota, and M. D. Penta, "Guidelines to Prompt Large Language Models for Code Generation: An Empirical Characterization," arXiv, 2026. [Online]. Available: https://arxiv.org/html/2601.13118v1
  7. [7] Anonymous, "Reprogramming ENIAC," Wikimedia Commons, 1946. [Online]. Available: https://commons.wikimedia.org/wiki/File:Reprogramming_ENIAC.png Accessed: Dec. 4, 2026.

Related posts

← Journal