From 07df3dc1327929ba4305d912005af8b0d39b47ad Mon Sep 17 00:00:00 2001 From: ajay-kesavan Date: Fri, 15 May 2026 15:03:23 -0700 Subject: [PATCH] feat(eval): add --simulation flag to uipath debug Mirrors the --simulation flag from `uipath run` (#1624) onto `uipath debug`, so simulation configs can be passed inline as JSON without needing a simulation.json on disk. When --simulation is omitted, the existing simulation.json fallback is preserved. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/uipath/src/uipath/_cli/cli_debug.py | 33 +++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/uipath/src/uipath/_cli/cli_debug.py b/packages/uipath/src/uipath/_cli/cli_debug.py index cd9042b78..15b5ea6e5 100644 --- a/packages/uipath/src/uipath/_cli/cli_debug.py +++ b/packages/uipath/src/uipath/_cli/cli_debug.py @@ -3,13 +3,18 @@ from typing import cast, get_args import click +from pydantic import ValidationError from uipath._cli._chat._bridge import get_chat_bridge from uipath._cli._debug._bridge import DebugAttachMode, get_debug_bridge from uipath._cli._utils._debug import setup_debugging from uipath._cli._utils._studio_project import StudioClient from uipath.core.tracing import UiPathTraceManager -from uipath.eval.mocks import UiPathMockRuntime +from uipath.eval.mocks import ( + SimulationConfig, + UiPathMockRuntime, + build_mocking_context, +) from uipath.eval.mocks._mock_runtime import load_simulation_config from uipath.platform.common import ResourceOverwritesContext, UiPathConfig from uipath.runtime import ( @@ -74,6 +79,12 @@ "'console' for local runs." ), ) +@click.option( + "--simulation", + required=False, + default=None, + help="Simulation config as a JSON object (same schema as simulation.json)", +) @track_command("debug") def debug( entrypoint: str | None, @@ -85,6 +96,7 @@ def debug( debug: bool, debug_port: int, attach: str | None, + simulation: str | None, ) -> None: """Debug the project.""" input_file = file or input_file @@ -96,6 +108,14 @@ def debug( cast(DebugAttachMode, attach.lower()) if attach else None ) + simulation_config: SimulationConfig | None = None + if simulation: + try: + simulation_config = SimulationConfig.model_validate_json(simulation) + except (ValidationError, ValueError) as e: + console.error(f"Invalid --simulation config: {e}") + return + result = Middlewares.next( "debug", entrypoint, @@ -188,9 +208,14 @@ async def execute_debug_runtime(): if schema.metadata and "settings" in schema.metadata: agent_model = schema.metadata["settings"].get("model") - mocking_context = load_simulation_config( - agent_model=agent_model - ) + if simulation_config: + mocking_context = build_mocking_context( + simulation_config, agent_model + ) + else: + mocking_context = load_simulation_config( + agent_model=agent_model + ) mock_runtime = UiPathMockRuntime( delegate=debug_runtime,