Skip to content

Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.

Rust

fix(cli): forward OpenClaw arguments unchanged (#477)

Elyas Mehtabuddinca39ffab004a
diff --git a/switchyard/cli/launchers/openclaw_launcher.py b/switchyard/cli/launchers/openclaw_launcher.py
index a0dbcc87a..2fbe04977 100644
--- a/switchyard/cli/launchers/openclaw_launcher.py
+++ b/switchyard/cli/launchers/openclaw_launcher.py
@@ -152,8 +152,8 @@ def _openclaw_env(workspace: str) -> dict[str, str]:
def _openclaw_command(openclaw_bin: str, openclaw_args: list[str]) -> list[str]:
- """Build the OpenClaw interactive command."""
- return [openclaw_bin, "chat", *openclaw_args]
+ """Build the OpenClaw command, defaulting to interactive chat."""
+ return [openclaw_bin, *(openclaw_args or ["chat"])]
def _supervise_openclaw(
diff --git a/tests/test_launchers.py b/tests/test_launchers.py
index 6873c7b75..4f2c9a995 100644
--- a/tests/test_launchers.py
+++ b/tests/test_launchers.py
@@ -8,10 +8,12 @@ from pathlib import Path
import pytest
+from switchyard.cli.command_utils import strip_forwarded_args
from switchyard.cli.launch_command import _config_path
from switchyard.cli.launchers.claude_code_launcher import _claude_env
from switchyard.cli.launchers.codex_cli_launcher import _codex_env, _provider_overrides
from switchyard.cli.launchers.native_server import NativeServer
+from switchyard.cli.launchers.openclaw_launcher import _openclaw_command
from switchyard.cli.switchyard_cli import _build_parser
@@ -46,6 +48,27 @@ def test_launcher_surface_is_model_config_and_forwarded_args(agent: str) -> None
assert vars(args)[f"{agent}_args"] == ["--", "--version"]
+ ("agent_args", "expected"),
+ [
+ ([], ["openclaw", "chat"]),
+ (["--", "--version"], ["openclaw", "--version"]),
+ (["--", "chat", "--help"], ["openclaw", "chat", "--help"]),
+ ],
+)
+def test_openclaw_uses_forwarded_args_as_the_complete_argument_list(
+ agent_args: list[str],
+ expected: list[str],
+) -> None:
+ launch = _subparsers(_build_parser())["launch"]
+ parser = _subparsers(launch)["openclaw"]
+ args = parser.parse_args(["--model", "switchyard", *agent_args])
+
+ command = _openclaw_command("openclaw", strip_forwarded_args(args.openclaw_args))
+
+ assert command == expected
+
+
def test_default_config_is_packaged_openrouter_deployment() -> None:
config = _config_path(None)
assert config.name == "openrouter.toml"