This is an automated email from the ASF dual-hosted git repository.
wenjin272 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-agents.git
The following commit(s) were added to refs/heads/main by this push:
new be9716fc [python] Tolerate Java tool params without a description
(#915)
be9716fc is described below
commit be9716fc24235bbe0d88e10fda87650b2a189f57
Author: Edson <[email protected]>
AuthorDate: Sat Jul 18 04:45:05 2026 -0400
[python] Tolerate Java tool params without a description (#915)
---
python/flink_agents/api/tools/tests/test_utils.py | 10 ++++++++++
python/flink_agents/api/tools/utils.py | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/python/flink_agents/api/tools/tests/test_utils.py
b/python/flink_agents/api/tools/tests/test_utils.py
index b1d01f09..a98ef921 100644
--- a/python/flink_agents/api/tools/tests/test_utils.py
+++ b/python/flink_agents/api/tools/tests/test_utils.py
@@ -174,6 +174,16 @@ def test_model_from_java_schema_fields_are_required() ->
None:
assert field.is_required()
+def test_model_from_java_schema_without_description() -> None:
+ # Java only emits a "description" key for a @ToolParam with a non-empty
+ # description (ToolParam.description() defaults to ""), so a param without
+ # one must be tolerated and fall back to a generated description.
+ schema_str = json.dumps({"properties": {"a": {"type": "number"}}})
+ field = create_model_from_java_tool_schema_str("J",
schema_str).model_fields["a"]
+ assert field.annotation is float
+ assert field.description == "Parameter: a"
+
+
# ---- create_java_tool_schema_str_from_model
----------------------------------
diff --git a/python/flink_agents/api/tools/utils.py
b/python/flink_agents/api/tools/utils.py
index 79063950..d3cf647b 100644
--- a/python/flink_agents/api/tools/utils.py
+++ b/python/flink_agents/api/tools/utils.py
@@ -193,7 +193,7 @@ def create_model_from_java_tool_schema_str(
fields = {}
for param_name in properties:
- description = properties[param_name]["description"]
+ description = properties[param_name].get("description")
if description is None:
description = f"Parameter: {param_name}"
type = TYPE_MAPPING.get(properties[param_name]["type"])