Skip to content

Automate browser based workflows with AI

Add invalid response to log to help us better debug it (#4142)

Suchintan2eeca1c6998b
diff --git a/skyvern/forge/sdk/api/llm/utils.py b/skyvern/forge/sdk/api/llm/utils.py
index df6f3aff8..26d7f55ec 100644
--- a/skyvern/forge/sdk/api/llm/utils.py
+++ b/skyvern/forge/sdk/api/llm/utils.py
@@ -143,6 +143,12 @@ def _coerce_response_to_dict(response: Any) -> dict[str, Any]:
if isinstance(response, dict):
return response
+ LOG.warning(
+ "Parsed LLM response is not a dict",
+ response_type=type(response).__name__,
+ response=response,
+ )
+
if isinstance(response, list):
first_dict = next((item for item in response if isinstance(item, dict)), None)
LOG.warning(
@@ -157,11 +163,6 @@ def _coerce_response_to_dict(response: Any) -> dict[str, Any]:
LOG.warning("List response contained no dict entries; returning empty dict")
raise InvalidLLMResponseType("list")
- LOG.warning(
- "Parsed LLM response is not a dict; returning empty dict",
- response_type=type(response).__name__,
- )
-
raise InvalidLLMResponseType(type(response).__name__)