AI & Business

What Actually Reduces Costs in an Agent-Based Development Workflow

András Leskó
CTO
AI & Business · AI TOKENIZATION / Part 2

Everyone has experienced this: if you do a lot of coding with AI, it can get really expensive—you can end up spending an amount comparable to developer salaries on tokens. Of course, if you generate enough value by using AI, it’s worth it in the end—but if something costs a lot, it’s definitely worth optimizing after a while. At least that’s what CFOs are sure of, but even developers with a down-to-earth outlook occasionally find themselves thinking this way.

We’ve written before about why it’s better to measure first, and why a developer’s token consumption isn’t a good metric. Enough time has passed since then, and we’ve gathered enough day-to-day experience at Gloster—where we’re handling an increasing portion of development using agentic AI tools, under human supervision—that it’s time to take a look at the practical side as well.

The question isn't whether it's possible to save money. It is. The question is which practices yield meaningful savings without slowing down the developer. There's a sharp line between the two—and I think that's exactly what most teams don't see clearly.

Cost arises in context

Consumption is driven by the size of the context, not the length of the prompt. With every message, the entire conversation up to that point is re-run—so the fiftieth message also carries all the previous ones with it. This is mitigated by prompt caching: when an ongoing conversation continues, the earlier part is retrieved from the cache, which is much more efficient.

This gives rise to a common misconception. Many people think that a long session is expensive in and of itself, so they prefer to start a new one frequently. But that’s not what makes it expensive. Losing the cache is. If someone leaves the machine idle for a longer period and the cache expires, the next request will run at full cost again—discarding a warm cache can easily cost more than what a fresh session would save.

It’s therefore best to time the reset based on tasks, not hours. Four habits that work at this level:

  • A clean slate when switching. Use /clear when you’re actually switching to a different task; from that point on, the stuck context will cost you money in every message. If you need to return to it later, use /rename before deleting it and /resume afterward.
  • Compaction guidelines. Along with the /compact option, it’s a good idea to specify what to keep, such as code snippets and API calls. The default behavior can also be specified in the project’s CLAUDE.md file.
  • Keep CLAUDE.md short. It loads in every round regardless of the session’s length, so excessive project memory results in recurring costs. Community experience suggests setting the limit around 150–200 lines: include conventions and constraints that the agent cannot figure out on its own, but avoid general descriptions.
  • Pruning MCP servers and plugins. The tool definitions for a connected server are included in every single message, even if we don’t call them a single time that day. We disable anything we don’t use for a given task—this is the step on the entire list that pays off the fastest.

Model Selection and the Scope of the Prompt

The most expensive practice is to run everything on the most powerful model. The Sonnet is more than sufficient for the majority of daily coding tasks; it’s best to reserve the Opus for architectural decisions and tasks that require multi-step thinking. That’s what the /model opusplan is for: design with Opus, execution with Sonnet.

An imprecise prompt is an expensive prompt. A task like “review the codebase and find everything related to X” forces the agent to perform a broad, costly search. If we specify the file or directory, we get a more precise and less expensive result. This is especially true for subagents, because each one opens its own context window and carries with it whatever we wrote in the spawn prompt. The same applies to Jira tickets and Confluence pages: a precisely referenced ticket is cheaper than a search.

BUT.

There’s one step that isn’t about the budget, but about quality: “plan mode” before making major changes. The agent first describes what they’re planning, and any flawed assumptions are identified before any code is written. This saves us from back-and-forth fixes, multiple rounds of coding, and having to re-prompt.

Where is it worth doing this?

For most teams, this is enough. These few habits account for the bulk of the savings, and they cost nothing: they don't slow down the work, and they don't require any new tools. However, there are a few situations where this isn't enough:

  • Large monorepos. This is where the context pane runs out of space the fastest due to searches that read files one by one.
  • Fixed-price projects where the token cost comes directly from the margin, not from a separate budget.
  • Teams working in a customer-facing environment, where the customer's subscription serves as the budget. In this context, the limit isn't a financial issue but an operational one: if it runs out, work comes to a halt.
  • A large team. If everyone works on the most powerful model by default, multiplying that by fifty developers really adds up.

The Compromise

It has to be said: the token is inexpensive compared to developers’ hourly rates. Anyone who spends ten minutes fine-tuning the context typically ends up spending more than they save. Premature optimization is the death of a project here, too.

However, two factors complicate the picture.

First: good token management goes hand in hand with good work practices. A tightly defined prompt, plan mode, and clear context not only reduce costs but also yield more accurate results. It would be worth implementing these practices even if the tokens were free.

Another point: bad defaults can snowball. With a single developer, we might not even notice them—but across an entire delivery organization, the stakes are high. That’s why it’s worth standardizing defaults centrally: model selection, the CLAUDE.md template, and enabled MCP servers. As for day-to-day micro-optimization, let’s leave that to the developers.

Other measures we have implemented

The built-in tools provide the foundation. The next step involves structuring the workflow, and for us, this leads in three directions.

  • RAG on top of the codebase. Instead of having the agent read entire files in the hope that the answer is contained within them, we pre-index the codebase into a vector store, and the agent retrieves only the relevant details. Published measurements report a reduction of around 40% or more compared to searches based on reading through the entire files. For large repositories, the gap widens further: a few thousand tokens per search, compared to roughly 30,000 if the agent were to read through the files itself.
  • Plugins based on cost control. A robust set of community tools has been built around this topic—these are not Anthropic products, so it’s worth reviewing them thoroughly before installation. There are four recurring patterns. One filters out lengthy tool and MCP outputs from the context and provides only a brief summary. Another filters out noisy shell command output before it enters the context. The third provides a real-time usage dashboard and a budget guard. The fourth enforces the plan–execute–check cycle—it doesn’t condense anything, but it simply reduces misunderstandings and the need for re-prompts.
  • Skills instead of a project memory that’s always loaded. A skill is loaded only when it’s relevant—whereas CLAUDE.md is always loaded. A well-tailored skill therefore costs money only when we actually use it. You can also configure which model it runs on, even as a subagent.

The bottom line in one sentence

Token cost awareness shouldn’t be a separate task; it needs to be built into the workflow. When the context is right, the model selection is deliberate, and the prompt is tightly defined, the cost naturally goes down—and the output becomes more accurate. Anything beyond that is fine-tuning, and for most teams, it’s not worth the time. However, where it is worth it—large repositories, fixed-price projects, teams working within a client’s framework—RAG, a tightly tailored toolset, and skill-based work organization provide the next level of optimization.

AI & Business · AI TOKENISATION / Part 2

Everyone has run into it: if you code a lot with AI, it can get seriously expensive — you can burn as much on tokens as you would on a developer's salary. Of course, if you generate enough value from using AI, it pays off in the end — but if something costs a lot, it is certainly worth optimising after a while. At least according to the CFOs, and even level-headed developers start to wonder about it now and then.

We have written before about why it is worth measuring first, and why a developer's token consumption is not the right metric. Enough time has passed since then, and enough day-to-day experience has built up at Gloster — where we are handling an ever larger share of development with agentic AI tools, under human supervision — that it is time to look at the practical side too.

The question, after all, is not whether you can save money. You can. The question is which habit brings meaningful savings without slowing the developer down along the way. The line between the two is sharp — and I think this is exactly what most teams do not see clearly.

Cost is created in the context

Consumption is driven by the size of the context, not by the length of the prompt. With every message the whole conversation so far runs through again — so the fiftieth message carries all the previous ones with it. Prompt caching softens this: if a conversation that is already running continues, the earlier part comes from the cache, much more cheaply.

From this comes a widespread misconception. Many people think that a long session is expensive in itself, so they prefer to start a new one often. But that is not the expensive part. Losing the cache is. If someone leaves the machine for a longer stretch and the cache expires, the next message runs again at full price — dropping a warm cache can easily cost more than a fresh session would save.

So the reset is worth timing to the task, not to the clock. Four habits that work at this level:

  • A clean slate at the switch. /clear comes when we really do jump to a different task; a context that has got stuck costs money in every message from then on. If you need to come back to it later, /rename before clearing, /resume afterwards.
  • Compaction with guidance. Alongside /compact it is worth stating what it should keep, for example the code snippets and the API calls. The default behaviour can also be set in the project's CLAUDE.md.
  • Keep the CLAUDE.md short. Regardless of the session length it is loaded on every turn, so an over-large project memory is a recurring cost. Community experience draws the line at around 150–200 lines: conventions and constraints the agent would not work out on its own should go in, general description should not.
  • Pruning MCP servers and plugins. The tool definitions of a connected server go into every single message, even if we never call them once that day. Whatever we are not using for the job at hand, switch it off — this is the fastest-paying step on the whole list.

Model choice and the scope of the prompt

The most expensive habit is running everything on the strongest model. For most day-to-day coding tasks Sonnet is more than enough; Opus is worth keeping for architectural decisions and tasks that call for multi-step reasoning. That is what /model opusplan is for: planning with Opus, execution with Sonnet.

An imprecise prompt is an expensive prompt. A task of the "look through the codebase and find everything related to X" kind forces the agent into a broad, expensive exploration. If we name the file or the directory, we get a more precise and cheaper answer. With subagents this is true many times over, because each one opens its own context window and carries with it whatever we wrote into the spawn prompt. The same holds for Jira tickets and Confluence pages: the precisely referenced ticket is cheaper than the search.

BUT. There is one step that is not about the wallet but about quality: plan mode before a bigger change. The agent first describes what it plans to do, and a wrong assumption comes to light before any code is written. This saves us the back-and-forth fixing, the multiple rounds of coding, the re-prompting.

Where is it worth bothering with this?

For most teams that is enough. These few habits bring the bulk of the savings, and they cost nothing: they do not slow the work down, and they need no new tool.

There are, however, a few situations where this is no longer enough:

  • Large monorepos. This is where the context window runs out soonest, from a search that reads the files in one after another.
  • Fixed-price projects, where the token cost comes directly out of the margin, not out of a separate budget.
  • Teams working in a client environment, where the budget is the client's subscription. There the limit is not a financial question but an operational one: if it runs out, the work stops.
  • Large headcount. If everyone works on the strongest model by default, multiplied by fifty developers it already shows on the bill.

The trade-off

It has to be said: the token is cheap compared with developer hourly rates. Someone who spends ten minutes polishing their context typically spends more than they save. Premature optimisation is the death of the project here too.

Two things, though, add nuance to the picture.

The first: good token management coincides with good working method. The tightly scoped prompt, plan mode and a clean context are not only cheaper but also give a more precise result. These would be worth introducing even if the token were free.

The second: bad defaults scale. With one developer we do not even notice them — across a whole delivery organisation there is something at stake. That is why it is worth putting the defaults in order centrally: model choice, CLAUDE.md template, the MCP servers that are switched on. The daily micro-optimisation, leave to the developer.

What we have introduced beyond this

The built-in tools provide the foundation. The next step up is already about building the workflow, and for us it goes further in three directions.

  • RAG over the codebase. Instead of the agent reading in whole files in the hope that the answer will be in there, we index the codebase into a vector store in advance, and the agent only fetches the relevant snippets. The published measurements mention a reduction of around 40% or more compared with a search based on reading the files through. With large repos the gap widens further: a few thousand tokens per search, as against something on the order of thirty thousand if the agent reads through the files itself.
  • Plugins built on cost control. A substantial community toolkit has grown up around the topic — these are not Anthropic products, so before installing them it is worth reviewing them thoroughly. There are four recurring patterns. One offloads large tool and MCP outputs from the context and feeds in only a short summary. Another filters the output of noisy shell commands before it gets into the context. A third gives a real-time usage dashboard and a budget guard. The fourth enforces the plan–implement–verify arc — this compresses nothing; it simply means fewer misunderstandings and less re-prompting.
  • Skills instead of an always-loaded project memory. A skill is loaded when it is relevant — the CLAUDE.md, by contrast, always is. A well-scoped skill therefore only costs money when we actually use it. It can also be set which model it runs on, even as a subagent.

The point in one sentence

Token cost-awareness cannot be a separate task; it has to be built into the working method. Where the context is in order, the model choice is deliberate and the prompt is tightly scoped, the cost comes down on its own — and the output becomes more precise too. Whatever lies beyond that is fine-tuning, and for most teams the time spent on it does not pay off.

Where it does, though — large repos, fixed-price projects, teams working from a client's budget — RAG, a tightly scoped toolkit and skill-based work organisation provide the next step up.

KI & Wirtschaft · KI-TOKENISIERUNG / Teil 2

Wenn Sie viel mit KI programmieren, wissen Sie, wie teuer das werden kann: Für Token lässt sich durchaus so viel Geld verbrennen, wie ein Entwicklergehalt ausmacht. Schaffen Sie mit dem KI-Einsatz genug Wert, zahlt sich das am Ende natürlich aus – aber was viel kostet, ist nach einer Weile ganz sicher auch die Optimierung wert. Zumindest sind CFOs davon überzeugt, und auch nüchtern denkenden Entwicklern kommt dieser Gedanke gelegentlich in den Sinn.

Wir haben bereits darüber geschrieben, warum es sich lohnt, zuerst zu messen, und warum der Tokenverbrauch pro Entwickler nicht die richtige Kennzahl ist. Seither ist einige Zeit vergangen, und bei Gloster – wo wir einen immer größeren Teil der Entwicklung mit agentenbasierten KI-Tools unter menschlicher Aufsicht erledigen – ist so viel alltägliche Erfahrung zusammengekommen, dass es an der Zeit ist, sich auch die praktische Seite anzusehen.

Die Frage ist nämlich nicht, ob man sparen kann. Man kann. Die Frage ist, welche Gewohnheiten eine spürbare Einsparung bringen, ohne dass der Entwickler dabei langsamer wird. Zwischen wirksamen und bloß lästigen Maßnahmen verläuft eine scharfe Grenze – und genau diese Grenze ziehen die meisten Teams nicht klar.

Die Kosten entstehen im Kontext

Den Verbrauch treibt die Größe des Kontexts, nicht die Länge des Prompts. Bei jeder Nachricht wird das gesamte bisherige Gespräch erneut verarbeitet – die fünfzigste Nachricht trägt also auch alle vorangegangenen mit sich. Abgefedert wird das durch Prompt-Caching: Wenn ein bereits laufendes Gespräch fortgesetzt wird, kommt der frühere Teil aus dem Cache, und zwar deutlich günstiger.

Daraus ergibt sich ein verbreiteter Irrtum. Viele meinen, eine lange Session sei an sich teuer, und starten deshalb lieber häufig eine neue. Nur ist das nicht der teure Teil. Teuer ist der Verlust des Caches. Wenn die Arbeit längere Zeit liegen bleibt und der Cache abläuft, wird die nächste Nachricht wieder zum vollen Preis verarbeitet – das Verwerfen eines warmen Caches kann ohne Weiteres mehr kosten, als eine frische Session einspart.

Den Reset sollte man also an der Aufgabe ausrichten, nicht an der Uhr. Vier Gewohnheiten, die auf dieser Ebene funktionieren:

  • Beim Aufgabenwechsel ein sauberer Schnitt. Ein /clear ist dann angebracht, wenn wir wirklich zu einer anderen Aufgabe springen; ein veralteter Kontext kostet von da an bei jeder Nachricht Geld. Wer später darauf zurückkommen muss: vor dem Löschen /rename, danach /resume.
  • Compaction mit Vorgabe. Beim /compact sollte man mitgeben, was erhalten bleiben soll, etwa Codeausschnitte und API-Aufrufe. Das Standardverhalten lässt sich auch in der CLAUDE.md des Projekts festlegen.
  • Die CLAUDE.md sollte kurz bleiben. Sie wird unabhängig von der Länge der Session in jeder Runde geladen; ein zu großes Projektgedächtnis ist also ein wiederkehrender Kostenpunkt. Die Erfahrung der Community zieht die Grenze bei etwa 150 bis 200 Zeilen: Konventionen und Vorgaben, die der Agent nicht von selbst herausfindet, gehören hinein, allgemeine Beschreibungen nicht.
  • MCP-Server und Plugins ausdünnen. Die Tool-Definitionen eines angebundenen Servers landen in jeder einzelnen Nachricht, auch dann, wenn wir sie den ganzen Tag über kein einziges Mal aufrufen. Was wir für die jeweilige Arbeit nicht nutzen, schalten wir ab – das ist der Punkt auf dieser Liste, der sich am schnellsten amortisiert.

Modellwahl und der Zuschnitt des Prompts

Die teuerste Gewohnheit ist, alles auf dem stärksten Modell laufen zu lassen. Für die meisten alltäglichen Programmieraufgaben reicht Sonnet völlig aus; Opus sollte man sich für Architekturentscheidungen und Aufgaben aufheben, die mehrstufiges Denken erfordern. Genau dafür ist /model opusplan da: Planung mit Opus, Ausführung mit Sonnet.

Ein ungenauer Prompt ist ein teurer Prompt. Eine Aufgabe vom Typ „Sieh dir die Codebasis an und finde alles, was mit X zu tun hat" zwingt den Agenten zu einer breiten, teuren Erkundung. Wenn wir die Datei oder das Verzeichnis benennen, bekommen wir eine präzisere und günstigere Antwort. Bei Subagenten verstärkt sich der Effekt, denn jeder öffnet ein eigenes Kontextfenster und trägt alles mit sich, was wir in den Spawn-Prompt geschrieben haben. Dasselbe gilt für Jira-Tickets und Confluence-Seiten: Das genau referenzierte Ticket ist günstiger als die Suche.

Aber: Es gibt einen Schritt, bei dem es nicht ums Geld geht, sondern um die Qualität – den Plan Mode vor einer größeren Änderung. Der Agent beschreibt zuerst, was er vorhat, und falsche Annahmen kommen noch vor dem Schreiben des Codes ans Licht. Damit sparen wir uns Korrekturrunden, mehrfaches Implementieren und erneutes Prompten.

Wann lohnt sich der Aufwand?

Für die meisten Teams reicht das aus. Diese paar Gewohnheiten bringen den Großteil der Einsparung und kosten nichts: Sie bremsen die Arbeit nicht und erfordern keine neuen Werkzeuge.

Es gibt allerdings einige Situationen, in denen das nicht mehr genügt:

  • Große Monorepos. Hier füllt sich das Kontextfenster am schnellsten, weil die Suche die Dateien der Reihe nach einliest.
  • Festpreisprojekte, bei denen die Tokenkosten unmittelbar aus der Marge kommen, nicht aus einem separaten Budget.
  • Teams, die in einer Kundenumgebung arbeiten und deren Budget das Abonnement des Kunden ist. Dort ist das Limit keine finanzielle Frage, sondern eine betriebliche: Ist es aufgebraucht, steht die Arbeit still.
  • Große Teams. Wenn alle standardmäßig auf dem stärksten Modell arbeiten, macht sich das, mit fünfzig Entwicklern multipliziert, auf der Rechnung bemerkbar.

Die Abwägung

Man muss es klar sagen: Token sind im Vergleich zu den Entwickler-Stundensätzen billig. Wer zehn Minuten damit verbringt, an seinem Kontext zu feilen, gibt in der Regel mehr aus, als er einspart. Verfrühte Optimierung ist auch hier die Wurzel allen Übels.

Zwei Dinge relativieren das Bild allerdings.

Das eine: Ein guter Umgang mit Token fällt mit einer guten Arbeitsmethode zusammen. Der eng gefasste Prompt, der Plan Mode und der saubere Kontext sind nicht nur günstiger, sie liefern auch ein präziseres Ergebnis. Diese Praktiken würden sich auch dann lohnen, wenn Token gratis wären.

Das andere: Schlechte Standardeinstellungen skalieren. Bei einem Entwickler bemerken wir sie nicht einmal – bei einer ganzen Delivery-Organisation geht es um relevante Summen. Deshalb sollte man die Standardeinstellungen zentral vorgeben: Modellwahl, CLAUDE.md-Vorlage, eingeschaltete MCP-Server. Die tägliche Mikro-Optimierung überlassen wir dagegen dem Entwickler.

Was wir darüber hinaus eingeführt haben

Die eingebauten Werkzeuge bilden die Grundlage. Die nächste Stufe betrifft den Aufbau des Arbeitsablaufs; bei uns führt sie in drei Richtungen weiter.

  • RAG auf der Codebasis. Anstatt ganze Dateien in der Hoffnung einzulesen, dass die Antwort darin steht, indexieren wir die Codebasis vorab in einen Vektorspeicher, und der Agent ruft nur die relevanten Ausschnitte ab. Veröffentlichte Messungen nennen eine Reduktion von rund 40 % oder mehr gegenüber einer Suche, die auf dem vollständigen Durchlesen der Dateien beruht. Bei großen Repos öffnet sich die Schere weiter: einige tausend Token pro Suche gegenüber der Größenordnung von dreißigtausend, wenn der Agent die Dateien selbst durchliest.
  • Auf Kostenkontrolle ausgelegte Plugins. Rund um das Thema sind zahlreiche Community-Plugins entstanden – keine Produkte von Anthropic, die man deshalb vor der Installation gründlich prüfen sollte. Es gibt vier wiederkehrende Muster. Das erste lagert große Tool- und MCP-Ausgaben aus dem Kontext aus und gibt nur eine kurze Zusammenfassung hinein. Das zweite filtert die Ausgabe besonders gesprächiger Shell-Befehle, bevor sie in den Kontext gelangt. Das dritte liefert ein Echtzeit-Nutzungsdashboard und einen Budget Guard. Das vierte erzwingt den Ablauf aus Planung, Umsetzung und Prüfung – das komprimiert nichts, es führt einfach zu weniger Missverständnissen und weniger erneutem Prompten.
  • Skills statt des immer geladenen Projektgedächtnisses. Ein Skill wird geladen, wenn er relevant ist – die CLAUDE.md hingegen immer. Ein gut zugeschnittener Skill verursacht also nur dann Kosten, wenn wir ihn wirklich nutzen. Es lässt sich zudem einstellen, auf welchem Modell er laufen soll und ob er als Subagent ausgeführt wird.

Kurz gefasst

Kostenbewusstsein bei Token darf keine separate Aufgabe sein, es muss in die Arbeitsmethode eingebaut werden. Wo der Kontext in Ordnung ist, die Modellwahl bewusst und der Prompt eng gefasst, dort sinken die Kosten von selbst – und das Ergebnis wird ebenfalls präziser. Was darüber hinausgeht, ist bereits Feinabstimmung, und bei den meisten Teams lohnt sich die dafür aufgewendete Zeit nicht.

Wo sie sich hingegen lohnt – große Repos, Festpreisprojekte, Teams, die aus dem Budget des Kunden arbeiten –, dort bilden RAG, ein eng gefasstes Toolset und die skillbasierte Arbeitsorganisation die nächste Stufe.

Newsletter

Get new articles delivered to your inbox.

A concise monthly brief: the latest articles, audit insights, and event invitations. Unsubscribe with one click—no spam.
Thank you! Your submission has been successfully recorded!
Oops! Something went wrong while submitting the form.