Skip to content

chore(langchain): update docs on error handling for json schema - #39632

Merged
ccurme (ccurme) merged 1 commit into
masterfrom
cc/handle_errors_docstring
Aug 13, 2026
Merged

chore(langchain): update docs on error handling for json schema#39632
ccurme (ccurme) merged 1 commit into
masterfrom
cc/handle_errors_docstring

Conversation

@ccurme

Copy link
Copy Markdown
Collaborator

Resolves #38719.

@github-actions github-actions Bot added infra PRs made that include chores, devops, repo meta changes internal langchain `langchain` package issues & PRs size: XS < 50 LOC labels Aug 13, 2026
@ccurme
ccurme (ccurme) enabled auto-merge (squash) August 13, 2026 15:31

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment on lines +228 to +230
As a result, `handle_errors` is effectively inert for dict schemas. To get
validation and automatic retries, express the schema as a Pydantic model,
`dataclass`, or `TypedDict` instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Warning incorrectly says all error handling is inert

handle_errors still handles MultipleStructuredOutputsError for raw dict schemas: _handle_model_output invokes _handle_structured_output_error before parsing the schema whenever the model returns multiple structured tool calls. Calling the option “effectively inert” therefore tells dict-schema users that custom messages/retries will never run even though they do for this reachable error path. Please scope the warning specifically to schema-validation errors and retries.

(Refers to lines 228-230)


Your feedback helps Open SWE learn. React with 👍 or 👎 to tell us if this review comment was useful.

Suggested change
As a result, `handle_errors` is effectively inert for dict schemas. To get
validation and automatic retries, express the schema as a Pydantic model,
`dataclass`, or `TypedDict` instead.
As a result, `handle_errors` cannot catch schema-validation errors or retry
schema-invalid output for dict schemas. To get that validation and automatic
retry behavior, express the schema as a Pydantic model, `dataclass`, or `TypedDict`.

@ccurme
ccurme (ccurme) merged commit a2f02ab into master Aug 13, 2026
59 checks passed
@ccurme
ccurme (ccurme) deleted the cc/handle_errors_docstring branch August 13, 2026 15:32
@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks
⏩ 15 skipped benchmarks1


Comparing cc/handle_errors_docstring (ce44b81) with master (cde5293)

Open in CodSpeed

Footnotes

  1. 15 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra PRs made that include chores, devops, repo meta changes internal langchain `langchain` package issues & PRs size: XS < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured output with a raw JSON-schema dict is never validated, making ToolStrategy's handle_errors retry unreachable for dict schemas

1 participant