Back to case studies

Token optimization

53% lower token costs

Four teams cut coding-agent token costs by 53%. Cortiscale matched model capability to task difficulty and customized the Pi harness, which manages an agent's context, tools, and execution loop.

Impact

Lower token costs
53%
Developers across four teams
32
Teams using the shared setup
4

Task-based routing and focused context reduced spend while task success stayed broadly stable.

The challenge

Nearly every task used the same expensive model. Simple documentation edits and test updates received the same treatment as difficult debugging, even when they did not need the same capability.

Long instructions, repeated file reads, and full build logs inflated context. Repeated inputs and attempts made agent spending difficult to predict.

What we changed

  1. Match the model to the task

    Cortiscale introduced task-based routing. Lower-cost models handled predictable edits and summaries; stronger models handled complex debugging and design decisions. Failed checks or uncertain results triggered escalation, with explicit retry limits.

  2. Focus the agent's context

    Custom Pi extensions loaded relevant instructions and code context for each task. Tools returned focused file excerpts and concise test failures, while full logs stayed available when needed. Long sessions kept a compact decision record instead of repeatedly sending the entire history.

  3. Measure cost against useful output

    A shared dashboard tracked model choice, token usage, retries, and cost per completed task. The teams compared representative workloads and task success before expanding the routing rules.

Before and after

Before

  • One expensive model handled almost every task.
  • Bloated context and repeated inputs increased token use.
  • Spending was difficult to relate to useful completed work.

After

  • Model capability matched the difficulty of the work.
  • The customized harness sent more focused context.
  • The team could see the model cost of each successful task.

Results

Model API cost per successful task fell by 53%, including failed attempts and retries. Task-based routing and a focused harness reduced unnecessary model spend.

What changed for the team

The teams reduced token costs and gained a clearer view of the cost of useful agent output. Model routing and focused context made the platform more economical while task success stayed broadly stable.

Start a conversation

What would you like your team to achieve with AI?

Tell us how your software team uses AI today and what you’d like to improve. We’ll discuss whether tailored training or an ongoing collaboration fits.