Skip to content

Cost: apply LLM cost-mitigation before scaling usage (caching / routing / batch / context) #57

Description

@atomicdragonranch

Reference lives in docs/llm-cost-optimization.md (PR #56). Tracking so it surfaces while working on the agent , act on these as usage grows:

  • Prompt-cache the stable prefix (system prompt + tool defs). Verify usage.cache_read_input_tokens > 0; audit the prefix for silent invalidators (timestamps/UUIDs/unsorted JSON). ~0.1x cost on cached reads.
  • Model routing , move cheap steps (classification/triage/extraction) to Haiku or rules; reserve Opus for hard reasoning. Keep the main loop on one model; delegate cheap sub-steps to Haiku subagents.
  • Batch API (50% off) for any non-latency-sensitive work (backfills, bulk/scheduled runs); stacks with caching.
  • Context management on long loops , compaction / context-editing + effort/task_budget.
  • Measure-first , baseline with count_tokens + usage before optimizing.

Cost impact: $0 to adopt (config/architecture); goal is to cut recurring inference spend (caching + routing alone often >50%).

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentClaude Agent SDK, agentic architecturedocumentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions