Skip to content

Add LLM cost change analysis to CI#737

Open
Jwrede wants to merge 1 commit into
JudgmentLabs:mainfrom
Jwrede:add-tokentoll-cost-analysis
Open

Add LLM cost change analysis to CI#737
Jwrede wants to merge 1 commit into
JudgmentLabs:mainfrom
Jwrede:add-tokentoll-cost-analysis

Conversation

@Jwrede
Copy link
Copy Markdown

@Jwrede Jwrede commented May 4, 2026

Summary

Add tokentoll GitHub Action to analyze LLM API cost changes on pull requests.

When a PR modifies code that makes LLM API calls (model swaps, max_tokens changes, new call sites), tokentoll posts a comment showing the projected cost impact. It stays silent on PRs that don't touch LLM code.

What it detects

tokentoll uses Python AST analysis (zero runtime dependencies) to find calls to:

  • OpenAI (chat.completions.create, responses.create, embeddings.create)
  • Anthropic (messages.create)
  • Google GenAI (generate_content)
  • LiteLLM (completion, embedding)
  • LangChain (ChatOpenAI, ChatAnthropic, init_chat_model)
  • Zhipu AI / GLM (ZhipuAiClient, ZhipuAI)

Current scan of this project

tokentoll Scan Report

File Line SDK Model Est. Cost/Call Monthly
api/agent/core/llm_utils.py 356 litellm gpt-4o (default) $0.04 $42.21
api/agent/core/llm_utils.py 359 litellm gpt-4o (default) $0.04 $42.21
api/agent/tools/outbound_duplicate_guard.py 199 litellm gpt-4o (default) $0.04 $42.21
console/api_views.py 1106 litellm gpt-4o (default) $0.04 $42.21
scripts/marketing/email-campaign.py 55 litellm gpt-4o (default) $0.04 $42.21
scripts/prototype/agent.py 70 litellm openrouter/google/gemini-2.5-pro $0.02 $21.11

Total estimated monthly cost: $232.16

Assumptions
  • 1000 calls/month per call site

Generated by tokentoll

How it works

  • Runs only on PRs, compares base vs head
  • Posts a sticky comment (updates in place, no duplicates)
  • Only comments when LLM calls are added, removed, or modified
  • First run posts an initial scan (this PR) so you can see the output
  • Zero runtime dependencies, ~1s scan time for most projects
  • PyPI | GitHub

Changes

  • Adds .github/workflows/llm-costs.yml (17 lines)
  • No code changes, no new dependencies

Adds a CI workflow that runs tokentoll on pull requests to detect
changes in LLM API calls (model swaps, new call sites, removed
endpoints) and posts the cost impact as a PR comment.

The action is pinned to SHA 753ca4d1150c74169b52a843439049b65e256d2b (v0.6.1) and installs
tokentoll==v0.6.1 from PyPI. Zero runtime dependencies.
Copy link
Copy Markdown

@propel-code-bot propel-code-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review found no issues; the CI cost-analysis workflow addition is well-scoped and safe.

Status: No Issues Found | Risk: Low

Review Details

📁 1 files reviewed | 💬 0 comments

@propel-code-bot
Copy link
Copy Markdown

✔️ Propel has finished reviewing this change.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant