← All case studies

Inspiration

Limit your token usage — or go bankrupt

Niklas Andervang · AI · 6 min read · 10 May 2026

Agentic workflows are rapidly becoming the backbone of modern development – planning agents, review agents, refactoring agents, release agents. But there is a growing problem that many teams underestimate: you are not scaling your AI usage, you are scaling your cost exposure. If you do not control token usage, you will hit a cost wall.

Utvärdering av verktyget Graphify, en kunskapsgraf över kodbasen
Agentic workflows scale costs faster than value. A codebase knowledge graph (e.g. Graphify) replaces costly exploration with structured queries – reducing tool calls by a factor of 3–4 and total workflow costs by around 50%.

The hidden cost driver: exploration, not intelligence

Most people assume that LLM costs come from reasoning. In reality, the biggest cost driver is inefficient exploration. Typical agent behaviour:

  • 1.List directories
  • 2.Search (grep) for patterns
  • 3.Read large files
  • 4.Repeat – every session

This leads to high token consumption, repeated work, slow execution and poor cost predictability. At Arkido, where we specialise in integrations and AI agent-based workflows, this was one of the first bottlenecks we identified when evaluating tools.

Our evaluation: Graphify and the Codebase Knowledge Graph approach

As part of our work on AI-driven development, we evaluated Graphify, a tool that builds a Codebase Knowledge Graph (a knowledge graph of the codebase). The idea is simple but powerful: instead of letting agents rediscover your architecture, you give them a map of your entire codebase structure. Graphify builds this map by extracting:

  • •Dependencies between files and modules
  • •Relationships between functions and components
  • •High-impact "hotspots"
  • •Architectural boundaries

All of this is exposed through lightweight queries instead of extensive file exploration.

The numbers (what actually matters)

We tested the same architecture-heavy task with and without a knowledge graph.

MetricWith GraphifyWithout
Time to complete~45 seconds~3 minutes
Tool calls1865
Reduction3.6× fewer calls—

At Arkido, we do not just look at performance – we look at cost implications. Tool calls = cost multipliers. Reducing them by a factor of 3–4 has a direct impact on your AI budget.

Where the savings actually come from

In a more in-depth benchmark (refactoring + code quality analysis), we broke down the workflow:

PhaseWithout graphWith graph
Structural exploration~25–30 calls~7 calls
Pattern detection (grep etc.)~12 calls~12 calls
Total~37–42~19
  • •~75 % reduction in structural exploration
  • •~50 % reduction overall

The real inefficiency is not in the analysis – it is in finding what to analyse.

The shift: from exploration to structured queries

Old approach (costly)

  • •Explore first
  • •Understand later
  • •Miss things → explore again

New approach (efficient)

  • •Query the structure first
  • •Identify hotspots
  • •Dive into the code with precision
Graph first, grep second. The graph tells you where to look; traditional tools tell you what you are looking at.

Real-world impact on agents

Planning agent

MetricWithoutWith graph
Tool calls~30~8
SpeedBaseline~4× faster

Review agent

MetricWithoutWith graph
Tool calls~12~4
SpeedBaseline~3× faster

Refactoring / architectural analysis

  • •~50 % fewer tool calls
  • •Better identification of high-risk areas

Quality is part of the cost

One of the most overlooked cost drivers is missed context. When agents miss important connections, they produce weaker results, need retries and explore again. In our evaluation, graph-based workflows revealed critical issues that brute-force exploration would likely miss, because the agent started with high-impact nodes rather than random sampling.

Better prioritisation reduces both cost and risk.

A simple cost model

Total AI cost ≈ Cost per call × Number of calls × Attempt factor. A Codebase Knowledge Graph reduces both the number of calls and the attempt factor. That makes the effect multiplicative, not incremental.

This is the same shift we saw in the cloud

BeforeAfter
Let agents explore everythingGive agents structured context
Optimise promptsOptimise workflows
Scale usageControl costs

Trade-offs (and when it makes sense)

Benefits

  • •3–4× fewer tool calls
  • •~50 % overall reduction across workflows
  • •Faster execution
  • •Better architectural decisions
  • •More predictable costs

Limitations

  • •Does not replace code-level inspection
  • •Requires the graph to be kept up to date (automated in practice)

Arkido perspective

From our perspective at Arkido – working at the intersection of integration, architecture and AI agent workflows – this is not just a tool choice. It is an architectural pattern. We see Codebase Knowledge Graphs (with tools such as Graphify) becoming:

  • •A standard component in AI-enabled development platforms
  • •A cost-control mechanism for LLM usage
  • •A foundation for scalable agent-based workflows

Key takeaways

  • •Token usage is the new cloud cost problem
  • •Most of the cost comes from exploration, not reasoning
  • •A Codebase Knowledge Graph eliminates repeated discovery
  • •Graphify proved this in practice: 3.6× fewer tool calls, ~50 % overall reduction
  • •The winning pattern: Graph first, then everything else

Source: Graphify — Kunskapsgraf för kodbas

Frequently asked questions

+What is a knowledge graph for a codebase?

A structured representation of a codebase that maps dependencies and architecture, enabling agents to query its structure instead of exploring files manually.

+How does Graphify reduce token usage?

By replacing costly exploration steps with efficient graph queries, significantly reducing the number of tool calls.

+Why are agent-based workflows expensive?

Because agents repeatedly explore large codebases from scratch, consuming tokens and tool calls without reusable structural context.

+Does this replace tools like grep or file reading?

No. It complements them – graphs handle structure, while traditional tools handle implementation details.

+What are "god nodes"?

Highly interconnected parts of a codebase where changes carry significant impact and risk.

+When should you implement this approach?

When you have growing AI usage, multiple agents or rising costs – especially in complex or long-lived systems where repeated exploration becomes expensive.

Are your AI costs spiralling?

Tell us how you use AI agents today, and we’ll show you how to reduce token usage without compromising quality.

Martin Holmberg, VD – svarar gärna på era frågor.

Martin Holmberg, VD på Arkido

Related articles