Expanded LLM/STT/TTS usage tracking across pre-prod flows and some fixes - #119
Expanded LLM/STT/TTS usage tracking across pre-prod flows and some fixes#119MSami625 wants to merge 56 commits into
Conversation
…3 artifacts on preview
…and actor stamping
…oved task dispatching
…ics across services
… for usage features
…tion in Docker and API
…rocess_evaluator_result.py
…ing and cache/Ui fixes
…r available models
…iguration for periodic job scheduling
…sage pricing routes; enhance usage snapshot billability checks
…eamline cost calculations for pending usage deltas
…ed references in the documentation
…ations; enforce CSP and adjust token lifetimes
… API keys; refactor local storage clearing logic
…orm logouts; streamline local storage clearing
…or evaluator results and metric studio runs; improve CSP policy for voice provider connections
|
| Filename | Overview |
|---|---|
| app/services/playground/post_call_processing.py | Adds row-locked playground post-call deduplication, but the previously reported gap between additive usage application and dedup-flag commit remains. |
| app/api/v1/routes/playground.py | Integrates the new post-call claims and prevents duplicate evaluator creation through a locked create-and-link transaction. |
| app/services/usage/external_agent_usage.py | Extracts provider-specific usage and records contextual LLM, STT, and TTS counters while propagating incomplete recording outcomes. |
| app/workers/tasks/run_evaluator.py | Adds voice-bundle LLM simulation and safer event-loop handling, but whole-task retries still replay already billed simulation turns. |
| app/services/testing/llm_to_llm_evaluator_simulation.py | Implements turn-based evaluator simulation and records usage per call, with durable simulation state written only after all turns finish. |
Reviews (12): Last reviewed commit: "feat(playground): enhance call data proc..." | Re-trigger Greptile
…n events and audio billing; enhance CSP policy for frame sources
…API routes and services;
…g evaluator result creation and usage tracking;
…oducing patching for blob storage and integrating new storage stubs
…processing; improve error handling during database commits
…call usage tracking; update test to reflect new behavior
… tests; update configuration and service logic to prevent external API calls
… conversation tracking in test agents and voice agents
…and update configuration for Flexprice setup
…icense features to canonical meters with dry-run option
…ribe functionality and updating configuration options
…pt partial AI assistance, enhancing tracking for generated prompts and scenarios
…information and updating event handling for playground calls and fix sarvam ai flooding logs
What Changed?
external_agent_usage.pyto extract and record provider usage from Vapi, Retell, ElevenLabs, and Smallest call payloadsexternal_usage_recorded)run_evaluatorasyncio event loop handling for voice-bridge runsconnect-src/worker-srcfor voice provider WebRTC connectionsWhy?
Pre-prod testing (evaluators, playground, personas, Metrics Studio) was not consistently attributing LLM/STT/TTS usage, and external voice provider token usage from call payloads was not being captured. This gives accurate per-workspace usage/cost tracking across synthetic testing and live provider calls.
How to Test?
pytest tests/test_services/test_usage/test_pre_prod_usage.py tests/test_services/test_usage/test_test_agent_simulation_usage.py tests/test_services/test_testing/test_llm_to_llm_evaluator_simulation.py tests/test_core/test_security_headers_middleware.py -vTEST_AGENTRelease Label
major- breaking change, next release bumps major versionminor- backward-compatible feature, next release bumps minor versionfix- backward-compatible bug fix, next release bumps patch versionChecklist
CONTRIBUTING.mdguide.