generate_with_schema silently drops the schema when a provider raises TypeError internally
Author: sclfczCreated Sep 30, 2026Updated Sep 30, 2026
What happened
DeepEvalBaseLLM.generate_with_schema falls back to calling the model without schema whenever generate raises TypeError, on the assumption stated in its comment:
if schema is not None:
try:
return self.generate(*args, schema=schema, **kwargs)
except TypeError:
pass # this means provider doesn't accept schema kwarg
return self.generate(*args, **kwargs)A provider that does accept schema but raises TypeError inside its own code is indistinguishable from one that does not, so the caller's schema is dropped silently:
class Provider(DeepEvalBaseLLM):
def generate(self, *args, **kwargs):
if "schema" in kwargs:
raise TypeError("'NoneType' object is not subscriptable") # its own bug
return "plain text (schema dropped)"
Provider().generate_with_schema("prompt", schema=dict)
# observed calls: [{"schema"}, {}] -> returns "plain text (schema dropped)"Structured output silently degrades to unstructured text, and the provider's real error is swallowed. a_generate_with_schema has the same pattern.
Expected
Only a provider that genuinely cannot take the keyword should fall back; a provider that accepts it should have its error surface.
Version
deepeval on main, Python 3.13.
Source: confident-ai/deepeval