Skip to content

Conversation

@zerone0x
Copy link
Contributor

Summary

Fixes #8184

Backends like SGLang with strict JSON Schema validation (using Pydantic) fail when object schemas don't have a required field, returning errors like:

Tool function has invalid 'parameters' schema: None is not of type 'array' on schema['required']

This PR ensures all object-type schemas have required set (as an empty array [] if no fields are required).

Changes

  • Added ensureRequiredField() helper in ProviderTransform.schema() that recursively adds required: [] to all object schemas that don't have it
  • Added comprehensive tests covering empty objects, nested objects, deeply nested objects, arrays of objects, and preservation of existing required fields

Test plan

  • All existing tests pass
  • New tests verify the fix works for various schema structures
  • Manual testing with SGLang backend (would need access to such a backend)

🤖 Generated with Claude Code

…tors

Backends like SGLang with strict JSON Schema validation fail when object
schemas don't have a 'required' field. This fix ensures all object-type
schemas have 'required' set (as an empty array if no fields are required).

Fixes anomalyco#8184

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters)

1 participant