---
title: "LLM Cost Optimization: 3 Patterns to Cut LLM Token Spend"
description: "LLM token spend is best reduced by using traces to find three waste patterns: repeated input context that doesn't improve results, retry storms and runaway agent loops, and output tokens that don't lift outcomes."
url: "https://swe.quest/articles/llm-cost-optimization-3-patterns-to-cut-llm-token-spend-f19f5dd3713227bf"
canonical: "https://www.honeycomb.io/blog/llm-cost-optimization-patterns"
source: "Honeycomb"
published: "2026-11-05"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["llms","cost-optimization","observability","ai-agents"]
---

# LLM Cost Optimization: 3 Patterns to Cut LLM Token Spend

A post on [Honeycomb](https://swe.quest/sources/honeycomb.md), published 2026-11-05, 9 min read, How-to. Original: [https://www.honeycomb.io/blog/llm-cost-optimization-patterns](https://www.honeycomb.io/blog/llm-cost-optimization-patterns)

## Summary

LLM token spend is best reduced by using traces to find three waste patterns: repeated input context that doesn't improve results, retry storms and runaway agent loops, and output tokens that don't lift outcomes. For each, compare expensive and normal cohorts on high-cardinality attributes (prompt version, model, workflow step, tenant, retries) and apply targeted fixes such as filtering retrieval, summarizing history, retry limits, tighter termination conditions and structured outputs. Treat every cost cut as a production change: baseline cost per successful outcome, change one pattern at a time, and roll back if quality guardrails like completion, acceptance or parsing success regress.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)

## Prerequisites

- distributed tracing basics ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))
- LLM API usage ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

Honeycomb, distributed tracing

## Related posts

- [Everything We Talked About at O11yDay London 2026](https://swe.quest/articles/everything-we-talked-about-at-o11yday-london-2026-0f7b0e96a8f38f57.md): Honeycomb · 2026-10-16 · Medium · 11 min read · AI agents, Observability, AI for coding, Code review, Cost optimization
  Across ten sessions at O11yDay London, the recurring bottleneck was not writing code but reviewing it, operating agents in production, and proving the spend is worth it.
- [Controlling costs when building with AI](https://swe.quest/articles/controlling-costs-when-building-with-ai-e6fb1a0a01ec2e9a.md): incident.io · 2025-03-25 · Medium · 10 min read · LLMs, Cost optimization, Observability, Go
  After hitting OpenAI billing limits broke its early AI features, incident.io built per-prompt cost attribution into its Go LLM abstraction, using reflection to capture each prompt's type name alongside token usage and emitting it to Grafana metrics and Postgres records for BI.
- [Building Deep Research: How we Achieved State of the Art](https://swe.quest/articles/building-deep-research-how-we-achieved-state-of-the-art-414ffb743a73bb80.md): Hugging Face · 2025-11-24 · Medium · 7 min read · AI agents, LLMs, Evaluation
  Tavily's deep research agent reached state of the art on DeepResearch Bench while using 66% fewer tokens than LangChain's Open Deep Research, mainly through context engineering.
- [Beyond LLMs: Why Scalable Enterprise AI Adoption Depends on Agent Logic](https://swe.quest/articles/beyond-llms-why-scalable-enterprise-ai-adoption-depends-on-agent-logic-477b5d921dc6bbb1.md): Hugging Face · 2026-06-01 · Easy · 10 min read · AI agents, LLMs, Static analysis, Incidents & postmortems, Testing
  Agent logic, meaning deterministic software primitives such as program analysis, knowledge graphs, DAGs and planning algorithms running inside the agent harness, steers LLMs toward enterprise workflows and shrinks their context.
- [How we make AI coding more cost efficient without sacrificing task quality](https://swe.quest/articles/how-we-make-ai-coding-more-cost-efficient-without-sacrificing-task-quality-07be31d835dcfb01.md): GitHub Engineering · 2026-09-02 · Medium · 10 min read · AI agents, AI for coding, LLMs, Evaluation, Cost optimization
  GitHub Copilot cut agent costs by optimizing for whole-task outcomes rather than per-tool-call token counts, after finding that aggressive shell-output compression (RTK) made agents reread or rerun commands and raised end-to-end cost.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
