[python] Tolerate Java tool params without a description#915
Merged
wenjin272 merged 1 commit intoJul 18, 2026
Merged
Conversation
create_model_from_java_tool_schema_str read properties[name]["description"] directly, but Java's SchemaUtils.generateSchema only emits a "description" key when a @ToolParam has a non-empty description (ToolParam.description() defaults to ""). A description-less param — which the project's own tools produce, e.g. @ToolParam(name = "a") — therefore crashed the Python schema converter with KeyError: 'description'. Read it with .get() so the existing 'if description is None' fallback fabricates the default "Parameter: <name>" description instead of crashing. Add a regression test covering a property with no description key. Closes apache#913
Zhuoxi2000
marked this pull request as draft
July 17, 2026 07:32
Zhuoxi2000
marked this pull request as ready for review
July 17, 2026 07:55
wenjin272
approved these changes
Jul 18, 2026
wenjin272
left a comment
Contributor
There was a problem hiding this comment.
Thanks for taking this on @Zhuoxi2000. LGTM
wenjin272
pushed a commit
that referenced
this pull request
Jul 18, 2026
(cherry picked from commit be9716f)
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.
Linked issue: #913
Purpose of change
create_model_from_java_tool_schema_strreadproperties[name]["description"]directly, but Java's
SchemaUtils.generateSchemaonly emits a"description"key when a
@ToolParamhas a non-empty description (ToolParam.description()defaults to
""). A description-less param — which the project's own toolsproduce, e.g.
@ToolParam(name = "a")— therefore crashed the Python schemaconverter with
KeyError: 'description'.Read it with
.get()so the existingif description is Nonefallbackfabricates the default
"Parameter: <name>"description instead of crashing.Closes #913
Tests
Added
test_model_from_java_schema_without_description, covering a propertywith no
descriptionkey. It fails onmainwithKeyError: 'description'(
utils.py:196) and passes with this change.pytest flink_agents/api/tools/: 16 passed.ruff check --no-fix/ruff format --check(pinned 0.11.13): clean.API
No. The function signature and contract are unchanged; it only stops raising
KeyErrorfor a schema that omitsdescription, falling back to the defaultdescription that the surrounding code already implements. The Java schema
generator is untouched.
Documentation
doc-neededdoc-not-neededdoc-included