Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/uipath_langchain/agent/tools/integration_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down
41 changes: 41 additions & 0 deletions tests/agent/tools/test_integration_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Loading