Repository navigation
Conversation
There was a problem hiding this comment.
🟢 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
0and7, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's a bug in
make_tool_server: optional request fields get a default ofNoneinstead of the default in the tool's parameter schema. So a parameter left out of the request is passed asNonerather than its declared default.For a tool
def echo(value: int = 7) -> str,POST {}calls it withvalue=Noneand returns"None"(with typeguard on, it's an argument type error). It should call it with7; 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_serverwhere optional tool parameters were modeled withdefault=None, so omitted JSON fields were passed asNoneinstead of the default declared on the tool (e.g.echo(value: int = 7)returning"None").create_request_model_from_toolnow sets Pydantic field defaults frominfo.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 defaults0and7, empty vs explicit bodies, and tools with or without per-parameter docstrings.Reviewed by Cursor Bugbot for commit 8f743d5. Configure here.