Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG]: ensure_type_in_schemas incorrectly forces empty schemas {} to {"type": "object"} in anyOf/oneOf

Open Beginner friendly
#8,073 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sallyw02 is already working on this.

Since Oct 12, 2026.

  • #8106 by @sallyw02 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ai, backend

Research direction

Start with lib/crewai/src/crewai/utilities/pydantic_schema_utils.py and inspect ensure_type_in_schemas() around the empty-schema handling described in the issue. Trace how that function handles anyOf and oneOf, then check existing tests for these schemas. Done means {} retains its unconstrained JSON Schema meaning while the intended strict-mode behavior is preserved.

Written by the indexing model from the issue text.

Description

Description

In lib/crewai/src/crewai/utilities/pydantic_schema_utils.py, ensure_type_in_schemas() converts empty schemas {} inside anyOf / oneOf into {"type": "object"}:

# lib/crewai/src/crewai/utilities/pydantic_schema_utils.py (lines 290-292)
for i, schema in enumerate(schema_list):
    if isinstance(schema, dict) and schema == {}:
        schema_list[i] = {"type": "object"}

In JSON Schema specification, {} represents an unconstrained schema (accepting any value, including primitives such as strings, numbers, and booleans). Converting {} to {"type": "object"} corrupts schema semantics:

  1. When a tool has a parameter typed as Any or Optional[Any], Pydantic generates {"anyOf": [{}, {"type": "null"}]}.
  2. ensure_type_in_schemas transforms this into {"anyOf": [{"type": "object"}, {"type": "null"}]}.
  3. As a result, the tool parameter is restricted to dictionaries/objects only. If an LLM returns a valid scalar (e.g. 42 or "ok"), validation fails or the LLM is forced to return {} instead of the requested scalar.
Steps to Reproduce
from copy import deepcopy
from crewai.utilities.pydantic_schema_utils import ensure_type_in_schemas

schema = {"anyOf": [{}, {"type": "null"}]}
result = ensure_type_in_schemas(deepcopy(schema))
print(result)

# Observed:
# {'anyOf': [{'type': 'object'}, {'type': 'null'}]}
Expected Behavior

Empty schemas {} (representing Any) should not be unconditionally converted to {"type": "object"}. If OpenAI strict mode requires an explicit type, converting {} to an object restricts valid scalar arguments. The conversion should either preserve {} when not enforcing strict object constraints or avoid coercing unconstrained types to object.

Additional Context
  • Python environment: Python 3.10+ / Pydantic v2
  • File: lib/crewai/src/crewai/utilities/pydantic_schema_utils.py
Dominant language
Python
Stars
59.8k
Forks
8.8k
Avg merge
1d 14h
Merged PRs (30d)
90

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from crewAIInc/crewAI

All issues in crewAIInc/crewAI

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.