Skip to content
Merged
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
2 changes: 2 additions & 0 deletions api/core/tools/tool_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ def _convert_tool_response_to_str(tool_response: list[ToolInvokeMessage]) -> str
ensure_ascii=False,
)
)
elif response.type == ToolInvokeMessage.MessageType.VARIABLE:
continue
else:
parts.append(str(response.message))

Expand Down
2 changes: 0 additions & 2 deletions api/core/tools/utils/workflow_configuration_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ def get_workflow_graph_variables(cls, graph: Mapping[str, Any]) -> Sequence[Vari
"""
nodes = graph.get("nodes", [])
start_node = next(filter(lambda x: x.get("data", {}).get("type") == "start", nodes), None)

if not start_node:
return []

return [VariableEntity.model_validate(variable) for variable in start_node.get("data", {}).get("variables", [])]

@classmethod
Expand Down
1 change: 1 addition & 0 deletions api/services/tools/workflow_tools_manage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def create_workflow_tool(
try:
WorkflowToolProviderController.from_db(workflow_tool_provider)
except Exception as e:
logger.warning(e, exc_info=True)
raise ValueError(str(e))

with Session(db.engine, expire_on_commit=False) as session, session.begin():
Expand Down
22 changes: 22 additions & 0 deletions api/tests/unit_tests/core/tools/test_tool_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,28 @@ def test_agent_invoke_engine_meta_error():
assert error_meta.error == "meta failure"


def test_convert_tool_response_excludes_variable_messages():
"""Regression test for issue #34723.

WorkflowTool._invoke yields VARIABLE, TEXT, and suppressed-JSON messages.
_convert_tool_response_to_str must skip VARIABLE messages so that the
returned string contains only the TEXT representation and not a
duplicated, garbled Pydantic repr of the same data.
"""
tool = _build_tool()
outputs = {"reports": "hello"}
messages = [
tool.create_variable_message(variable_name="reports", variable_value="hello"),
tool.create_text_message('{"reports": "hello"}'),
tool.create_json_message(outputs, suppress_output=True),
]

result = ToolEngine._convert_tool_response_to_str(messages)

assert result == '{"reports": "hello"}'
assert "variable_name" not in result


def test_agent_invoke_tool_invoke_error():
tool = _build_tool(with_llm_parameter=True)
callback = Mock()
Expand Down
Loading