feat: update dependencies and add token usage reporting for AI providers#27146
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning MetaMask internal reviewing guidelines:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
✅ E2E Fixture Validation — Schema is up to date |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
@SocketSecurity ignore npm/openai@6.25.0. |
|



Description
Upgrades the smart E2E selector's AI provider stack and adds token usage
and cost reporting to make it easier to monitor and compare provider costs.
Provider changes
openai → anthropic → googlepriority)gpt-5.2-chat-latestclaude-sonnet-4-6(wasclaude-opus-4-5-20251101)SDK upgrades
openai:^4.77.0→^6.25.0@anthropic-ai/sdk:^0.71.0→^0.78.0ChatCompletionMessageToolCallis nowa discriminated union — added
toolCall.type === 'function'guard beforeaccessing
.functionError visibility
isAvailable()catch blocks now log the actual API error insteadof silently returning
falsefailed API call
Token cost tracking
LLMUsagetype toLLMResponse— all three providers now returninputTokens/outputTokensper API callanalyzeWithAgentaccumulates totals across iterations and prints a costreport on completion
MODEL_PRICINGtable added toconfig.ts(keyed to the three active models)Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Medium risk due to major
openaiSDK upgrade and provider/model default changes that can alter analyzer behavior and costs, though the impact is confined to test tooling.Overview
Updates the
tests/tools/e2e-ai-analyzerprovider stack by upgradingopenaito v6 and@anthropic-ai/sdk, switching the default provider priority to OpenAI → Anthropic → Google, and updating the default OpenAI/Anthropic model IDs.Adds token usage + estimated cost reporting: introduces
LLMUsageonLLMResponse, populates usage from all three providers, accumulates totals across agent iterations inanalyzeWithAgent, and prints a final report using a newMODEL_PRICINGtable.Improves provider diagnostics by logging underlying API errors during
isAvailable()checks and making availability output distinguish between missing API keys and failed API calls; also adds an OpenAI v6 tool-call type guard (toolCall.type === 'function') when decoding tool uses.Written by Cursor Bugbot for commit 8389bd8. This will update automatically on new commits. Configure here.