Skip to content

Automate browser based workflows with AI

fix cannot access local variable 'prompt_tokens' where it is not associated with a value (#3286)

Shuchang Zhengb9470ffb443f
diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.py
index 95762bac4..a87a75729 100644
--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py
+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py
@@ -198,6 +198,13 @@ class LLMAPIHandlerFactory:
thought=thought,
ai_suggestion=ai_suggestion,
)
+ prompt_tokens = 0
+ completion_tokens = 0
+ reasoning_tokens = 0
+ cached_tokens = 0
+ completion_token_detail = None
+ cached_token_detail = None
+ llm_cost = 0
if step or thought:
try:
# FIXME: volcengine doesn't support litellm cost calculation.