@@ -435,6 +435,63 @@ def test_create_wxo_flow_tool_prefixes_name_for_raw_payload(monkeypatch):
435435 assert artifact_bytes == b"artifact"
436436
437437
438+ def test_create_wxo_flow_tool_does_not_prefix_flow_variables (monkeypatch ):
439+ """With app_id set, flow variable names remain unprefixed (TRM exposes both)."""
440+ service = WatsonxOrchestrateDeploymentService (DummySettingsService ())
441+ flow_payload = BaseFlowArtifact (
442+ id = "00000000-0000-0000-0000-000000000001" ,
443+ name = "testflow" ,
444+ description = "desc" ,
445+ data = {
446+ "nodes" : [
447+ {
448+ "data" : {
449+ "node" : {
450+ "template" : {
451+ "api_key" : {"load_from_db" : True , "value" : "OPENAI_API_KEY" },
452+ }
453+ }
454+ }
455+ }
456+ ]
457+ },
458+ tags = [],
459+ provider_data = {"project_id" : "project-123" },
460+ )
461+ captured = {}
462+
463+ def capture_build (** kwargs ):
464+ captured ["flow_definition" ] = kwargs ["flow_definition" ]
465+ return b"artifact"
466+
467+ fake_tool = SimpleNamespace (
468+ __tool_spec__ = SimpleNamespace (
469+ model_dump = lambda ** kwargs : {"name" : "testflow" },
470+ ),
471+ )
472+ monkeypatch .setattr (
473+ watsonx_orchestrate_module ,
474+ "create_langflow_tool" ,
475+ lambda ** kwargs : fake_tool ,
476+ )
477+ monkeypatch .setattr (service , "_build_langflow_artifact_bytes" , capture_build )
478+ monkeypatch .setattr (
479+ watsonx_orchestrate_module ,
480+ "uuid4" ,
481+ lambda : SimpleNamespace (hex = "abcdef123456" ),
482+ )
483+
484+ service ._create_wxo_flow_tool (
485+ flow_payload = flow_payload ,
486+ connections = {"my_app" : "conn-1" },
487+ app_id = "my_app" ,
488+ )
489+
490+ template = captured ["flow_definition" ]["data" ]["nodes" ][0 ]["data" ]["node" ]["template" ]
491+ assert template ["api_key" ]["value" ] == "OPENAI_API_KEY"
492+ assert "my_app_OPENAI_API_KEY" not in str (template ["api_key" ]["value" ])
493+
494+
438495@pytest .mark .anyio
439496async def test_create_execution_posts_runs_payload (monkeypatch ):
440497 service = WatsonxOrchestrateDeploymentService (DummySettingsService ())
0 commit comments