diff --git a/src/langbot/pkg/utils/funcschema.py b/src/langbot/pkg/utils/funcschema.py index f18b9e6b..bbe8b77b 100644 --- a/src/langbot/pkg/utils/funcschema.py +++ b/src/langbot/pkg/utils/funcschema.py @@ -83,7 +83,7 @@ def get_func_schema(function: typing.Callable) -> dict: parameters['properties'][param.name] = { 'type': param_type, - 'description': args_doc[param.name], + 'description': args_doc.get(param.name, ''), } # add schema for array diff --git a/tests/unit_tests/utils/test_funcschema.py b/tests/unit_tests/utils/test_funcschema.py index 8df7ff07..66e31655 100644 --- a/tests/unit_tests/utils/test_funcschema.py +++ b/tests/unit_tests/utils/test_funcschema.py @@ -188,4 +188,22 @@ class TestGetFuncSchema: result = funcschema.get_func_schema(doc_func) - assert result['parameters']['properties']['param_name']['description'] == 'This is the param description.' \ No newline at end of file + assert result['parameters']['properties']['param_name']['description'] == 'This is the param description.' + + def test_missing_parameter_doc_uses_empty_description(self): + """Test that undocumented parameters do not crash schema generation.""" + funcschema = get_funcschema_module() + + def partially_documented_func(documented: str, undocumented: int): + """Function with one undocumented param. + + Args: + documented: Documented parameter. + """ + pass + + result = funcschema.get_func_schema(partially_documented_func) + + props = result['parameters']['properties'] + assert props['documented']['description'] == 'Documented parameter.' + assert props['undocumented']['description'] == ''