Skip to content

[python] Tolerate Java tool params without a description#915

Merged
wenjin272 merged 1 commit into
apache:mainfrom
Zhuoxi2000:fix-tool-schema-missing-description
Jul 18, 2026
Merged

[python] Tolerate Java tool params without a description#915
wenjin272 merged 1 commit into
apache:mainfrom
Zhuoxi2000:fix-tool-schema-missing-description

Conversation

@Zhuoxi2000

Copy link
Copy Markdown
Contributor

Linked issue: #913

Purpose of change

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.

Closes #913

Tests

Added test_model_from_java_schema_without_description, covering a property
with no description key. It fails on main with KeyError: '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
KeyError for a schema that omits description, falling back to the default
description that the surrounding code already implements. The Java schema
generator is untouched.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

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
Zhuoxi2000 marked this pull request as draft July 17, 2026 07:32
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue. labels Jul 17, 2026
@Zhuoxi2000
Zhuoxi2000 marked this pull request as ready for review July 17, 2026 07:55

@wenjin272 wenjin272 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for taking this on @Zhuoxi2000. LGTM

@wenjin272
wenjin272 merged commit be9716f into apache:main Jul 18, 2026
28 checks passed
@wenjin272 wenjin272 added the fixVersion/0.3.1 The feature or bug should be implemented/fixed in the 0.3.1 version. label Jul 18, 2026
wenjin272 pushed a commit that referenced this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.3.1 The feature or bug should be implemented/fixed in the 0.3.1 version. fixVersion/0.4.0 priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] create_model_from_java_tool_schema_str crashes on a Java tool param without a description

2 participants