Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(extraction-cache): prompt normalization pipeline (SKY-8872) (#5504)
Aaron Perez52ec84461215
diff --git a/pyproject.toml b/pyproject.tomlindex 1145f40e9..19cf9de73 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -60,6 +60,7 @@ dependencies = ["onepassword-sdk==0.4.0","types-boto3[full]>=1.38.31,<2","lark>=1.2.2,<2",+ "selectolax>=0.3.28,<0.4","libcst>=1.8.2,<2","curlparser>=0.1.0,<0.2","pandas>=2.3.1,<4",diff --git a/skyvern/core/script_generations/real_skyvern_page_ai.py b/skyvern/core/script_generations/real_skyvern_page_ai.pyindex 87957f465..9de35bcdb 100644--- a/skyvern/core/script_generations/real_skyvern_page_ai.py+++ b/skyvern/core/script_generations/real_skyvern_page_ai.py@@ -23,7 +23,7 @@ from skyvern.schemas.workflows import BlockStatusfrom skyvern.services import script_servicefrom skyvern.services.otp_service import poll_otp_valuefrom skyvern.utils.css_selector import compute_selector_options-from skyvern.utils.prompt_engine import load_prompt_with_elements+from skyvern.utils.prompt_engine import load_prompt_with_elements, load_prompt_with_elements_trackedfrom skyvern.utils.prompt_truncation import truncate_extraction_schemafrom skyvern.webeye.actions import handler_utilsfrom skyvern.webeye.actions.actions import (@@ -919,33 +919,69 @@ class RealSkyvernPageAi(SkyvernPageAi):# that will be sent to the LLM (captures economy-tree swaps and 2/3# truncation inside load_prompt_with_elements).extracted_text_for_prompt = self.scraped_page.extracted_text if include_extracted_text else None-- extract_information_prompt = load_prompt_with_elements(+ capped_schema = truncate_extraction_schema(schema)+ # Normalize error_code_mapping to the exact string the prompt will+ # render (None when falsy). Hashing this string below means None and+ # {} collapse to one key since both drop the prompt block.+ error_code_mapping_str = json.dumps(error_code_mapping) if error_code_mapping else None++ # Use the _tracked variant so the cache key below can hash post-ceiling+ # values — when the prompt exceeds the hard ceiling,+ # enforce_prompt_ceiling drops fields to None and two requests that+ # render to the same final LLM prompt must share a cache key.+ extract_information_prompt, post_ceiling_kwargs = load_prompt_with_elements_tracked(element_tree_builder=self.scraped_page,prompt_engine=prompt_engine,template_name="extract-information",html_need_skyvern_attrs=False,data_extraction_goal=prompt,- extracted_information_schema=truncate_extraction_schema(schema),+ extracted_information_schema=capped_schema,current_url=self.scraped_page.url,extracted_text=extracted_text_for_prompt,- error_code_mapping_str=(json.dumps(error_code_mapping) if error_code_mapping else None),+ error_code_mapping_str=error_code_mapping_str,local_datetime=local_datetime_str,)- # Share the extract-information cache with the agent path. Best-effort- # per the RFC review — any exception falls through to the full LLM- # call below. The `try` is narrowed to just compute_cache_key + lookup- # so a downstream log failure can't re-enter the except block and- # double-count the call as both a hit/miss and a `lookup_error` in- # the Datadog miss-reason metric.+ # Cache extract-information within this script-generation path. The+ # `call_path="script"` discriminator structurally isolates these keys+ # from the agent/handler paths so a script-path hit can never replay+ # an agent-path result (or vice versa), even when all other inputs+ # happen to hash identically (e.g. a goal with no `{{ var }}`+ # substitutions and no nav/prev context).+ #+ # Best-effort per the RFC review — any exception falls through to the+ # full LLM call below. The `try` is narrowed to just compute_cache_key+ # + lookup so a downstream log failure can't re-enter the except block+ # and double-count the call as both a hit/miss and a `lookup_error`+ # in the Datadog miss-reason metric.workflow_run_id = context.workflow_run_id if context else Nonecache_key: str | None = Nonelookup_result: extraction_cache.LookupResult | None = Nonetry:+ # Use the variant of the element tree that load_prompt_with_elements+ # actually rendered (could be economy or 2/3-truncated under token+ # pressure). Falls back to a fresh HTML build when the prior build+ # used fmt=JSON (field is None in that case). The fallback call+ # mutates `last_used_element_tree{_html}` on self.scraped_page;+ # this is intentional — nothing downstream reads those fields after+ # the cache key is computed.+ # navigation_payload / previous_extracted_information intentionally+ # omitted — ai_extract is the script-generation extract path and+ # doesn't carry navigation context.+ # Hash the post-ceiling values so two requests that differ only in+ # dropped fields (schema/extracted_text on oversized prompts) and+ # render to the same final LLM prompt share a cache key.cache_key = extraction_cache.compute_cache_key(- rendered_prompt=extract_information_prompt,+ call_path="script",+ element_tree=self.scraped_page.last_used_element_tree_html+ or self.scraped_page.build_element_tree(html_need_skyvern_attrs=False),+ extracted_text=post_ceiling_kwargs["extracted_text"],+ current_url=self.scraped_page.url,+ data_extraction_goal=prompt,+ extracted_information_schema=post_ceiling_kwargs["extracted_information_schema"],+ error_code_mapping=error_code_mapping_str,llm_key=None,+ local_datetime=local_datetime_str,)lookup_result = extraction_cache.lookup(workflow_run_id, cache_key)except Exception:@@ -963,7 +999,7 @@ class RealSkyvernPageAi(SkyvernPageAi):# Preserve cache_key so the downstream store() can still warm the cache# for subsequent identical calls even when lookup() fails transiently.- if lookup_result is not None and lookup_result.hit:+ if lookup_result is not None and lookup_result.hit and isinstance(lookup_result.value, (dict, list, str)):LOG.info("ai_extract cache hit — skipping LLM call",workflow_run_id=workflow_run_id,@@ -974,8 +1010,16 @@ class RealSkyvernPageAi(SkyvernPageAi):fallback_reason=None,cache_path="script",)- return lookup_result.value # type: ignore[return-value]- if lookup_result is not None:+ return lookup_result.value+ if lookup_result is not None and lookup_result.hit:+ LOG.warning(+ "ai_extract cache hit returned non-cacheable value type; falling through to LLM",+ workflow_run_id=workflow_run_id,+ cache_key=cache_key,+ value_type=type(lookup_result.value).__name__,+ cache_path="script",+ )+ elif lookup_result is not None:LOG.info("ai_extract cache miss",workflow_run_id=workflow_run_id,@@ -1009,8 +1053,10 @@ class RealSkyvernPageAi(SkyvernPageAi):)# Cache the post-validation result so cache hits return the same- # schema-validated shape as a fresh LLM call.- if cache_key is not None and result is not None:+ # schema-validated shape as a fresh LLM call. Accept dict / list / str+ # — the `extract-information` prompt uses `force_dict=False`, so root+ # `type: array` or scalar schemas are valid return shapes.+ if cache_key is not None and isinstance(result, (dict, list, str)):try:extraction_cache.store(workflow_run_id, cache_key, result)except Exception:diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.pyindex 9c854f464..c4b7e14d9 100644--- a/skyvern/forge/agent.py+++ b/skyvern/forge/agent.py@@ -116,7 +116,7 @@ from skyvern.utils.image_resizer import Resolutionfrom skyvern.utils.prompt_engine import (PROMPT_HARD_CEILING_TOKENS,MaxStepsReasonResponse,- enforce_prompt_ceiling,+ enforce_prompt_ceiling_tracked,load_prompt_with_elements,)from skyvern.utils.prompt_truncation import truncate_extraction_schema@@ -5067,16 +5067,17 @@ class ForgeAgent:@staticmethodasync def create_extract_action(task: Task, step: Step, scraped_page: ScrapedPage) -> ExtractAction:context = skyvern_context.ensure_context()+ local_datetime_str = datetime.now(context.tz_info).isoformat()capped_schema = truncate_extraction_schema(task.extracted_information_schema)# generate reasoning by prompt llm to think briefly what data to extractsummary_kwargs: dict[str, Any] = {"data_extraction_goal": task.data_extraction_goal,"data_extraction_schema": capped_schema,"current_url": scraped_page.url,- "local_datetime": datetime.now(context.tz_info).isoformat(),+ "local_datetime": local_datetime_str,}prompt = prompt_engine.load_prompt("data-extraction-summary", **summary_kwargs)- prompt = enforce_prompt_ceiling(+ prompt, post_ceiling_kwargs = enforce_prompt_ceiling_tracked(prompt,prompt_engine=prompt_engine,template_name="data-extraction-summary",@@ -5091,8 +5092,18 @@ class ForgeAgent:cache_key: str | None = Nonelookup_result: extraction_cache.LookupResult | None = Nonetry:+ # data-extraction-summary is goal-agnostic: only goal/schema/URL/datetime+ # affect the rendered prompt, so everything else is intentionally omitted.+ # Hash the post-ceiling value for `data_extraction_schema` — when the+ # rendered prompt exceeds PROMPT_HARD_CEILING_TOKENS the ceiling drops+ # that field to None, so two oversized-schema requests that both get+ # dropped produce an identical LLM prompt and must share a cache key.cache_key = extraction_cache.compute_cache_key(- rendered_prompt=prompt,+ call_path="agent",+ data_extraction_goal=task.data_extraction_goal,+ extracted_information_schema=post_ceiling_kwargs["data_extraction_schema"],+ current_url=scraped_page.url,+ local_datetime=local_datetime_str,llm_key=None,)lookup_result = extraction_cache.lookup(workflow_run_id, cache_key)@@ -5111,7 +5122,7 @@ class ForgeAgent:# Preserve cache_key so the store() below can still warm the cache# for subsequent identical calls even when lookup() fails transiently.- if lookup_result is not None and lookup_result.hit:+ if lookup_result is not None and lookup_result.hit and isinstance(lookup_result.value, dict):LOG.info("data-extraction-summary cache hit — skipping LLM call",workflow_run_id=workflow_run_id,@@ -5124,7 +5135,17 @@ class ForgeAgent:)data_extraction_summary_resp = lookup_result.valueelse:- if lookup_result is not None:+ if lookup_result is not None and lookup_result.hit and not isinstance(lookup_result.value, dict):+ LOG.warning(+ "data-extraction-summary cache hit returned non-dict value; falling through to LLM",+ workflow_run_id=workflow_run_id,+ cache_key=cache_key,+ value_type=type(lookup_result.value).__name__,+ cache_path="agent",+ )+ elif lookup_result is not None:+ # Genuine miss only — non-dict hits are logged as a warning above and+ # must NOT also emit a miss log (would double-count in Datadog).LOG.info("data-extraction-summary cache miss",workflow_run_id=workflow_run_id,@@ -5138,11 +5159,7 @@ class ForgeAgent:data_extraction_summary_resp = await app.EXTRACTION_LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="data-extraction-summary")- # Guard on both cache_key and response to match the other two call sites- # and avoid caching None — a cached None would later produce hit=True/value=None,- # which would then trip the RuntimeError below instead of falling through to a- # fresh LLM call as the pre-telemetry get()-returns-None path did.- if cache_key and data_extraction_summary_resp is not None:+ if cache_key and isinstance(data_extraction_summary_resp, dict):extraction_cache.store(workflow_run_id, cache_key, data_extraction_summary_resp)if data_extraction_summary_resp is None:diff --git a/skyvern/forge/sdk/cache/extraction_cache.py b/skyvern/forge/sdk/cache/extraction_cache.pyindex 09f79a26c..379e26798 100644--- a/skyvern/forge/sdk/cache/extraction_cache.py+++ b/skyvern/forge/sdk/cache/extraction_cache.py@@ -49,8 +49,10 @@ import timefrom collections import OrderedDictfrom dataclasses import dataclassfrom typing import Any+from urllib.parse import urlparse, urlunparseimport structlog+from selectolax.parser import HTMLParserLOG = structlog.get_logger()@@ -117,14 +119,203 @@ _HIT_RATE_LOG_INTERVAL = 50 # log hit rate every N lookups_ISO_LINE_RE = re.compile(r"^(\d{4}-\d{2}-\d{2})T[\d:.+\-]+$", re.MULTILINE)-def _normalize_prompt_datetime(prompt: str) -> str:- """Replace ISO timestamp lines in the prompt with their date-only prefix.+def _normalize_datetime_lines(text: str) -> str:+ """Collapse ISO-timestamp-only lines to their date prefix so same-day calls+ hash identically. Operates on any plain-text input (rendered prompts,+ extracted text, etc.); only the key-derivation copy is normalized.+ """+ return _ISO_LINE_RE.sub(lambda m: m.group(1), text)+++# Query parameter names treated as nondeterministic nonces/session tokens.+# Values are replaced with a placeholder; the param is still kept so the+# presence/absence of the param still matters. Only names that are+# unambiguously cachebusters/CSRF/session markers are listed — ambiguous+# short names like `state`, `token`, `sid`, `ts`, and `cb` (callback,+# category, customer bucket) are excluded because redacting them risks+# false cache hits when they're primary differentiators.+_NONCE_PARAM_NAMES = frozenset(+ {+ "_",+ "_csrf",+ "authenticity_token",+ "cache_buster",+ "cachebuster",+ "csrf",+ "csrf_token",+ "csrfmiddlewaretoken",+ "csrftoken",+ "nonce",+ "session_id",+ "sessionid",+ "timestamp",+ }+)+++# Element attribute names whose values are treated as nondeterministic and+# replaced with a sentinel during cache-key derivation. Scoped to identifier+# attributes — values of `class`, `href`, `src`, `alt`, `title`, and `name`+# are preserved because they typically differentiate real pages.+# NOTE: `name` is intentionally excluded — <input name="field_name"> carries+# semantic field identity (not a transient ID) and must differentiate pages.+_SUSPECT_ATTR_NAMES = frozenset(+ {+ "id",+ "for",+ "aria-labelledby",+ "aria-describedby",+ "data-testid",+ }+)++# <input name="..."> values that are CSRF/anti-forgery tokens. The value is+# replaced with "" (empty string) during canonicalization.+_CSRF_INPUT_NAMES = frozenset(+ {+ "_csrf",+ "_token",+ "authenticity_token",+ "csrf",+ "csrf_token",+ "csrfmiddlewaretoken",+ "csrftoken",+ "__requestverificationtoken",+ }+)++# <meta name="..."> values that carry CSRF tokens in `content=`.+_CSRF_META_NAMES = frozenset({"csrf-token", "csrf_token", "_csrf"})++_NONCE_VALUE_SENTINEL = "__NONCE__"++# Matches UUID v4 substrings inside an attribute value. v4 is random; v1/v3/v5+# are time- or namespace-based and can be stable business keys, so we leave+# them alone to avoid collapsing genuinely different entities into one key.+_UUID_V4_IN_VALUE_RE = re.compile(+ r"[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}",+ re.IGNORECASE,+)++# Matches a random-looking hex suffix preceded by a `-`, `_`, or `:` delimiter+# inside an attribute value. Two lookaheads anchor the "random" shape:+# - ``(?=[0-9a-f]*[a-f])`` keeps purely numeric suffixes like ``order-123456``+# intact — those are typically stable business IDs.+# - ``(?=[0-9a-f]*[0-9])`` keeps hex-letter-only English words like ``facade``+# or ``decade`` intact — collapsing them would introduce false cache hits.+_TRANSIENT_HEX_SUFFIX_IN_VALUE_RE = re.compile(+ r"(?<=[-_:])(?=[0-9a-f]*[a-f])(?=[0-9a-f]*[0-9])[0-9a-f]{6,}",+ re.IGNORECASE,+)+++def _redact_transient_in_value(value: str) -> str:+ """Replace UUID-v4 and random-hex-suffix substrings within an attribute value.++ Preserves stable business IDs (``id="submit-button"``, ``id="order-123456"``,+ ``id="zone-facade"``) while collapsing rotating IDs (``id="item-3f8a9b12…"``,+ ``data-testid="btn-1a2b3c4d"``).+ """+ value = _UUID_V4_IN_VALUE_RE.sub("__UUID__", value)+ value = _TRANSIENT_HEX_SUFFIX_IN_VALUE_RE.sub("__TID__", value)+ return value+++def _canonical_url(url: str | None) -> str | None:+ """Return a canonical form of ``url`` for cache-key derivation.++ Redacts nonce query *values* (keys in ``_NONCE_PARAM_NAMES``) to+ ``_NONCE_VALUE_SENTINEL`` while keeping the param itself so presence/absence+ still differentiates cache keys, and sorts remaining pairs by lowercased key.+ Fragments are preserved because SPAs use hash routing+ (``#/orders/123`` vs ``#/orders/456``) to encode page identity; stripping+ would collapse structurally-different pages into the same key.+ Scheme and host casing are NOT normalized — URLs come from the browser so+ case variance is rare; flag if we see misses driven by it.+ Path segments are NOT normalized — URLs that embed session tokens in the+ path (``/session/abc123/docs``) will produce distinct keys per session; if+ this becomes a hit-rate concern we can extend the canonicalization.+ Never raises; on a malformed input that ``urlparse`` can't round-trip we+ return the original string so cache lookup degrades gracefully.+ """+ if url is None:+ return None+ if url == "":+ return ""+ try:+ parsed = urlparse(url)+ # Manual split so `?flag` (bare) and `?flag=` (empty value) stay+ # distinct. parse_qsl collapses both to ('flag', ''), which produced+ # false cache hits when both forms appeared for the same key.+ triples: list[tuple[str, str, bool]] = []+ for seg in parsed.query.split("&"):+ if not seg:+ continue+ if "=" in seg:+ k, _, v = seg.partition("=")+ triples.append((k, v, True))+ else:+ triples.append((seg, "", False))+ # Only redact when the nonce has a non-empty value; `?nonce=` keeps+ # its empty value so it doesn't collide with `?nonce=abc`.+ canonicalized = [+ (k, _NONCE_VALUE_SENTINEL if v and k.lower() in _NONCE_PARAM_NAMES else v, has_eq)+ for k, v, has_eq in triples+ ]+ canonicalized.sort(key=lambda p: p[0].lower())+ new_query = "&".join(f"{k}={v}" if has_eq else k for k, v, has_eq in canonicalized)+ return urlunparse(parsed._replace(query=new_query))+ except (ValueError, TypeError):+ return url+++def _canonical_element_tree(html: str | None) -> str | None:+ """Return a canonicalized HTML string for cache-key derivation.- This lets us hash the rendered prompt directly without microsecond-level- timestamp churn defeating the cache. The actual prompt sent to the LLM is- unchanged; only the key-derivation copy is normalized.+ Redacts UUID-v4 / random-hex-suffix substrings within identifier-style+ attribute values (id/for/aria-*/data-testid) and zeros CSRF-token+ <input>/<meta> contents. Stable business IDs (``id='submit-button'``,+ ``id='order-123456'``) and semantic fields (``class``, ``href``, ``src``,+ ``name``, text content, document structure) are preserved.++ Never raises. Returns the input unchanged if parsing fails."""- return _ISO_LINE_RE.sub(lambda m: m.group(1), prompt)+ if html is None:+ return None+ if html == "":+ return ""+ try:+ tree = HTMLParser(html)+ for node in tree.root.traverse(include_text=False):+ if not node.attributes:+ continue+ tag = node.tag++ # CSRF scrubbing reads `name` before the sentinel pass so it is+ # always available regardless of _SUSPECT_ATTR_NAMES membership.+ if tag == "input":+ input_name = (node.attributes.get("name", "") or "").lower()+ if input_name in _CSRF_INPUT_NAMES:+ node.attrs["value"] = ""+ elif tag == "meta":+ meta_name = (node.attributes.get("name", "") or "").lower()+ if meta_name in _CSRF_META_NAMES:+ node.attrs["content"] = ""++ # Pattern-based value redaction inside suspect attributes: UUIDs+ # and random hex suffixes collapse; stable business IDs survive.+ for attr_name in list(node.attributes.keys()):+ if attr_name.lower() in _SUSPECT_ATTR_NAMES:+ current_val = node.attributes.get(attr_name) or ""+ node.attrs[attr_name] = _redact_transient_in_value(current_val)++ # selectolax's html property returns the full serialized tree+ return tree.html or html+ except Exception:+ # WARNING rather than DEBUG so a transient parser regression surfaces+ # in Datadog instead of silently degrading cache hits.+ LOG.warning("canonical_element_tree_failed", exc_info=True)+ return htmldef _normalize(value: Any) -> str:@@ -141,6 +332,7 @@ def _normalize(value: Any) -> str:def compute_cache_key(*,+ call_path: str,element_tree: str | None = None,extracted_text: str | None = None,current_url: str | None = None,@@ -151,57 +343,41 @@ def compute_cache_key(previous_extracted_information: Any = None,llm_key: str | None = None,local_datetime: str | None = None,- rendered_prompt: str | None = None,) -> str:"""Return a stable sha256 hex digest for the inputs that affect extraction output.- Preferred usage: pass `rendered_prompt` (the fully-rendered extract-information- prompt string) together with `llm_key` and `local_datetime`. This captures- any prompt transformations (economy element tree, 2/3 truncation) applied- inside `load_prompt_with_elements`, so the cache key matches exactly what- goes to the LLM.-- Legacy usage: the loose-field parameters (element_tree, extracted_text, …)- are retained for tests and backward compatibility. They are ignored when- `rendered_prompt` is provided.-- Note: screenshots are passed to the LLM as multimodal input but are NOT- included in the cache key. For the target loop pattern (same URL, same DOM- on each re-visit), screenshots are expected to be visually identical when- the element tree and extracted text match. If this assumption proves wrong- (e.g. dynamic overlays), we can add a SHA-256 of the screenshot bytes as- a follow-up.+ ``call_path`` is a required discriminator so different callsites (agent,+ handler, script) never collide even when their other inputs happen to+ hash identically — e.g. when ``ai_extract`` runs on a goal with no+ ``{{ var }}`` substitutions and no nav context, all other parts can match+ ``extract_information_for_navigation_goal``'s inputs and produce the same+ SHA otherwise."""def _s(v: str | None) -> str:"""Map None to a sentinel so None and '' hash differently."""return _NULL_SENTINEL if v is None else v- # Truncate local_datetime to date-only (YYYY-MM-DD) so the key is stable- # within a single run but changes across midnight for date-relative goals.date_only = local_datetime[:10] if local_datetime and len(local_datetime) >= 10 else _s(local_datetime)- if rendered_prompt is not None:- # Normalize the local_datetime line inside the rendered prompt so that- # two calls on the same day produce the same hash. The template emits- # the full ISO timestamp on its own line; strip sub-date precision- # before hashing.- normalized_prompt = _normalize_prompt_datetime(rendered_prompt)- parts = [normalized_prompt, _s(llm_key)]- else:- parts = [- _s(element_tree),- _s(extracted_text),- _s(current_url),- _s(data_extraction_goal),- _normalize(extracted_information_schema),- _normalize(navigation_payload),- _normalize(error_code_mapping),- _normalize(previous_extracted_information),- _s(llm_key),- date_only,- ]- # Use a delimiter that cannot appear inside any part naturally.+ canonical_url = _canonical_url(current_url)+ canonical_element_tree = _canonical_element_tree(element_tree)+ canonical_extracted_text = _normalize_datetime_lines(extracted_text) if extracted_text is not None else None+ canonical_goal = _normalize_datetime_lines(data_extraction_goal) if data_extraction_goal is not None else None++ parts = [+ call_path,+ _s(canonical_element_tree),+ _s(canonical_extracted_text),+ _s(canonical_url),+ _s(canonical_goal),+ _normalize(extracted_information_schema),+ _normalize(navigation_payload),+ _normalize(error_code_mapping),+ _normalize(previous_extracted_information),+ _s(llm_key),+ date_only,+ ]joined = "\x1f".join(parts).encode("utf-8", errors="replace")return hashlib.sha256(joined).hexdigest()@@ -282,7 +458,11 @@ def _maybe_log_hit_rate() -> None:def store(workflow_run_id: str | None, cache_key: str, result: Any) -> None:- """Store an extraction result for later reuse within the same workflow run."""+ """Store an extraction result for later reuse within the same workflow run.++ No size bound today — extraction results are typically small JSON. Revisit+ when the v4 Redis transition lands and introduces a per-entry byte cap.+ """if not workflow_run_id:returnif workflow_run_id in _CACHE:diff --git a/skyvern/utils/prompt_engine.py b/skyvern/utils/prompt_engine.pyindex c2d29b7f8..209cff7ce 100644--- a/skyvern/utils/prompt_engine.py+++ b/skyvern/utils/prompt_engine.py@@ -53,13 +53,20 @@ CEILING_FALLBACK_KEYS_BY_TEMPLATE: dict[str, list[str]] = {}-def load_prompt_with_elements(+def load_prompt_with_elements_tracked(element_tree_builder: ElementTreeBuilder,prompt_engine: PromptEngine,template_name: str,html_need_skyvern_attrs: bool = True,**kwargs: Any,-) -> str:+) -> tuple[str, dict[str, Any]]:+ """Same as load_prompt_with_elements but also returns post-ceiling kwargs.++ The returned kwargs dict reflects every fallback key that was set to None+ to bring the prompt under the hard ceiling. Callers that hash prompt+ inputs for caching should use these values instead of the pre-drop kwargs+ so two requests that render to the same final prompt share a cache key.+ """elements = element_tree_builder.build_element_tree(html_need_skyvern_attrs=html_need_skyvern_attrs)prompt = prompt_engine.load_prompt(template_name,@@ -97,7 +104,7 @@ def load_prompt_with_elements(max_tokens=DEFAULT_MAX_TOKENS,)- return enforce_prompt_ceiling(+ return enforce_prompt_ceiling_tracked(prompt,prompt_engine=prompt_engine,template_name=template_name,@@ -106,25 +113,42 @@ def load_prompt_with_elements()-def enforce_prompt_ceiling(+def load_prompt_with_elements(+ element_tree_builder: ElementTreeBuilder,+ prompt_engine: PromptEngine,+ template_name: str,+ html_need_skyvern_attrs: bool = True,+ **kwargs: Any,+) -> str:+ prompt, _ = load_prompt_with_elements_tracked(+ element_tree_builder=element_tree_builder,+ prompt_engine=prompt_engine,+ template_name=template_name,+ html_need_skyvern_attrs=html_need_skyvern_attrs,+ **kwargs,+ )+ return prompt+++def enforce_prompt_ceiling_tracked(prompt: str,*,prompt_engine: PromptEngine,template_name: str,kwargs: dict[str, Any],elements: Any | None = None,-) -> str:- """Drop fallback-chain keys in priority order until the prompt fits.+) -> tuple[str, dict[str, Any]]:+ """Same as enforce_prompt_ceiling but also returns post-drop kwargs.- Use this at any call site that builds a prompt via prompt_engine.load_prompt- directly, so the 180k hard ceiling is enforced regardless of whether the- caller went through load_prompt_with_elements.+ Callers that derive a cache key from the prompt inputs should hash the+ returned kwargs so requests that render to the same final LLM prompt+ (because dropped fields differed but were both dropped) share a key."""+ working_kwargs = dict(kwargs)final_token_count = count_tokens(prompt)if final_token_count <= PROMPT_HARD_CEILING_TOKENS:- return prompt+ return prompt, working_kwargsfallback_keys = CEILING_FALLBACK_KEYS_BY_TEMPLATE.get(template_name, [])- working_kwargs = dict(kwargs)for drop_key in fallback_keys:if working_kwargs.get(drop_key) is None:continue@@ -142,11 +166,35 @@ def enforce_prompt_ceiling(prompt = prompt_engine.load_prompt(template_name, elements=elements, **working_kwargs)final_token_count = count_tokens(prompt)if final_token_count <= PROMPT_HARD_CEILING_TOKENS:- return prompt+ return prompt, working_kwargsLOG.error("Prompt still exceeds hard ceiling after all fallback drops",template_name=template_name,final_token_count=final_token_count,hard_ceiling=PROMPT_HARD_CEILING_TOKENS,)+ return prompt, working_kwargs+++def enforce_prompt_ceiling(+ prompt: str,+ *,+ prompt_engine: PromptEngine,+ template_name: str,+ kwargs: dict[str, Any],+ elements: Any | None = None,+) -> str:+ """Drop fallback-chain keys in priority order until the prompt fits.++ Use this at any call site that builds a prompt via prompt_engine.load_prompt+ directly, so the 180k hard ceiling is enforced regardless of whether the+ caller went through load_prompt_with_elements.+ """+ prompt, _ = enforce_prompt_ceiling_tracked(+ prompt,+ prompt_engine=prompt_engine,+ template_name=template_name,+ kwargs=kwargs,+ elements=elements,+ )return promptdiff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex f62c124d4..01d0e51bc 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -83,6 +83,7 @@ from skyvern.utils.prompt_engine import (CheckDateFormatResponse,CheckPhoneNumberFormatResponse,load_prompt_with_elements,+ load_prompt_with_elements_tracked,)from skyvern.utils.prompt_truncation import truncate_extraction_schema, truncate_previous_extracted_informationfrom skyvern.webeye.actions import actions, handler_utils@@ -4274,11 +4275,18 @@ async def extract_information_for_navigation_goal(previous_info_capped = truncate_previous_extracted_information(task.extracted_information)capped_schema = truncate_extraction_schema(task.extracted_information_schema)+ # Normalize error_code_mapping to the exact string the prompt will render+ # (None when falsy). Hashing this value below — instead of the raw dict —+ # means None and {} collapse to one key since both drop the prompt block.+ error_code_mapping_str = json.dumps(task.error_code_mapping) if task.error_code_mapping else None# Render the prompt FIRST so the cache key hashes the exact string that# will be sent to the LLM (captures economy-tree swaps and 2/3 truncation- # inside load_prompt_with_elements).- extract_information_prompt = load_prompt_with_elements(+ # inside load_prompt_with_elements). Use the _tracked variant so the cache+ # key below can hash the post-ceiling values — when the prompt exceeds the+ # hard ceiling, `enforce_prompt_ceiling` drops fields to None, and two+ # requests that render to the same final LLM prompt must share a key.+ extract_information_prompt, post_ceiling_kwargs = load_prompt_with_elements_tracked(element_tree_builder=scraped_page_refreshed,prompt_engine=prompt_engine,template_name="extract-information",@@ -4290,7 +4298,7 @@ async def extract_information_for_navigation_goal(extracted_information_schema=capped_schema,current_url=scraped_page_refreshed.url,extracted_text=extracted_text_for_prompt,- error_code_mapping_str=(json.dumps(task.error_code_mapping) if task.error_code_mapping else None),+ error_code_mapping_str=error_code_mapping_str,local_datetime=local_datetime_str,)@@ -4301,9 +4309,32 @@ async def extract_information_for_navigation_goal(cache_key: str | None = Nonelookup_result: extraction_cache.LookupResult | None = Nonetry:+ # Use the variant of the element tree that load_prompt_with_elements+ # actually rendered (could be economy or 2/3-truncated under token+ # pressure). Falls back to a fresh HTML build when the prior build+ # used fmt=JSON (field is None in that case). The fallback call+ # mutates `last_used_element_tree{_html}` on scraped_page_refreshed;+ # this is intentional — nothing downstream reads those fields after+ # the cache key is computed.+ # Hash the post-ceiling values for fields that enforce_prompt_ceiling+ # may drop (previous_extracted_information / extracted_information_schema /+ # extracted_text). When those fields are dropped, two requests that+ # differ only in the dropped values render identical final prompts and+ # must share a cache key. `extracted_text` also respects+ # include_extracted_text (None when disabled).cache_key = extraction_cache.compute_cache_key(- rendered_prompt=extract_information_prompt,+ call_path="handler",+ element_tree=scraped_page_refreshed.last_used_element_tree_html+ or scraped_page_refreshed.build_element_tree(html_need_skyvern_attrs=False),+ extracted_text=post_ceiling_kwargs["extracted_text"],+ current_url=scraped_page_refreshed.url,+ data_extraction_goal=task.data_extraction_goal,+ extracted_information_schema=post_ceiling_kwargs["extracted_information_schema"],+ navigation_payload=task.navigation_payload,+ error_code_mapping=error_code_mapping_str,+ previous_extracted_information=post_ceiling_kwargs["previous_extracted_information"],llm_key=llm_key_override,+ local_datetime=local_datetime_str,)lookup_result = extraction_cache.lookup(task.workflow_run_id, cache_key)except Exception:@@ -4316,13 +4347,13 @@ async def extract_information_for_navigation_goal(cache_scope=extraction_cache.SCOPE_RUN,cache_age_seconds=None,fallback_reason=extraction_cache.FALLBACK_LOOKUP_ERROR,- cache_path="agent",+ cache_path="handler",exc_info=True,)# Preserve cache_key so the downstream store() can still warm the cache# for subsequent identical calls even when lookup() fails transiently.- if lookup_result is not None and lookup_result.hit:+ if lookup_result is not None and lookup_result.hit and isinstance(lookup_result.value, (dict, list, str)):LOG.info("extract_information cache hit — skipping LLM call",task_id=task.task_id,@@ -4332,7 +4363,7 @@ async def extract_information_for_navigation_goal(cache_scope=lookup_result.scope,cache_age_seconds=lookup_result.age_seconds,fallback_reason=None,- cache_path="agent",+ cache_path="handler",)# Fire-and-forget shadow sampling on sampled hits. Flag lookup happens# inside the background task so the cache-hit return is not blocked@@ -4390,7 +4421,16 @@ async def extract_information_for_navigation_goal(schema=shadow_schema,)return ScrapeResult(scraped_data=lookup_result.value)- if lookup_result is not None:+ if lookup_result is not None and lookup_result.hit:+ LOG.warning(+ "extract_information cache hit returned non-cacheable value type; falling through to LLM",+ task_id=task.task_id,+ workflow_run_id=task.workflow_run_id,+ cache_key=cache_key,+ value_type=type(lookup_result.value).__name__,+ cache_path="handler",+ )+ elif lookup_result is not None:LOG.info("extract_information cache miss",task_id=task.task_id,@@ -4400,7 +4440,7 @@ async def extract_information_for_navigation_goal(cache_scope=lookup_result.scope,cache_age_seconds=None,fallback_reason=lookup_result.fallback_reason,- cache_path="agent",+ cache_path="handler",)# Use the appropriate LLM handler based on the feature flag@@ -4423,8 +4463,11 @@ async def extract_information_for_navigation_goal()# Cache the post-validation result so cache hits return the same shape as- # a fresh LLM call (schema-validated with missing fields filled).- if cache_key is not None and json_response is not None:+ # a fresh LLM call (schema-validated with missing fields filled). Accept+ # dict / list / str — the `extract-information` prompt uses+ # `force_dict=False`, so root `type: array` or scalar schemas are valid+ # return shapes (matches ``ScrapeResult.scraped_data``).+ if cache_key is not None and isinstance(json_response, (dict, list, str)):try:extraction_cache.store(task.workflow_run_id, cache_key, json_response)except Exception:diff --git a/skyvern/webeye/scraper/scraped_page.py b/skyvern/webeye/scraper/scraped_page.pyindex 4036d32e0..e33b1897a 100644--- a/skyvern/webeye/scraper/scraped_page.py+++ b/skyvern/webeye/scraper/scraped_page.py@@ -153,6 +153,11 @@ class ScrapedPage(BaseModel, ElementTreeBuilder):element_tree_trimmed: list[dict]economy_element_tree: list[dict] | None = Nonelast_used_element_tree: list[dict] | None = None+ # Last HTML variant built for the LLM (captures economy / truncation).+ # None when the last build used fmt=JSON or no build has run yet. The+ # extraction cache reads this to hash the exact HTML the LLM saw; JSON+ # callers fall back to a fresh HTML rebuild at the cache callsite.+ last_used_element_tree_html: str | None = Nonescreenshots: list[bytes] = []url: str = ""html: str = ""@@ -227,15 +232,22 @@ class ScrapedPage(BaseModel, ElementTreeBuilder):def build_element_tree(self, fmt: ElementTreeFormat = ElementTreeFormat.HTML, html_need_skyvern_attrs: bool = True) -> str:+ # Side effect: writes self.last_used_element_tree (always) and+ # self.last_used_element_tree_html (HTML → string, JSON → None). The+ # extraction cache reads the latter to hash the exact variant sent to+ # the LLM. Callers that don't want the write must snapshot first.self.last_used_element_tree = self.element_tree_trimmedif fmt == ElementTreeFormat.JSON:+ self.last_used_element_tree_html = Nonereturn json.dumps(self.element_tree_trimmed)if fmt == ElementTreeFormat.HTML:- return "".join(+ result = "".join(json_to_html(element, need_skyvern_attrs=html_need_skyvern_attrs)for element in self.element_tree_trimmed)+ self.last_used_element_tree_html = result+ return resultraise UnknownElementTreeFormat(fmt=fmt)@@ -263,6 +275,7 @@ class ScrapedPage(BaseModel, ElementTreeBuilder):self.last_used_element_tree = self.economy_element_treeif fmt == ElementTreeFormat.JSON:+ self.last_used_element_tree_html = Noneelement_str = json.dumps(self.economy_element_tree)return element_str[: int(len(element_str) * percent_to_keep)]@@ -271,7 +284,9 @@ class ScrapedPage(BaseModel, ElementTreeBuilder):json_to_html(element, need_skyvern_attrs=html_need_skyvern_attrs)for element in self.economy_element_tree)- return element_str[: int(len(element_str) * percent_to_keep)]+ result = element_str[: int(len(element_str) * percent_to_keep)]+ self.last_used_element_tree_html = result+ return resultraise UnknownElementTreeFormat(fmt=fmt)@@ -315,6 +330,9 @@ class ScrapedPage(BaseModel, ElementTreeBuilder):self.html = refreshed_page.htmlself.extracted_text = refreshed_page.extracted_textself.url = refreshed_page.url+ # Defensive: callers today rebuild before reading, but future direct+ # reads of this field post-refresh would otherwise see stale HTML.+ self.last_used_element_tree_html = Nonereturn selfasync def generate_scraped_page(diff --git a/tests/unit/test_extract_information_previous_info_cap.py b/tests/unit/test_extract_information_previous_info_cap.pyindex cde0d66b2..5766a250f 100644--- a/tests/unit/test_extract_information_previous_info_cap.py+++ b/tests/unit/test_extract_information_previous_info_cap.py@@ -27,15 +27,21 @@ def _capture_handler_kwargs(monkeypatch, previous_extracted_information):captured: dict = {}- def fake_load_prompt_with_elements(**kwargs):- captured.update(kwargs)- return "rendered-prompt"+ def fake_load_prompt_with_elements_tracked(**kwargs):+ captured.update(+ {+ k: v+ for k, v in kwargs.items()+ if k not in {"element_tree_builder", "prompt_engine", "template_name", "html_need_skyvern_attrs"}+ }+ )+ return "rendered-prompt", dict(captured)async def fake_handler_call(**kwargs):captured["prompt"] = kwargs.get("prompt")return {}- monkeypatch.setattr(handler, "load_prompt_with_elements", fake_load_prompt_with_elements)+ monkeypatch.setattr(handler, "load_prompt_with_elements_tracked", fake_load_prompt_with_elements_tracked)monkeypatch.setattr(handler, "ensure_context", lambda: MagicMock(tz_info=None))monkeypatch.setattr(handler.service_utils, "is_cua_task", AsyncMock(return_value=False))monkeypatch.setattr(@@ -97,15 +103,21 @@ def _capture_handler_schema(monkeypatch, extracted_information_schema):captured: dict = {}- def fake_load_prompt_with_elements(**kwargs):- captured.update(kwargs)- return "rendered-prompt"+ def fake_load_prompt_with_elements_tracked(**kwargs):+ captured.update(+ {+ k: v+ for k, v in kwargs.items()+ if k not in {"element_tree_builder", "prompt_engine", "template_name", "html_need_skyvern_attrs"}+ }+ )+ return "rendered-prompt", dict(captured)async def fake_handler_call(**kwargs):captured["prompt"] = kwargs.get("prompt")return {}- monkeypatch.setattr(handler, "load_prompt_with_elements", fake_load_prompt_with_elements)+ monkeypatch.setattr(handler, "load_prompt_with_elements_tracked", fake_load_prompt_with_elements_tracked)monkeypatch.setattr(handler, "ensure_context", lambda: MagicMock(tz_info=None))monkeypatch.setattr(handler.service_utils, "is_cua_task", AsyncMock(return_value=False))monkeypatch.setattr(diff --git a/tests/unit/test_extract_information_text_optout.py b/tests/unit/test_extract_information_text_optout.pyindex 434cabad0..089d5ff66 100644--- a/tests/unit/test_extract_information_text_optout.py+++ b/tests/unit/test_extract_information_text_optout.py@@ -77,18 +77,26 @@ def _capture_extract_information_kwargs(monkeypatch, include_extracted_text: boocaptured: dict = {}- def fake_load_prompt_with_elements(**kwargs):- captured.update(kwargs)- return "rendered-prompt"+ def fake_load_prompt_with_elements_tracked(**kwargs):+ # Drop the non-kwargs args (element_tree_builder, prompt_engine, etc.)+ # so captured reflects the rendered-prompt template vars only.+ captured.update(+ {+ k: v+ for k, v in kwargs.items()+ if k not in {"element_tree_builder", "prompt_engine", "template_name", "html_need_skyvern_attrs"}+ }+ )+ return "rendered-prompt", dict(captured)async def fake_handler_call(**kwargs):captured["prompt"] = kwargs.get("prompt")return {}# The handler calls compute_cache_key (may raise), LOG, LLMAPIHandlerFactory,- # service_utils.is_cua_task. Monkey-patch just enough to reach load_prompt_with_elements- # and the handler call.- monkeypatch.setattr(handler, "load_prompt_with_elements", fake_load_prompt_with_elements)+ # service_utils.is_cua_task. Monkey-patch just enough to reach the prompt+ # builder and the handler call.+ monkeypatch.setattr(handler, "load_prompt_with_elements_tracked", fake_load_prompt_with_elements_tracked)monkeypatch.setattr(handler, "ensure_context", lambda: MagicMock(tz_info=None))monkeypatch.setattr(handler.service_utils, "is_cua_task", AsyncMock(return_value=False))monkeypatch.setattr(@@ -160,9 +168,15 @@ def _capture_ai_extract_kwargs(monkeypatch, include_extracted_text: bool):captured: dict = {}- def fake_load_prompt_with_elements(**kwargs):- captured.update(kwargs)- return "rendered-prompt"+ def fake_load_prompt_with_elements_tracked(**kwargs):+ captured.update(+ {+ k: v+ for k, v in kwargs.items()+ if k not in {"element_tree_builder", "prompt_engine", "template_name", "html_need_skyvern_attrs"}+ }+ )+ return "rendered-prompt", dict(captured)scraped_page = MagicMock()scraped_page.url = "https://example.test"@@ -181,7 +195,7 @@ def _capture_ai_extract_kwargs(monkeypatch, include_extracted_text: bool):async def fake_handler(*, prompt, step, screenshots, prompt_name, force_dict):return {}- monkeypatch.setattr(module, "load_prompt_with_elements", fake_load_prompt_with_elements)+ monkeypatch.setattr(module, "load_prompt_with_elements_tracked", fake_load_prompt_with_elements_tracked)monkeypatch.setattr(module.app, "EXTRACTION_LLM_API_HANDLER", fake_handler)monkeypatch.setattr(module.extraction_cache, "compute_cache_key", lambda **_: None)monkeypatch.setattr(page, "_refresh_scraped_page", fake_refresh)@@ -216,9 +230,15 @@ def _capture_ai_extract_kwargs_with_schema(monkeypatch, schema):captured: dict = {}- def fake_load_prompt_with_elements(**kwargs):- captured.update(kwargs)- return "rendered-prompt"+ def fake_load_prompt_with_elements_tracked(**kwargs):+ captured.update(+ {+ k: v+ for k, v in kwargs.items()+ if k not in {"element_tree_builder", "prompt_engine", "template_name", "html_need_skyvern_attrs"}+ }+ )+ return "rendered-prompt", dict(captured)scraped_page = MagicMock()scraped_page.url = "https://example.test"@@ -237,7 +257,7 @@ def _capture_ai_extract_kwargs_with_schema(monkeypatch, schema):async def fake_handler(*, prompt, step, screenshots, prompt_name, force_dict):return {}- monkeypatch.setattr(module, "load_prompt_with_elements", fake_load_prompt_with_elements)+ monkeypatch.setattr(module, "load_prompt_with_elements_tracked", fake_load_prompt_with_elements_tracked)monkeypatch.setattr(module.app, "EXTRACTION_LLM_API_HANDLER", fake_handler)monkeypatch.setattr(module.extraction_cache, "compute_cache_key", lambda **_: None)monkeypatch.setattr(page, "_refresh_scraped_page", fake_refresh)diff --git a/tests/unit/test_extraction_cache.py b/tests/unit/test_extraction_cache.pyindex a84e9edca..d861206e8 100644--- a/tests/unit/test_extraction_cache.py+++ b/tests/unit/test_extraction_cache.py@@ -16,6 +16,7 @@ def _reset_cache() -> None:def _key(**overrides: object) -> str:defaults: dict[str, object] = {+ "call_path": "test","element_tree": "<html><body>docs</body></html>","extracted_text": "Document list","current_url": "https://example.com/docs",@@ -195,49 +196,6 @@ def test_none_and_empty_string_produce_different_keys() -> None:assert _key(data_extraction_goal=None) != _key(data_extraction_goal="")-def test_rendered_prompt_path_identical_prompts_hit() -> None:- """Two calls with the same rendered prompt should produce the same key."""- prompt = "Extract docs.\nCurrent datetime, ISO format:\n2026-04-10T08:00:00\nDone."- key1 = extraction_cache.compute_cache_key(rendered_prompt=prompt, llm_key="gpt-4o")- key2 = extraction_cache.compute_cache_key(rendered_prompt=prompt, llm_key="gpt-4o")- assert key1 == key2---def test_rendered_prompt_path_different_prompts_miss() -> None:- """Different rendered prompts must produce different keys."""- p1 = "Extract docs from list A\n2026-04-10T08:00:00"- p2 = "Extract docs from list B\n2026-04-10T08:00:00"- assert extraction_cache.compute_cache_key(rendered_prompt=p1) != extraction_cache.compute_cache_key(- rendered_prompt=p2- )---def test_rendered_prompt_normalizes_timestamp_line() -> None:- """Same-day prompts with different ISO timestamps should hash identically."""- p1 = "Header\n2026-04-10T08:30:15.123456\nFooter"- p2 = "Header\n2026-04-10T23:59:59.999999\nFooter"- assert extraction_cache.compute_cache_key(rendered_prompt=p1) == extraction_cache.compute_cache_key(- rendered_prompt=p2- )---def test_rendered_prompt_midnight_crossing_produces_miss() -> None:- """Different dates in the rendered prompt timestamp must produce different keys."""- p1 = "Header\n2026-04-10T23:59:59\nFooter"- p2 = "Header\n2026-04-11T00:00:01\nFooter"- assert extraction_cache.compute_cache_key(rendered_prompt=p1) != extraction_cache.compute_cache_key(- rendered_prompt=p2- )---def test_rendered_prompt_llm_key_affects_hash() -> None:- """Same rendered prompt with different llm_key should produce different keys."""- prompt = "Extract docs\n2026-04-10T08:00:00"- k1 = extraction_cache.compute_cache_key(rendered_prompt=prompt, llm_key="gpt-4o")- k2 = extraction_cache.compute_cache_key(rendered_prompt=prompt, llm_key="claude-sonnet-4-6")- assert k1 != k2--def test_lookup_refreshes_lru_position() -> None:"""A cache hit should refresh the run's LRU position, preventing eviction."""max_runs = extraction_cache._MAX_WORKFLOW_RUNS@@ -262,3 +220,261 @@ def test_lookup_refreshes_lru_position() -> None:assert oldest_after.hit is Trueassert oldest_after.value == {"v": 0}assert extraction_cache.lookup("wfr_1", key).hit is False # evicted+++# ---------------------------------------------------------------------------+# _canonical_url primitive+# ---------------------------------------------------------------------------+++class TestCanonicalUrl:+ def test_returns_none_for_none(self) -> None:+ assert extraction_cache._canonical_url(None) is None++ def test_returns_empty_for_empty(self) -> None:+ assert extraction_cache._canonical_url("") == ""++ def test_leaves_simple_url_unchanged(self) -> None:+ assert extraction_cache._canonical_url("https://example.com/docs") == "https://example.com/docs"++ def test_sorts_query_params_by_key(self) -> None:+ assert extraction_cache._canonical_url("https://x/y?b=2&a=1") == "https://x/y?a=1&b=2"++ def test_redacts_nonce_param_values_and_preserves_keys(self) -> None:+ """Nonce values are replaced with a sentinel but keys are preserved so+ presence/absence of the param still differentiates cache keys.+ """+ out = extraction_cache._canonical_url("https://x/y?a=1&_csrf=abc&b=2")+ assert "_csrf=__NONCE__" in out+ assert "a=1" in out and "b=2" in out++ def test_same_nonce_key_different_values_produce_same_canonical(self) -> None:+ """Two URLs that differ only in a nonce value must hash identically."""+ a = extraction_cache._canonical_url("https://x/y?_csrf=abc")+ b = extraction_cache._canonical_url("https://x/y?_csrf=xyz")+ assert a == b++ def test_nonce_key_absent_vs_present_produce_different_canonical(self) -> None:+ """A URL with the nonce key absent must canonicalize differently than one with the key present."""+ with_nonce = extraction_cache._canonical_url("https://x/y?_csrf=abc")+ without = extraction_cache._canonical_url("https://x/y")+ assert with_nonce != without++ def test_empty_nonce_value_does_not_collide_with_populated_value(self) -> None:+ """`?_csrf=` (empty) must canonicalize differently than `?_csrf=abc`."""+ empty = extraction_cache._canonical_url("https://x/y?_csrf=")+ populated = extraction_cache._canonical_url("https://x/y?_csrf=abc")+ assert empty != populated+ assert "_csrf=__NONCE__" not in empty++ def test_bare_flag_does_not_collide_with_empty_value(self) -> None:+ """`?flag` (no `=`) must canonicalize differently than `?flag=`."""+ bare = extraction_cache._canonical_url("https://x/y?flag")+ empty = extraction_cache._canonical_url("https://x/y?flag=")+ assert bare != empty+ assert bare.endswith("?flag")+ assert empty.endswith("?flag=")++ def test_preserves_fragment(self) -> None:+ """SPAs with hash routing encode page identity in the fragment (e.g. `#/orders/123` vs+ `#/orders/456`); stripping the fragment would collapse structurally-different pages."""+ assert extraction_cache._canonical_url("https://x/y?a=1#section") == "https://x/y?a=1#section"++ def test_different_fragments_produce_different_canonical(self) -> None:+ """Hash-routed SPA URLs must canonicalize distinctly when the fragment differs."""+ a = extraction_cache._canonical_url("https://x/y#/orders/123")+ b = extraction_cache._canonical_url("https://x/y#/orders/456")+ assert a != b++ def test_preserves_duplicate_keys_in_order(self) -> None:+ # Repeated keys can be semantically ordered (first-wins handlers,+ # ordered multi-sort). Python's stable sort preserves insertion order+ # within the same key.+ url = "https://x/y?sort=price&sort=rating"+ assert extraction_cache._canonical_url(url) == "https://x/y?sort=price&sort=rating"++ def test_trailing_punctuation_is_not_stripped(self) -> None:+ # _canonical_url operates on pre-parsed URL strings, not on URLs+ # embedded in prose. Callers pass `current_url` directly.+ assert extraction_cache._canonical_url("https://x/y.") == "https://x/y."++ def test_malformed_url_returns_input_unchanged(self) -> None:+ # Never raise — cache lookup must degrade gracefully.+ assert extraction_cache._canonical_url("not a url at all") == "not a url at all"++ def test_case_insensitive_nonce_match_redacts_value(self) -> None:+ """Uppercase nonce keys are still matched; the value is redacted, the key preserved."""+ out = extraction_cache._canonical_url("https://x/y?CSRF=abc&a=1")+ assert "CSRF=__NONCE__" in out+ assert "a=1" in out+++# ---------------------------------------------------------------------------+# _canonical_element_tree primitive+# ---------------------------------------------------------------------------+++class TestCanonicalElementTree:+ def test_returns_none_for_none(self) -> None:+ assert extraction_cache._canonical_element_tree(None) is None++ def test_returns_empty_for_empty(self) -> None:+ assert extraction_cache._canonical_element_tree("") == ""++ def test_scrubs_uuid_in_id_attribute(self) -> None:+ h1 = '<div id="3f8a9b12-1234-4678-9abc-def012345678">x</div>'+ h2 = '<div id="fedcba98-8765-4321-abcd-123456789abc">x</div>'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_scrubs_random_hex_suffix_in_id_attribute(self) -> None:+ h1 = '<div id="row-abc123def">x</div>'+ h2 = '<div id="row-fedcba987">x</div>'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_scrubs_data_testid(self) -> None:+ h1 = '<button data-testid="btn-1a2b3c4d">go</button>'+ h2 = '<button data-testid="btn-5e6f7a8b">go</button>'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_leaves_class_and_href_untouched(self) -> None:+ # class and href carry semantic weight — they must differentiate pages.+ h1 = '<a class="btn primary" href="/docs">go</a>'+ h2 = '<a class="btn danger" href="/docs">go</a>'+ assert extraction_cache._canonical_element_tree(h1) != extraction_cache._canonical_element_tree(h2)++ def test_scrubs_csrf_input_value(self) -> None:+ h1 = '<input name="_csrf" value="abc123">'+ h2 = '<input name="_csrf" value="zyx987">'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_scrubs_csrf_meta_content(self) -> None:+ h1 = '<meta name="csrf-token" content="abc123">'+ h2 = '<meta name="csrf-token" content="zyx987">'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_canonical_element_tree_returns_string_for_valid_html(self) -> None:+ # selectolax is permissive enough that we can't reliably force its+ # parser to raise from pytest; the except-path fallback is exercised+ # indirectly by the None/empty-string guards at the top of the function.+ assert extraction_cache._canonical_element_tree("<div>ok</div>") is not None++ def test_preserves_text_content(self) -> None:+ out = extraction_cache._canonical_element_tree('<div id="x-abc123def">hello world</div>')+ assert "hello world" in out++ def test_different_text_produces_different_output(self) -> None:+ out1 = extraction_cache._canonical_element_tree("<div>alpha</div>")+ out2 = extraction_cache._canonical_element_tree("<div>beta</div>")+ assert out1 != out2++ def test_scrubs_csrf_input_case_insensitive(self) -> None:+ """CSRF <input name=...> match must be case-insensitive, matching prior regex behavior."""+ h1 = '<input name="CSRF_TOKEN" value="abc123">'+ h2 = '<input name="CSRF_TOKEN" value="zyx987">'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_scrubs_csrf_meta_case_insensitive(self) -> None:+ """CSRF <meta name=...> match must be case-insensitive, matching prior regex behavior."""+ h1 = '<meta name="CSRF-TOKEN" content="abc123">'+ h2 = '<meta name="CSRF-TOKEN" content="zyx987">'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)++ def test_preserves_semantic_input_name_values(self) -> None:+ """<input name=...> values carry field-name semantics (not transient IDs).+ Two forms with different input names must NOT collapse to the same canonical.+ """+ h1 = '<form><input name="company_name" type="text"><button>Go</button></form>'+ h2 = '<form><input name="contact_phone" type="text"><button>Go</button></form>'+ assert extraction_cache._canonical_element_tree(h1) != extraction_cache._canonical_element_tree(h2)++ def test_preserves_stable_business_ids_in_suspect_attrs(self) -> None:+ """Semantic identifiers without transient patterns must survive canonicalization.++ Only UUIDs and random-looking hex suffixes are redacted inside suspect+ attributes; stable business IDs like id='submit-button' must differentiate.+ """+ h1 = '<button id="submit-button">go</button>'+ h2 = '<button id="cancel-button">go</button>'+ assert extraction_cache._canonical_element_tree(h1) != extraction_cache._canonical_element_tree(h2)++ def test_preserves_numeric_only_suffix_in_suspect_attrs(self) -> None:+ """Purely numeric suffixes (e.g. 'order-123456') are stable business IDs; don't collapse them."""+ h1 = '<div id="order-123456">go</div>'+ h2 = '<div id="order-987654">go</div>'+ assert extraction_cache._canonical_element_tree(h1) != extraction_cache._canonical_element_tree(h2)++ def test_preserves_hex_letter_only_english_words_in_suspect_attrs(self) -> None:+ """Hex-letter-only strings like 'facade' or 'decade' are English words, not random IDs."""+ h1 = '<div id="zone-facade">go</div>'+ h2 = '<div id="zone-decade">go</div>'+ assert extraction_cache._canonical_element_tree(h1) != extraction_cache._canonical_element_tree(h2)++ def test_preserves_non_v4_uuid_in_suspect_attrs(self) -> None:+ """v1/v3/v5 UUIDs are deterministic / namespace-based and can be stable business keys."""+ # v1 UUID (version nibble = 1) — must NOT be collapsed+ h1 = '<div id="3f8a9b12-1234-1678-9abc-def012345678">x</div>'+ h2 = '<div id="fedcba98-8765-1321-abcd-123456789abc">x</div>'+ assert extraction_cache._canonical_element_tree(h1) != extraction_cache._canonical_element_tree(h2)++ def test_scrubs_attr_case_insensitively(self) -> None:+ """Even if a parser surfaces an uppercase attribute name, it must still match the suspect set."""+ # selectolax 0.3.34 normalizes to lowercase, but we want robustness if that ever changes.+ # Exercise via direct set membership: this test pins the lower() call.+ h1 = '<div ID="3f8a9b12-1234-4678-9abc-def012345678">x</div>'+ h2 = '<div ID="fedcba98-8765-4321-abcd-123456789abc">x</div>'+ assert extraction_cache._canonical_element_tree(h1) == extraction_cache._canonical_element_tree(h2)+++# ---------------------------------------------------------------------------+# compute_cache_key — structured-path canonicalization integration+# ---------------------------------------------------------------------------+++def test_key_stable_across_nonce_params_in_url() -> None:+ """current_url with different nonce param values should still hit."""+ assert _key(current_url="https://x/y?a=1&_csrf=abc") == _key(current_url="https://x/y?a=1&_csrf=xyz")+++def test_key_stable_across_uuid_in_element_tree() -> None:+ """element_tree with different UUIDs in id= attributes should still hit."""+ h1 = '<div id="3f8a9b12-1234-4678-9abc-def012345678">doc</div>'+ h2 = '<div id="fedcba98-8765-4321-abcd-123456789abc">doc</div>'+ assert _key(element_tree=h1) == _key(element_tree=h2)+++def test_key_stable_across_csrf_token_in_element_tree() -> None:+ """element_tree with different CSRF tokens should still hit."""+ h1 = '<input name="_csrf" value="abc123">'+ h2 = '<input name="_csrf" value="zyx987">'+ assert _key(element_tree=h1) == _key(element_tree=h2)+++def test_key_stable_across_iso_timestamps_in_extracted_text() -> None:+ """extracted_text with same-day ISO timestamps should still hit."""+ t1 = "Report\n2026-04-10T08:30:15.123456\nEnd"+ t2 = "Report\n2026-04-10T23:59:59.999999\nEnd"+ assert _key(extracted_text=t1) == _key(extracted_text=t2)+++def test_key_changes_across_different_dates_in_extracted_text() -> None:+ """Midnight crossing in extracted_text must produce a different key."""+ t1 = "Report\n2026-04-10T23:59:59\nEnd"+ t2 = "Report\n2026-04-11T00:00:01\nEnd"+ assert _key(extracted_text=t1) != _key(extracted_text=t2)+++def test_call_path_discriminator_isolates_otherwise_identical_keys() -> None:+ """Different call_paths must produce different keys even when every other+ input is identical — guards against silent cross-path cache hits (e.g.+ script path replaying an agent-path extraction result)."""+ assert _key(call_path="handler") != _key(call_path="script")+ assert _key(call_path="handler") != _key(call_path="agent")+ assert _key(call_path="script") != _key(call_path="agent")+++def test_key_stable_across_iso_timestamps_in_data_extraction_goal() -> None:+ """Same-day ISO timestamps in the goal (e.g. 'extract updated after <ts>')+ must not cause per-second key churn."""+ g1 = "Extract records updated after\n2026-04-10T08:30:15.123456\nonward"+ g2 = "Extract records updated after\n2026-04-10T23:59:59.999999\nonward"+ assert _key(data_extraction_goal=g1) == _key(data_extraction_goal=g2)diff --git a/tests/unit/test_load_prompt_with_elements_ceiling.py b/tests/unit/test_load_prompt_with_elements_ceiling.pyindex c4769ab25..20c9abcde 100644--- a/tests/unit/test_load_prompt_with_elements_ceiling.py+++ b/tests/unit/test_load_prompt_with_elements_ceiling.py@@ -107,3 +107,78 @@ def test_load_prompt_with_elements_respects_ceiling_for_small_prompts() -> None:assert "small blob" in renderedassert count_tokens(rendered) <= PROMPT_HARD_CEILING_TOKENS+++def test_enforce_prompt_ceiling_tracked_reports_dropped_keys() -> None:+ from skyvern.forge.prompts import prompt_engine as engine_module+ from skyvern.utils.prompt_engine import PROMPT_HARD_CEILING_TOKENS, enforce_prompt_ceiling_tracked+ from skyvern.utils.token_counter import count_tokens++ giant_schema = {"type": "object", "_blob": "lorem " * 300_000}+ kwargs = {+ "data_extraction_goal": "Extract",+ "data_extraction_schema": giant_schema,+ "current_url": "https://example.test",+ "local_datetime": "2026-04-14T12:00:00",+ }+ rendered = engine_module.load_prompt("data-extraction-summary", **kwargs)+ assert count_tokens(rendered) > PROMPT_HARD_CEILING_TOKENS++ rendered, post_kwargs = enforce_prompt_ceiling_tracked(+ rendered,+ prompt_engine=engine_module,+ template_name="data-extraction-summary",+ kwargs=kwargs,+ )+ assert count_tokens(rendered) <= PROMPT_HARD_CEILING_TOKENS+ assert post_kwargs["data_extraction_schema"] is None+ # kwargs dict is not mutated in place+ assert kwargs["data_extraction_schema"] is giant_schema+++def test_enforce_prompt_ceiling_tracked_noop_under_ceiling() -> None:+ from skyvern.forge.prompts import prompt_engine as engine_module+ from skyvern.utils.prompt_engine import enforce_prompt_ceiling_tracked++ kwargs = {+ "data_extraction_goal": "Extract",+ "data_extraction_schema": {"type": "object"},+ "current_url": "https://example.test",+ "local_datetime": "2026-04-14T12:00:00",+ }+ rendered = engine_module.load_prompt("data-extraction-summary", **kwargs)++ rendered_after, post_kwargs = enforce_prompt_ceiling_tracked(+ rendered,+ prompt_engine=engine_module,+ template_name="data-extraction-summary",+ kwargs=kwargs,+ )+ assert rendered_after == rendered+ assert post_kwargs["data_extraction_schema"] == {"type": "object"}+++def test_load_prompt_with_elements_tracked_reports_dropped_keys() -> None:+ from skyvern.forge.prompts import prompt_engine as engine_module+ from skyvern.utils.prompt_engine import PROMPT_HARD_CEILING_TOKENS, load_prompt_with_elements_tracked+ from skyvern.utils.token_counter import count_tokens++ oversized_prev = [{"iter": i, "marker": f"UNIQUE_BLOCK_{i}_" + ("lorem ipsum " * 200)} for i in range(3000)]++ rendered, post_kwargs = load_prompt_with_elements_tracked(+ element_tree_builder=_make_element_tree_builder(),+ prompt_engine=engine_module,+ template_name="extract-information",+ data_extraction_goal="Extract documents",+ extracted_information_schema={"type": "object"},+ current_url="https://example.test",+ extracted_text=None,+ error_code_mapping_str=None,+ navigation_payload=None,+ local_datetime="2026-04-14T12:00:00",+ previous_extracted_information=oversized_prev,+ )++ assert count_tokens(rendered) <= PROMPT_HARD_CEILING_TOKENS+ # previous_extracted_information is first in the drop chain and large enough to have been dropped+ assert post_kwargs["previous_extracted_information"] is Nonediff --git a/uv.lock b/uv.lockindex 76dd4d32c..c14a6f5bc 100644--- a/uv.lock+++ b/uv.lock@@ -14,7 +14,7 @@ resolution-markers = [][options]-exclude-newer = "2026-04-07T17:49:42.509853Z"+exclude-newer = "2026-04-07T19:07:49.173655Z"exclude-newer-span = "P7D"[manifest]@@ -5485,6 +5485,35 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/b7/46/f5af3402b579fd5e11573ce652019a67074317e18c1935cc0b4ba9b35552/secretstorage-3.5.0-py3-none-any.whl", hash = "sha256:0ce65888c0725fcb2c5bc0fdb8e5438eece02c523557ea40ce0703c266248137", size = 15554, upload-time = "2025-11-23T19:02:51.545Z" },]+[[package]]+name = "selectolax"+version = "0.3.34"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/bf/8c/8bbe1b17098b4e2a63a251361870303c37ad4c3170536277096575c24ca4/selectolax-0.3.34.tar.gz", hash = "sha256:c2cdb30b60994f1e0b74574dd408f1336d2fadd68a3ebab8ea573740dcbf17e2", size = 4706599, upload-time = "2025-08-28T23:17:44.131Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/e4/1e/146ce1f51d472677777422ce4442eff081ac54331667a6558a98f7c47e6c/selectolax-0.3.34-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:aa1abb8ca78c832808661a9ac13f7fe23fbab4b914afb5d99b7f1349cc78586a", size = 2002899, upload-time = "2025-08-28T23:16:36.774Z" },+ { url = "https://files.pythonhosted.org/packages/3b/9f/30cb6a68d2e6d75da8fa3910d1f80a9b8b7338689894d24cfddb184adeaa/selectolax-0.3.34-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:88596b9f250ce238b7830e5987780031ffd645db257f73dcd816ec93523d7c04", size = 1994898, upload-time = "2025-08-28T23:16:38.153Z" },+ { url = "https://files.pythonhosted.org/packages/79/63/b207c894c54b426ae69e08c85a5dc85c22f4d10872efd17a599f8dfb94e2/selectolax-0.3.34-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7755dfe7dd7455ca1f7194c631d409508fa26be8db94874760a27ae27d98a1c3", size = 2209542, upload-time = "2025-08-28T23:16:39.975Z" },+ { url = "https://files.pythonhosted.org/packages/3b/50/76285317fafbb80f01853c05256c584f32184371f609ecb9f0bab372a785/selectolax-0.3.34-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:579fdefcb302a7cc632a094ec69e7db24865ec475b1f34f5b2f0e9d05d8ec428", size = 2242685, upload-time = "2025-08-28T23:16:41.327Z" },+ { url = "https://files.pythonhosted.org/packages/e3/ba/56be3f947cda174f1923fc08b216b63ec5c433c41b7b02c9ac05170a2b30/selectolax-0.3.34-cp311-cp311-win32.whl", hash = "sha256:a568d2f4581d54c74ec44102d189fe255efed2d8160fda927b3d8ed41fe69178", size = 1690600, upload-time = "2025-08-28T23:16:43.071Z" },+ { url = "https://files.pythonhosted.org/packages/53/f2/d44f44fe11a28be31a3f55cff298364cd5f0baa2dca2eed20d4e4ac230f5/selectolax-0.3.34-cp311-cp311-win_amd64.whl", hash = "sha256:ff0853d10a7e8f807113a155e93cd612a41aedd009fac02992f10c388fcdd6fe", size = 1792859, upload-time = "2025-08-28T23:16:44.77Z" },+ { url = "https://files.pythonhosted.org/packages/c3/a1/d4168930f1b377befa2e3b6db1a81a600c12a800689aef047ec4407ac933/selectolax-0.3.34-cp311-cp311-win_arm64.whl", hash = "sha256:f28ebdb0f376dae6f2e80d41731076ce4891403584f15cec13593f561cfb4db0", size = 1744909, upload-time = "2025-08-28T23:16:46.526Z" },+ { url = "https://files.pythonhosted.org/packages/d8/eb/6cf9dd52e20922ea5d5be8f8c448e9501a8503ad6c8d7f70be737f76e76b/selectolax-0.3.34-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:a913371fe79d6f795fc36c0c0753aab1593e198af78dc0654a7615a6581ada14", size = 2003247, upload-time = "2025-08-28T23:16:48.206Z" },+ { url = "https://files.pythonhosted.org/packages/bc/ec/58682f69bddfe1b64e44e235e6ad2585742b4d8d805c4c0d7f2a9c0d97f5/selectolax-0.3.34-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:11b0e913897727563b2689b38a63696a21084c3c7fd93042dc8af259a4020809", size = 1995861, upload-time = "2025-08-28T23:16:49.641Z" },+ { url = "https://files.pythonhosted.org/packages/ec/68/38b8bc49d19feefd20d65661ee0ffad8537cb21bdbeaa23be3cf42f7445d/selectolax-0.3.34-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7b49f0e0af267274c39a0dc7e807c556ecf2e189f44cf95dd5d2398f36c17ce9", size = 2202808, upload-time = "2025-08-28T23:16:51.564Z" },+ { url = "https://files.pythonhosted.org/packages/2d/42/1f5e5fc7c9ac362ac259a94d2d4040e1e2c57ab2c552db7bd830884d610a/selectolax-0.3.34-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d0a5a1a8b62e204aba7030b49c5b696ee24cabb243ba757328eb54681a74340c", size = 2241858, upload-time = "2025-08-28T23:16:53.589Z" },+ { url = "https://files.pythonhosted.org/packages/90/d7/fa4d3f8fa1cfdeb36f0a4f14db362fa45b913679a15e82f3618fd62526ce/selectolax-0.3.34-cp312-cp312-win32.whl", hash = "sha256:cb49af5de5b5e99068bc7845687b40d4ded88c5e80868a7f1aa004f2380c2444", size = 1686857, upload-time = "2025-08-28T23:16:55.247Z" },+ { url = "https://files.pythonhosted.org/packages/5b/2c/f0112f0de82e7b72773f5289481fa8e31c65992d687a36048ade7e2d5703/selectolax-0.3.34-cp312-cp312-win_amd64.whl", hash = "sha256:33862576e7d9bb015b1580752316cc4b0ca2fb54347cb671fabb801c8032c67e", size = 1789407, upload-time = "2025-08-28T23:16:56.622Z" },+ { url = "https://files.pythonhosted.org/packages/fc/09/8972f0fed462739ad8a5fe1f0191f19edfc95ff7c1b09de4c940c9fe744c/selectolax-0.3.34-cp312-cp312-win_arm64.whl", hash = "sha256:8a663d762c9b6e64888489293d9b37d6727ac8f447dca221e044b61203c0f1e1", size = 1737885, upload-time = "2025-08-28T23:16:58.161Z" },+ { url = "https://files.pythonhosted.org/packages/d0/29/eeb77d1a77599023387d4d00655960dfa3d760557b42a65ef347e29b40b0/selectolax-0.3.34-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2bb74e079098d758bd3d5c77b1c66c90098de305e4084b60981e561acf52c12a", size = 2001199, upload-time = "2025-08-28T23:16:59.467Z" },+ { url = "https://files.pythonhosted.org/packages/21/80/326b9dd2901b64c3c654db9e8841ddc412b9c2af0047b7d43290bbb276be/selectolax-0.3.34-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cc39822f714e6e434ceb893e1ccff873f3f88c8db8226ba2f8a5f4a7a0e2aa29", size = 1994171, upload-time = "2025-08-28T23:17:01.206Z" },+ { url = "https://files.pythonhosted.org/packages/15/af/1265e4f9429b3c3cf098ba08cb3264d7e16990ed3029d89e9890012aae76/selectolax-0.3.34-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:181b67949ec23b4f11b6f2e426ba9904dd25c73d12c2cb22caf8fae21a363e99", size = 2196092, upload-time = "2025-08-28T23:17:02.574Z" },+ { url = "https://files.pythonhosted.org/packages/1c/41/e67100abd8b0b2a5e1d5d7fa864c31d31e9a2c0bbd08ce4e951235f13143/selectolax-0.3.34-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0b09f9d7b22bbb633966ac2019ec059caf735a5bdb4a5784bab0f4db2198fd6a", size = 2233674, upload-time = "2025-08-28T23:17:03.928Z" },+ { url = "https://files.pythonhosted.org/packages/3a/24/7ad043805c9292b4f535071c223d10aad7703b4460d68de1dce9dcf21d3f/selectolax-0.3.34-cp313-cp313-win32.whl", hash = "sha256:6e2ae8a984f82c9373e8a5ec0450f67603fde843fed73675f5187986e9e45b59", size = 1686489, upload-time = "2025-08-28T23:17:05.341Z" },+ { url = "https://files.pythonhosted.org/packages/6b/79/62666fbfcd847c0cfc2b75b496bfa8382d765e7a3d5a2c792004760a6e61/selectolax-0.3.34-cp313-cp313-win_amd64.whl", hash = "sha256:96acd5414aaf0bb8677258ff7b0f494953b2621f71be1e3d69e01743545509ec", size = 1789924, upload-time = "2025-08-28T23:17:06.708Z" },+ { url = "https://files.pythonhosted.org/packages/5d/b5/0bb579210a7de36d97c359016e77119513d3e810c61e99ade72089bc1b4d/selectolax-0.3.34-cp313-cp313-win_arm64.whl", hash = "sha256:1d309fd17ba72bb46a282154f75752ed7746de6f00e2c1eec4cd421dcdadf008", size = 1737480, upload-time = "2025-08-28T23:17:08.575Z" },+]+[[package]]name = "send2trash"version = "2.1.0"@@ -5581,6 +5610,7 @@ dependencies = [{ name = "python-multipart" },{ name = "requests-toolbelt" },{ name = "rich", extra = ["jupyter"] },+ { name = "selectolax" },{ name = "sqlalchemy", extra = ["mypy"] },{ name = "sse-starlette" },{ name = "starlette-context" },@@ -5704,6 +5734,7 @@ requires-dist = [{ name = "python-multipart", specifier = ">=0.0.22,<1" },{ name = "requests-toolbelt", specifier = ">=1.0.0,<2" },{ name = "rich", extras = ["jupyter"], specifier = ">=13.7.0,<14" },+ { name = "selectolax", specifier = ">=0.3.28,<0.4" },{ name = "sqlalchemy", extras = ["mypy"], specifier = ">=2.0.29,<3" },{ name = "sse-starlette", specifier = ">=3.0.3,<4" },{ name = "starlette-context", specifier = ">=0.3.6,<0.6" },