Add LLM cost change analysis to CI#1357
Open
Jwrede wants to merge 8 commits intoAgentOps-AI:mainfrom
Open
Conversation
Adds a CI workflow that analyzes LLM API cost changes on pull requests. Posts a comment when model swaps, token limit changes, or new call sites are detected. Stays silent on PRs that don't touch LLM code.
Set default model for dynamic call sites so cost estimates are shown instead of N/A. Bump action to v0.4.0 which supports config files.
v0.5.0 includes built-in per-SDK default models (Anthropic calls use claude-sonnet, Google calls use gemini-flash, etc.) so a .tokentoll.yml config is no longer needed for basic usage.
v0.5.2 fixes false positives where OpenAI-compatible SDKs were misidentified as openai, and skips AzureChatOpenAI calls without an explicit model name. Also pins the pip install version inside the action so the SHA pin is meaningful.
v0.6.0 adds a ZhipuDetector (so Zhipu/GLM calls are attributed correctly) and a constructor-call fallback for OpenAI/Anthropic detectors, recovering DI-style detections that the v0.5.2 strict import check had dropped.
v0.6.1 reverts the v0.6.0 special-case that silently skipped AzureChatOpenAI(deployment_name=...) calls. Those calls now flow through the standard dynamic-default path like every other unresolved model, restoring consistency with the rest of the SDK detectors. The new skip_dynamic_models config option lets projects opt out of cost estimation for dynamic models project-wide or per path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
chat.completions.create,responses.create,embeddings.create)messages.create)generate_content)completion,embedding)ChatOpenAI,ChatAnthropic,init_chat_model)ZhipuAiClient,ZhipuAI)Current scan of this project
tokentoll Scan Report
app/e2e/sdk-api/src/agents/basic_agent.pyapp/e2e/sdk-api/src/agents/basic_agent.pyapp/e2e/sdk-api/src/agents/basic_agent.pyapp/e2e/sdk-api/src/agents/basic_agent.pyapp/e2e/sdk-api/src/agents/basic_agent.pyexamples/anthropic/agentops-anthropic-understanding-tools.pyexamples/anthropic/agentops-anthropic-understanding-tools.pyexamples/anthropic/agentops-anthropic-understanding-tools.pyexamples/anthropic/agentops-anthropic-understanding-tools.pyexamples/anthropic/anthropic-example-async.pyexamples/anthropic/anthropic-example-sync.pyexamples/google_genai/gemini_example.pyexamples/google_genai/gemini_example.pyexamples/google_genai/gemini_example.pyexamples/langchain/langchain_examples.pyexamples/langgraph/langgraph_example.pyexamples/litellm/litellm_example.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/multi_tool_orchestration.pyexamples/openai/o3_responses_example.pyexamples/openai/o3_responses_example.pyexamples/openai/o3_responses_example.pyexamples/openai/o3_responses_example.pyexamples/openai/openai_example_async.pyexamples/openai/openai_example_async.pyexamples/openai/openai_example_sync.pyexamples/openai/openai_example_sync.pyexamples/openai/web_search.pyexamples/openai/web_search.pyexamples/openai/web_search.pyexamples/openai/web_search.pyexamples/openai/web_search.pyexamples/xai/grok_examples.pyexamples/xai/grok_vision_examples.pyexamples/xpander/coding_agent.pytests/core_manual_tests/benchmark.pytests/core_manual_tests/canary.pytests/core_manual_tests/multi_session_llm.pytests/core_manual_tests/providers/anthropic_canary.pytests/core_manual_tests/providers/anthropic_canary.pytests/core_manual_tests/providers/anthropic_canary.pytests/core_manual_tests/providers/anthropic_canary.pytests/core_manual_tests/providers/litellm_canary.pytests/core_manual_tests/providers/litellm_canary.pytests/core_manual_tests/providers/litellm_canary.pytests/core_manual_tests/providers/litellm_canary.pytests/core_manual_tests/providers/openai_canary.pytests/core_manual_tests/providers/openai_canary.pytests/core_manual_tests/providers/openai_canary.pytests/core_manual_tests/providers/openai_canary.pytests/smoke/test_openai.pytests/unit/instrumentation/fixtures/generate_anthropic_fixtures.pytests/unit/instrumentation/fixtures/generate_anthropic_fixtures.pytests/unit/instrumentation/fixtures/generate_anthropic_fixtures.pytests/unit/instrumentation/fixtures/generate_anthropic_fixtures.pytests/unit/instrumentation/fixtures/generate_anthropic_fixtures.pyTotal estimated monthly cost: $1163.61
Assumptions
Generated by tokentoll
How it works
Changes
.github/workflows/llm-costs.yml(17 lines)