Skip to content

Automate browser based workflows with AI

Add workflow_run_id and task_id to LLM duration metrics logs (#5222)

pedrohsdb6aad5b0054ed
diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.py
index f68fc1b0f..02a55309b 100644
--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py
+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py
@@ -902,6 +902,8 @@ class LLMAPIHandlerFactory:
step_id=step.step_id if step else None,
thought_id=thought.observer_thought_id if thought else None,
organization_id=organization_id,
+ workflow_run_id=context.workflow_run_id if context else None,
+ task_id=context.task_id if context else None,
input_tokens=prompt_tokens if prompt_tokens > 0 else None,
output_tokens=completion_tokens if completion_tokens > 0 else None,
reasoning_tokens=reasoning_tokens if reasoning_tokens > 0 else None,
@@ -1366,6 +1368,8 @@ class LLMAPIHandlerFactory:
step_id=step.step_id if step else None,
thought_id=thought.observer_thought_id if thought else None,
organization_id=organization_id,
+ workflow_run_id=context.workflow_run_id if context else None,
+ task_id=context.task_id if context else None,
input_tokens=prompt_tokens if prompt_tokens > 0 else None,
output_tokens=completion_tokens if completion_tokens > 0 else None,
reasoning_tokens=reasoning_tokens if reasoning_tokens > 0 else None,
@@ -1735,6 +1739,8 @@ class LLMCaller:
step_id=step.step_id if step else None,
thought_id=thought.observer_thought_id if thought else None,
organization_id=organization_id,
+ workflow_run_id=context.workflow_run_id if context else None,
+ task_id=context.task_id if context else None,
input_tokens=call_stats.input_tokens if call_stats and call_stats.input_tokens else None,
output_tokens=call_stats.output_tokens if call_stats and call_stats.output_tokens else None,
reasoning_tokens=call_stats.reasoning_tokens if call_stats and call_stats.reasoning_tokens else None,