Speed optimizations: Economy element tree and TOTP context parsing skip (#3936)

This commit is contained in:
pedrohsdb
2025-11-06 21:56:52 -08:00
committed by GitHub
parent 44528cbd38
commit d8631151ba
4 changed files with 131 additions and 11 deletions

View File

@@ -571,8 +571,30 @@ class AgentFunction:
if "children" in queue_ele:
queue.extend(queue_ele["children"])
# Convert all eligible SVGs in parallel
if eligible_svgs:
# SPEED OPTIMIZATION: Skip SVG conversion when using economy tree
# Economy tree removes SVGs, so no point converting them
#
# COORDINATION: Use the same enable_speed_optimizations decision from context
# that was set in agent.py BEFORE scraping. This ensures SVG conversion skip
# is perfectly coordinated with economy tree selection.
skip_svg_conversion = False
if eligible_svgs and task and step:
# Get the optimization decision from context (set before scraping in agent.py)
current_context = skyvern_context.current()
enable_speed_optimizations = current_context.enable_speed_optimizations if current_context else False
if enable_speed_optimizations and step.retry_index == 0:
skip_svg_conversion = True
LOG.info(
"Speed optimization: Skipping SVG conversion (will use economy tree)",
step_order=step.order,
step_retry=step.retry_index,
workflow_run_id=task.workflow_run_id,
svg_count=len(eligible_svgs),
)
# Convert all eligible SVGs in parallel (unless skipped by optimization)
if eligible_svgs and not skip_svg_conversion:
await asyncio.gather(*[_convert_svg_to_string(element, task, step) for element, frame in eligible_svgs])
return element_tree