Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Fix routing profiles reset

Louis Choquel6f9c556174c8
diff --git a/.pipelex/inference/routing_profiles.toml b/.pipelex/inference/routing_profiles.toml
index 592533daf..47e87ecc0 100644
--- a/.pipelex/inference/routing_profiles.toml
+++ b/.pipelex/inference/routing_profiles.toml
@@ -45,9 +45,8 @@ fallback_order = [
"gemini-*" = "pipelex_inference"
[profiles.pipelex_first.optional_routes] # Each optional route is considered only if its backend is available
-"*-sdxl" = "blackboxai"
-"flux-*" = "blackboxai"
-"nano-banana" = "blackboxai"
+"*-sdxl" = "fal"
+"flux-*" = "fal"
"gpt-image-1" = "openai"
"mistral-ocr" = "mistral"
diff --git a/pipelex/cli/commands/init/command.py b/pipelex/cli/commands/init/command.py
index 093fddc99..41b9707a0 100644
--- a/pipelex/cli/commands/init/command.py
+++ b/pipelex/cli/commands/init/command.py
@@ -1,6 +1,7 @@
"""Main command orchestration for the init command."""
import os
+import shutil
import typer
from rich.console import Console
@@ -12,6 +13,7 @@ from pipelex.cli.commands.init.routing import customize_routing_profile
from pipelex.cli.commands.init.telemetry import setup_telemetry
from pipelex.cli.commands.init.ui.general_ui import build_initialization_panel, display_already_configured_message
from pipelex.cli.commands.init.ui.types import InitFocus
+from pipelex.kit.paths import get_kit_configs_dir
from pipelex.system.configuration.config_loader import config_manager
from pipelex.system.telemetry.telemetry_config import TELEMETRY_CONFIG_FILE_NAME
from pipelex.system.telemetry.telemetry_manager_abstract import TelemetryManagerAbstract
@@ -200,6 +202,16 @@ def execute_initialization(
# Step 2.5: Set up routing profile if specifically requested
if needs_routing:
console.print()
+
+ # If reset is True, copy the template file first
+ if reset:
+ routing_profiles_toml_path = os.path.join(config_manager.pipelex_config_dir, "inference", "routing_profiles.toml")
+ template_routing_path = os.path.join(str(get_kit_configs_dir()), "inference", "routing_profiles.toml")
+
+ if path_exists(template_routing_path):
+ shutil.copy2(template_routing_path, routing_profiles_toml_path)
+ console.print("✅ Reset routing_profiles.toml from template")
+
selected_backend_keys = get_selected_backend_keys(backends_toml_path)
if selected_backend_keys:
customize_routing_profile(selected_backend_keys)
diff --git a/pipelex/kit/configs/inference/routing_profiles.toml b/pipelex/kit/configs/inference/routing_profiles.toml
index 592533daf..47e87ecc0 100644
--- a/pipelex/kit/configs/inference/routing_profiles.toml
+++ b/pipelex/kit/configs/inference/routing_profiles.toml
@@ -45,9 +45,8 @@ fallback_order = [
"gemini-*" = "pipelex_inference"
[profiles.pipelex_first.optional_routes] # Each optional route is considered only if its backend is available
-"*-sdxl" = "blackboxai"
-"flux-*" = "blackboxai"
-"nano-banana" = "blackboxai"
+"*-sdxl" = "fal"
+"flux-*" = "fal"
"gpt-image-1" = "openai"
"mistral-ocr" = "mistral"
diff --git a/tests/e2e/pipelex/cli/test_init_cmd_focused.py b/tests/e2e/pipelex/cli/test_init_cmd_focused.py
index a4e1aac3a..57c353416 100644
--- a/tests/e2e/pipelex/cli/test_init_cmd_focused.py
+++ b/tests/e2e/pipelex/cli/test_init_cmd_focused.py
@@ -192,6 +192,37 @@ class TestFocusedInitialization:
# Verify telemetry was changed
env.verify_telemetry("identified")
+ def test_reset_routing_with_pipelex_inference(self, tmp_path: Path, mocker: MockerFixture) -> None:
+ """Test Case: Reset routing when only pipelex_inference is enabled (bug fix test)."""
+ # Setup environment with existing config and pipelex_inference enabled
+ env = MockedInitEnvironment(tmp_path, mocker)
+ env.setup_with_configs(include_backends=True, include_routing=True, include_telemetry=True)
+
+ # Enable only pipelex_inference
+ backends_path = env.inference_dir / "backends.toml"
+ toml_doc = load_toml_with_tomlkit(str(backends_path))
+ toml_doc["pipelex_inference"]["enabled"] = True # type: ignore[index]
+ toml_doc["openai"]["enabled"] = False # type: ignore[index]
+ toml_doc["anthropic"]["enabled"] = False # type: ignore[index]
+ save_toml_to_path(toml_doc, str(backends_path))
+
+ # Modify routing to have wrong config (simulating the bug scenario)
+ routing_path = env.inference_dir / "routing_profiles.toml"
+ routing_doc = load_toml_with_tomlkit(str(routing_path))
+ routing_doc["active"] = "wrong_profile" # type: ignore[index]
+ save_toml_to_path(routing_doc, str(routing_path))
+
+ # User inputs - need to confirm reset
+ env.add_confirm_input(True) # Confirm reset initialization
+
+ env.setup_mocks()
+
+ # Execute with ROUTING focus and reset flag
+ init_cmd(focus=InitFocus.ROUTING, reset=True)
+
+ # Verify routing was reset to pipelex_first (correct for pipelex_inference)
+ env.verify_routing("pipelex_first")
+
def test_everything_already_configured(self, tmp_path: Path, mocker: MockerFixture) -> None:
"""Test Case 7.1: Everything configured - decline reconfigure."""
# Setup complete environment