chore(replay): improve replay robustness with un-validated construction (#3414)

# What does this PR do?

some providers do not produce spec compliant outputs. when this happens
the replay infra will fail to construct the proper types and will return
a dict to the client. the client likely does not expect a dict.

this was discovered with tgi, which returns finish_reason="" when valid
values are "stop", "length" or "content_filter"

## Test Plan

ci
This commit is contained in:
Matthew Farrellee 2025-09-11 07:48:19 -04:00 committed by GitHub
parent 2838d5a20f
commit c2d281e01b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,7 +105,11 @@ def _deserialize_response(data: dict[str, Any]) -> Any:
return cls.model_validate(data["__data__"]) return cls.model_validate(data["__data__"])
except (ImportError, AttributeError, TypeError, ValueError) as e: except (ImportError, AttributeError, TypeError, ValueError) as e:
logger.warning(f"Failed to deserialize object of type {data['__type__']}: {e}") logger.warning(f"Failed to deserialize object of type {data['__type__']} with model_validate: {e}")
try:
return cls.model_construct(**data["__data__"])
except Exception as e:
logger.warning(f"Failed to deserialize object of type {data['__type__']} with model_construct: {e}")
return data["__data__"] return data["__data__"]
return data return data