Commit 76f86df
committed
fix: catch PydanticUserError when generating output schema
Pydantic 2.13.0 changed PydanticUserError's base class from TypeError to
RuntimeError (pydantic/pydantic#12579). _try_create_model_and_schema was
relying on `except TypeError` to catch PydanticInvalidForJsonSchema when
a return type can't be represented in JSON Schema (e.g. a Callable field).
On pydantic 2.13.0 the exception escapes and tool registration crashes
instead of falling back to unstructured output.
Catch PydanticUserError explicitly so the fallback works regardless of
which built-in exception it subclasses.1 parent 941089e commit 76f86df
1 file changed
+10
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
406 | 412 | | |
407 | | - | |
| 413 | + | |
| 414 | + | |
408 | 415 | | |
409 | 416 | | |
410 | 417 | | |
| |||
0 commit comments