Skip to content

Fix tool schema normalization dropping field names and literal data - #422

Open
WitBlue6 wants to merge 1 commit into
andrewyng:mainfrom
WitBlue6:WitBlue6/preserve-tool-schema-data-names
Open

WitBlue6 wants to merge 1 commit into
andrewyng:mainfrom
WitBlue6:WitBlue6/preserve-tool-schema-data-names

Conversation

@WitBlue6

Copy link
Copy Markdown

Summary

Fixes #421

The schema normalizer treats every dictionary as a schema. As a result, a callable's argument named title is removed from properties while remaining in required. Nested model aliases such as $defs disappear too. Dictionary defaults and object-valued const/enum/examples are also modified.

Distinguish maps of field names from schema dictionaries, and keep literal data opaque. Schema metadata titles are still removed, local model references are still inlined, and nullable normalization is retained. No public API or dependencies change.

Regression coverage

  • Callable title argument is advertised with its type and remains executable.
  • Nested Pydantic model preserves title and $defs field names while its schema metadata is removed.
  • Dictionary defaults retain their original content.
  • const/enum/examples preserve literal objects containing title, $defs, and $ref.

All new defect cases fail against the original implementation.

Validation

Python 3.10.17 on macOS arm64:

.venv/bin/pytest tests/utils tests/client -m "not integration" -q
.venv/bin/pytest tests -m "not integration" -q -rs
.venv/bin/black --check aisuite/utils/tools.py tests/utils/test_tool_manager.py
  • Tools/client subset: 84 passed, 15 integration cases deselected, 3 subtests passed.
  • Full non-integration suite: 447 passed, 2 skipped, 80 integration cases deselected, 3 subtests passed.
  • Skips are existing Python-version conditions (tomllib CLI test and Watsonx compatibility); no new skips.
  • Black 24.4.2 (the pre-commit version) passes for both changed files.

Live provider/MCP integration tests were not run; this change is validated using real Pydantic schemas and actual Tools registration/execution, without provider mocks or requests.

AI disclosure: implemented, reviewed against schema generation/execution callers, and tested by OpenAI Codex. No human review is claimed.

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.

Tool schema normalization drops title arguments and changes dictionary defaults

1 participant