You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your interest! I've assigned this to you. Before you start, could you give the repo a ⭐? It really helps with visibility for a new project. Looking forward to your PR!
A clean way to do this is to reuse the same accounting path as stream(): add a small provider-local helper like _apply_usage(response) and call it at the end of call_with_tools(). That keeps OpenAI/Mistral/Anthropic/Gemini parsing differences isolated while guaranteeing llm.tokens_used stays consistent across sync + streaming paths. I’d also add one regression test per provider with a minimal mocked response object, so future SDK field changes fail fast.
Thanks for your interest! I will assign it to you. Before you start, could you give the repo a ⭐? It really helps with visibility for a new project. Looking forward to your PR!
so in our Current state OpenAI's call_with_tools() already tracks tokens (lines 80-81), but looking at the other providers:
OpenAI — tracks tokens in call_with_tools() ✅
Anthropic, Gemini, Mistral — likely don't track tokens in call_with_tools() (they do in stream() but not the non-streaming tool call path)
The suggestion is sound:
_apply_usage(response) helper — each provider parses usage differently (OpenAI: response.usage.prompt_tokens, Anthropic:response.usage.input_tokens, Gemini: response.usage_metadata.prompt_token_count). A per-provider helper keeps that parsing isolated and DRY betweenstream() and call_with_tools().
One test per provider with mocked response iis exactly the right approach, catches SDK field changes early.
Keeps tokens_used consistent: right now an agent using call_with_tools() on Gemini/Mistral/Anthropic would show 0 tokens, which is a bug.
Resolved in v1.2.0 with CostTracker (hierarchical cost attribution with scope context manager) and BudgetGuard (budget limits with circuit breaker). See #316.
Activity
AmitoVrito commentedon Mar 12, 2026
Thanks for your interest! I've assigned this to you. Before you start, could you give the repo a ⭐? It really helps with visibility for a new project. Looking forward to your PR!
passionworkeer commentedon Mar 12, 2026
A clean way to do this is to reuse the same accounting path as stream(): add a small provider-local helper like _apply_usage(response) and call it at the end of call_with_tools(). That keeps OpenAI/Mistral/Anthropic/Gemini parsing differences isolated while guaranteeing llm.tokens_used stays consistent across sync + streaming paths. I’d also add one regression test per provider with a minimal mocked response object, so future SDK field changes fail fast.
AmitoVrito commentedon Mar 12, 2026
Thanks for your interest! I will assign it to you. Before you start, could you give the repo a ⭐? It really helps with visibility for a new project. Looking forward to your PR!
AmitoVrito commentedon Mar 12, 2026
so in our Current state OpenAI's call_with_tools() already tracks tokens (lines 80-81), but looking at the other providers:
The suggestion is sound:
i welcome this PR!!
AmitoVrito commentedon Mar 20, 2026
Resolved in v1.2.0 with
CostTracker(hierarchical cost attribution with scope context manager) andBudgetGuard(budget limits with circuit breaker). See #316.Hotfix SynapseKit#2