Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c62df86
Support tool mode in dynamic outputs
erichare Nov 6, 2025
10f5932
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 6, 2025
b764428
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 6, 2025
f35eac4
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 6, 2025
e77cf5c
Tool mode and ruff fixes
erichare Nov 6, 2025
86f8fcb
Template updates
erichare Nov 6, 2025
cc300f9
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 6, 2025
b508b17
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 6, 2025
b18ecd5
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 6, 2025
ec7f30c
Merge branch 'main' into fix-file-component-toolmode
erichare Nov 12, 2025
22dc1fa
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 12, 2025
2d1310a
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 12, 2025
8766a6e
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 12, 2025
25f24d0
Update test_mcp_servers_file.py
erichare Nov 18, 2025
78c0a8f
Merge branch 'main' into fix-file-component-toolmode
erichare Nov 18, 2025
17d6e6f
Revert "Update test_mcp_servers_file.py"
erichare Nov 18, 2025
e84ccc9
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 18, 2025
c224f64
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 18, 2025
7eb7557
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 18, 2025
7d45999
add possibility for the agent to access the processed output file
Cristhianzl Nov 24, 2025
46f462a
merge fix
Cristhianzl Nov 24, 2025
59459d0
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 24, 2025
5d7e885
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 24, 2025
3c13d86
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 24, 2025
1730e21
Merge branch 'main' into fix-file-component-toolmode
carlosrcoelho Nov 24, 2025
363f088
Merge branch 'main' into fix-file-component-toolmode
erichare Nov 24, 2025
9f8c9b5
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 24, 2025
01e2578
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 24, 2025
f3e74a9
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 24, 2025
0ac1338
Merge branch 'main' into fix-file-component-toolmode
erichare Nov 24, 2025
6bdcf1c
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 24, 2025
32b9506
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 24, 2025
6a87a83
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 24, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@
"dependencies": [
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "trustcall",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@
"dependencies": [
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "trustcall",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@
"dependencies": [
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "trustcall",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -2454,7 +2454,7 @@
"dependencies": [
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "trustcall",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,7 @@
"dependencies": [
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "trustcall",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -1099,7 +1099,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -2603,7 +2603,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -3325,7 +3325,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -392,7 +392,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -1297,7 +1297,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -2398,7 +2398,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down Expand Up @@ -3124,7 +3124,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@
},
{
"name": "pydantic",
"version": "2.11.10"
"version": "2.10.6"
},
{
"name": "lfx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,134 @@ def test_process_docling_subprocess_success(self, mock_subprocess):
assert result is not None
assert result.data["doc"] == mock_result["doc"]
assert result.data["file_path"] == "test.pdf"

def test_dynamic_outputs_have_tool_mode_enabled(self):
"""Test that all dynamically created outputs have tool_mode=True."""
component = FileComponent()

# Test single CSV file
frontend_node = {"outputs": [], "template": {"path": {"file_path": ["test.csv"]}}}
result = component.update_outputs(frontend_node, "path", ["test.csv"])
for output in result["outputs"]:
assert output.tool_mode is True, f"Output {output.name} should have tool_mode=True"

# Test single JSON file
frontend_node = {"outputs": [], "template": {"path": {"file_path": ["data.json"]}}}
result = component.update_outputs(frontend_node, "path", ["data.json"])
for output in result["outputs"]:
assert output.tool_mode is True, f"Output {output.name} should have tool_mode=True"

# Test multiple files
frontend_node = {"outputs": [], "template": {"path": {"file_path": ["file1.txt", "file2.txt"]}}}
result = component.update_outputs(frontend_node, "path", ["file1.txt", "file2.txt"])
for output in result["outputs"]:
assert output.tool_mode is True, f"Output {output.name} should have tool_mode=True"

# Test advanced mode enabled
frontend_node = {
"outputs": [],
"template": {
"path": {"file_path": ["document.pdf"]},
"advanced_mode": {"value": True},
},
}
result = component.update_outputs(frontend_node, "advanced_mode", field_value=True)
for output in result["outputs"]:
assert output.tool_mode is True, f"Output {output.name} should have tool_mode=True"

# Test advanced mode disabled
frontend_node = {
"outputs": [],
"template": {
"path": {"file_path": ["document.pdf"]},
"advanced_mode": {"value": False},
},
}
result = component.update_outputs(frontend_node, "advanced_mode", field_value=False)
for output in result["outputs"]:
assert output.tool_mode is True, f"Output {output.name} should have tool_mode=True"

def test_file_path_str_input_exists_for_tool_mode(self):
"""Test that file_path_str input exists for tool mode."""
component = FileComponent()

# Find the file_path_str input
file_path_str_input = None
for input_field in component.inputs:
if input_field.name == "file_path_str":
file_path_str_input = input_field
break

assert file_path_str_input is not None, "file_path_str input should exist"
assert file_path_str_input.tool_mode is True, "file_path_str should have tool_mode=True"

# Check that the path FileInput has tool_mode=False
path_input = None
for input_field in component.inputs:
if input_field.name == "path":
path_input = input_field
break

assert path_input is not None, "path input should exist"
assert path_input.tool_mode is False, "path FileInput should have tool_mode=False"

def test_read_file_using_file_path_str(self, tmp_path):
"""Test reading a file using file_path_str parameter (tool mode)."""
# Create a test file
test_file = tmp_path / "test.txt"
test_content = "Hello from tool mode!"
test_file.write_text(test_content)

# Create component and set file_path_str
component = FileComponent()
component.file_path_str = str(test_file)

# Load the file
result = component.load_files_message()

assert result.text == test_content, f"Expected '{test_content}', got '{result.text}'"

def test_read_file_using_path_when_file_path_str_not_provided(self, tmp_path):
"""Test that component falls back to uploaded file when file_path_str is not provided.

This simulates the scenario where a file is uploaded via UI and then the Agent
calls the component as a tool without providing file_path_str.
When a file is uploaded via UI, the FileInput populates the file_path attribute.
"""
# Create a test file
test_file = tmp_path / "test_from_ui.txt"
test_content = "Hello from uploaded file!"
test_file.write_text(test_content)

# Create component and simulate uploaded file
component = FileComponent()
# When user uploads file via UI, the FileInput sets the path attribute
# which populates the file_path list (from FileMixin)
component.path = str(test_file) # Simulate FileInput value

# DO NOT set file_path_str (simulating Agent calling tool without this parameter)
# component.file_path_str should be None or empty

# Load the file - should use path since file_path_str is not provided
result = component.load_files_message()

assert result.text == test_content, f"Expected '{test_content}', got '{result.text}'"

def test_file_path_str_takes_priority_over_path(self, tmp_path):
"""Test that file_path_str takes priority when both are provided."""
# Create two test files
file1 = tmp_path / "file1.txt"
file1.write_text("Content from path")

file2 = tmp_path / "file2.txt"
file2.write_text("Content from file_path_str")

# Create component with both inputs set
component = FileComponent()
component.path = str(file1) # Uploaded file via UI
component.file_path_str = str(file2) # Provided by Agent tool call

# Load the file - should use file_path_str (priority)
result = component.load_files_message()

assert result.text == "Content from file_path_str", "file_path_str should take priority over path"
Loading
Loading