From bec542ad1cc8bf4fc7c0a1f0f16ad8d85f5f1c55 Mon Sep 17 00:00:00 2001 From: dsuresh-ap Date: Thu, 12 Feb 2026 16:02:13 -0500 Subject: [PATCH] fix: extract jsonBodySection from body_structure [PC-3936] Pass jsonBodySection from agent config body_structure through to ActivityMetadata so the SDK uses the correct multipart part name. --- .../agent/tools/integration_tool.py | 5 ++- tests/agent/tools/test_integration_tool.py | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/uipath_langchain/agent/tools/integration_tool.py b/src/uipath_langchain/agent/tools/integration_tool.py index 5917c742..aec21723 100644 --- a/src/uipath_langchain/agent/tools/integration_tool.py +++ b/src/uipath_langchain/agent/tools/integration_tool.py @@ -119,18 +119,21 @@ def convert_to_activity_metadata( param_location_info.body_fields = list(body_fields_set) - # determine content type + # determine content type and json body section content_type = "application/json" + json_body_section = None if resource.properties.body_structure is not None: shorthand_type = resource.properties.body_structure.get("contentType", "json") if shorthand_type == "multipart": content_type = "multipart/form-data" + json_body_section = resource.properties.body_structure.get("jsonBodySection") return ActivityMetadata( object_path=resource.properties.tool_path, method_name=http_method, content_type=content_type, parameter_location_info=param_location_info, + json_body_section=json_body_section, ) diff --git a/tests/agent/tools/test_integration_tool.py b/tests/agent/tools/test_integration_tool.py index bba279f4..04e33de0 100644 --- a/tests/agent/tools/test_integration_tool.py +++ b/tests/agent/tools/test_integration_tool.py @@ -184,6 +184,47 @@ def test_jsonpath_parameter_handling_multiple_nested_same_root( assert "metadata.field2" not in result.parameter_location_info.body_fields assert "metadata.nested.field" not in result.parameter_location_info.body_fields + def test_json_body_section_from_body_structure(self, resource_factory): + """Test that jsonBodySection is extracted from body_structure.""" + param = AgentIntegrationToolParameter( + name="prompt", type="string", field_location="body" + ) + resource = resource_factory(parameters=[param]) + resource.properties.body_structure = { + "contentType": "multipart", + "jsonBodySection": "RagRequest", + } + + result = convert_to_activity_metadata(resource) + + assert result.content_type == "multipart/form-data" + assert result.json_body_section == "RagRequest" + + def test_json_body_section_none_when_not_specified(self, resource_factory): + """Test that json_body_section is None when bodyStructure has no jsonBodySection.""" + param = AgentIntegrationToolParameter( + name="prompt", type="string", field_location="body" + ) + resource = resource_factory(parameters=[param]) + resource.properties.body_structure = {"contentType": "multipart"} + + result = convert_to_activity_metadata(resource) + + assert result.content_type == "multipart/form-data" + assert result.json_body_section is None + + def test_json_body_section_none_when_no_body_structure(self, resource_factory): + """Test that json_body_section is None when body_structure is None.""" + param = AgentIntegrationToolParameter( + name="prompt", type="string", field_location="body" + ) + resource = resource_factory(parameters=[param]) + + result = convert_to_activity_metadata(resource) + + assert result.content_type == "application/json" + assert result.json_body_section is None + def test_parameter_location_mapping_simple_fields(self, resource_factory): """Test parameter mapping for simple field names across different locations.""" params = [