Skip to content

make_tool_server: use the tool's default for omitted optional parameters - #394

Open
rpinho wants to merge 1 commit into
Future-House:mainfrom
rpinho:fix-tool-defaults
Open

rpinho wants to merge 1 commit into
Future-House:mainfrom
rpinho:fix-tool-defaults

Conversation

@rpinho

@rpinho rpinho commented Nov 16, 2026 •

Copy link
Copy Markdown

There's a bug in make_tool_server: optional request fields get a default of None instead of the default in the tool's parameter schema. So a parameter left out of the request is passed as None rather than its declared default.

For a tool def echo(value: int = 7) -> str, POST {} calls it with value=None and returns "None" (with typeguard on, it's an argument type error). It should call it with 7; an explicit value still overrides it.

This uses info.get("default") from the schema for those fields.

Test: test_make_tool_server_default_parameter (defaults 0 and 7, with and without a value, with and without a parameter description) fails on main and passes here. Core tests: 181 passed, 1 skipped (2 live cases deselected); ruff, mypy, refurb and pylint pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N


Note

Low Risk
Targeted bugfix in debug tool-server request modeling; new regression test covers the behavior.

Overview
Fixes a bug in make_tool_server where optional tool parameters were modeled with default=None, so omitted JSON fields were passed as None instead of the default declared on the tool (e.g. echo(value: int = 7) returning "None").

create_request_model_from_tool now sets Pydantic field defaults from info.get("default") in the tool’s parameter schema, for both described and undescribed optional fields. Explicit request values still override the default.

Adds test_make_tool_server_default_parameter, covering defaults 0 and 7, empty vs explicit bodies, and tools with or without per-parameter docstrings.

Reviewed by Cursor Bugbot for commit 8f743d5. Configure here.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change to optional request-field default handling.

No open issues 🎉

What changed in this PR

Fixes default handling in make_tool_server so omitted optional request fields use the tool’s declared schema defaults instead of None.

Changes:

  • Applies schema defaults to optional fields, with or without parameter descriptions.
  • Adds regression coverage for defaults 0 and 7, omitted fields, and explicit values that override defaults.
File Description
tests/​test_tools.py Adds parameterized tests for omitted and explicit request values, with and without parameter descriptions.
src/​aviary/​tools/​server.py Uses schema defaults when building optional request-model fields.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants