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

Co-authored-by: Suchintan Singh <suchintan@skyvern.com>
This commit is contained in:
Suchintan
2025-11-28 21:58:10 -08:00
committed by GitHub
parent d6aed0d0be
commit 2eeca1c699

View File

@@ -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__)