DSPy: The framework for programming—not prompting—language models
Python
fix(tool): stabilize open args schema (#10012)
Isaac Miller88673867afa2
diff --git a/dspy/adapters/types/tool.py b/dspy/adapters/types/tool.pyindex aed4742f7..239ad1113 100644--- a/dspy/adapters/types/tool.py+++ b/dspy/adapters/types/tool.py@@ -264,7 +264,7 @@ class ToolCalls(Type):class ToolCall(Type):id: str | None = Nonename: str- args: dict[str, Any]+ args: dict[str, Any] = pydantic.Field(json_schema_extra={"additionalProperties": True})@classmethoddef __get_pydantic_json_schema__(cls, core_schema: Any, handler: Any) -> dict[str, Any]:diff --git a/tests/adapters/test_tool.py b/tests/adapters/test_tool.pyindex 94b62eacc..4987a6a13 100644--- a/tests/adapters/test_tool.py+++ b/tests/adapters/test_tool.py@@ -470,6 +470,7 @@ def test_tool_calls_json_schema_omits_internal_id_field():assert "tool_call_results" not in schema["properties"]assert "id" not in schema["$defs"]["ToolCall"]["properties"]+ assert schema["$defs"]["ToolCall"]["properties"]["args"]["additionalProperties"] is Trueassert schema["$defs"]["ToolCall"]["required"] == ["name", "args"]