fix: use SkipJsonSchema to exclude callable fields from JSON schema generation#3048
fix: use SkipJsonSchema to exclude callable fields from JSON schema generation#3048
Conversation
…eneration Callable fields on BaseModel classes (tools, resources, prompts, etc.) would break JSON schema generation using Pydantic's model_json_schema() method. This fix applies the SkipJsonSchema annotation from pydantic.json_schema to all callable fields: - Tool.serializer - Tool.auth, Resource.auth, Prompt.auth, ResourceTemplate.auth - FunctionTool.fn - TransformedTool.fn, parent_tool, forwarding_fn - FunctionResource.fn - FunctionResourceTemplate.fn - FunctionPrompt.fn SkipJsonSchema is the Pydantic 2 recommended approach for fields that should not appear in generated schemas, as it only affects JSON schema generation while leaving runtime behavior unchanged. Fixes #3046 Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
WalkthroughThis PR systematically wraps callable and serializer field types across multiple model classes with Pydantic's Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…eneration (PrefectHQ#3048) Co-authored-by: Bill Easton <strawgate@users.noreply.github.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Problem
Callable fields on BaseModel classes would break JSON schema generation using Pydantic's
model_json_schema()method. This prevented users from:model_json_schema()for introspectionSolution
Applied the
SkipJsonSchemaannotation frompydantic.json_schemato all callable fields across Tools, Resources, Prompts, and ResourceTemplates. This is the Pydantic 2 recommended approach for fields that should not appear in generated schemas, as it only affects JSON schema generation while leaving runtime behavior unchanged.Added comprehensive test coverage to verify JSON schema generation works correctly for all affected classes.
Fixes #3046
Generated with Claude Code