diff --git a/src/pydantic_ai_lightspeed/llamastack/_model.py b/src/pydantic_ai_lightspeed/llamastack/_model.py index 781af26b7..019652d5c 100644 --- a/src/pydantic_ai_lightspeed/llamastack/_model.py +++ b/src/pydantic_ai_lightspeed/llamastack/_model.py @@ -53,7 +53,6 @@ { "conversation", "max_infer_iters", - "tools", "tool_choice", "include", "text", @@ -84,6 +83,8 @@ def _model_settings_from_responses_params( if responses_params.extra_headers: settings_dict["extra_headers"] = dict(responses_params.extra_headers) settings_dict["openai_store"] = responses_params.store + if responses_params.tools is not None: + settings_dict["openai_native_tools"] = responses_params.tools if responses_params.previous_response_id is not None: settings_dict["openai_previous_response_id"] = ( responses_params.previous_response_id diff --git a/tests/unit/pydantic_ai_lightspeed/llamastack/test_model.py b/tests/unit/pydantic_ai_lightspeed/llamastack/test_model.py index 271a00fbe..191b8a2b9 100644 --- a/tests/unit/pydantic_ai_lightspeed/llamastack/test_model.py +++ b/tests/unit/pydantic_ai_lightspeed/llamastack/test_model.py @@ -86,7 +86,6 @@ def test_extra_body_fields(self) -> None: params = _make_params( max_infer_iters=5, max_tool_calls=10, - tools=[{"type": "function", "name": "test-function", "parameters": {}}], ) settings = _model_settings_from_responses_params(params) @@ -95,9 +94,16 @@ def test_extra_body_fields(self) -> None: assert settings["extra_body"]["max_infer_iters"] == 5 assert settings["extra_body"]["max_tool_calls"] == 10 assert settings["extra_body"]["conversation"] == "conv-1" - assert settings["extra_body"]["tools"] == [ - {"type": "function", "name": "test-function", "parameters": {}} - ] + + def test_tools_maps_to_openai_native_tools(self) -> None: + """Test that tools maps to openai_native_tools, not extra_body.""" + tools = [{"type": "function", "name": "test-function", "parameters": {}}] + params = _make_params(tools=tools) + settings = _model_settings_from_responses_params(params) + + assert "openai_native_tools" in settings + assert settings["openai_native_tools"] is params.tools + assert "tools" not in settings.get("extra_body", {}) def test_none_fields_excluded(self) -> None: """Test that None optional fields do not appear in the result.""" @@ -581,7 +587,6 @@ def test_contains_expected_fields(self) -> None: expected = { "conversation", "max_infer_iters", - "tools", "tool_choice", "include", "text",