Commit 5c09a39
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 6524782 commit 5c09a39
1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
411 | 412 | | |
412 | 413 | | |
413 | 414 | | |
414 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
415 | 422 | | |
416 | | - | |
| 423 | + | |
| 424 | + | |
417 | 425 | | |
418 | 426 | | |
419 | 427 | | |
| |||
0 commit comments