| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Picking the output model builds throwaway pydantic models for the return type, which raises PydanticSchemaGenerationError for annotations pydantic cannot model, such as Iterator[str] or AsyncIterator[str]. That call sat outside the try/except that routes expected schema failures to the unstructured fallback, so the error escaped func_metadata and a properly annotated generator tool could not register at all. With structured_output=True the existing flow raises InvalidSignature instead. Fixes modelcontextprotocol#3573
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3573. If a maintainer assigns you to #3573, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #3573
Disclosure: this fix was developed with AI assistance; I have reviewed the diff, run the tests locally, and can explain the change.
Summary
func_metadata raises an uncaught pydantic.errors.PydanticSchemaGenerationError when a tool's return annotation is Iterator[...] / AsyncIterator[...] (either the typing or the collections.abc spelling), so a correctly annotated generator tool cannot register at all. The fallback machinery for unserializable return types already exists — the call to _create_output_model() simply sits outside the try that routes those failures to it.
This wraps that call in the same failure path: on PydanticSchemaGenerationError the tool degrades to unstructured output (output_schema=None), and with structured_output=True the existing flow raises InvalidSignature. Generator[...] is untouched — pydantic treats it as a sequence and its structured array schema keeps working.
Motivation and Context
-> Iterator[str] is the PEP 484 spelling for generator functions, but registering one currently crashes at decoration time instead of taking the documented unstructured fallback (#3573). Fixing it at the model-selection step reuses the existing fallback semantics in one place rather than special-casing iterator types.
How Has This Been Tested?
Breaking Changes
None. Registrations that previously crashed now succeed as unstructured tools (or raise InvalidSignature under structured_output=True, matching the documented contract for unserializable return types).
Types of changes
Checklist