> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.colang.v2_x.runtime.runtime

## Module Contents

### Classes

| Name                                                                     | Description                           |
| ------------------------------------------------------------------------ | ------------------------------------- |
| [`RuntimeV2_x`](#nemoguardrails-colang-v2_x-runtime-runtime-RuntimeV2_x) | Runtime for executing the guardrails. |

### Functions

| Name                                                                                                                       | Description                                                                                     |
| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| [`convert_decorator_list_to_dictionary`](#nemoguardrails-colang-v2_x-runtime-runtime-convert_decorator_list_to_dictionary) | Convert list of decorators to a dictionary merging the parameters of decorators with same name. |
| [`create_flow_configs_from_flow_list`](#nemoguardrails-colang-v2_x-runtime-runtime-create_flow_configs_from_flow_list)     | Create a flow config dictionary and resolves flow overriding.                                   |

### Data

[`log`](#nemoguardrails-colang-v2_x-runtime-runtime-log)

### API

```python
class nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x(
    config: nemoguardrails.rails.llm.config.RailsConfig,
    verbose: bool = False
)
```

**Bases:** [Runtime](/guardrails-python-sdk/nemoguardrails/colang/runtime#nemoguardrails-colang-runtime-Runtime)

Runtime for executing the guardrails.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._add_flows_action(
    state: nemoguardrails.colang.v2_x.runtime.statemachine.State,
    args: dict = {}
) -> typing.List[str]
```

async

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._get_action_finished_event(
    result: dict,
    kwargs = {}
) -> typing.Dict[str, typing.Any]
```

staticmethod

Helper to return the ActionFinished event from the result of running a local action.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._get_action_resp(
    action_meta: typing.Dict[str, typing.Any],
    action_name: str,
    kwargs: typing.Dict[str, typing.Any]
) -> typing.Tuple[typing.Union[str, typing.Dict[str, typing.Any]], str]
```

async

Interact with actions and get response from action-server and system actions.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._get_async_actions_finished_events(
    main_flow_uid: str
) -> typing.Tuple[typing.List[dict], int]
```

async

Helper to return the ActionFinished events for the local async actions that finished.

Args
main\_flow\_uid: The UID of the main flow.

Returns
(action\_finished\_events, pending\_counter)
The array of \*ActionFinished events and the pending counter

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._init_flow_configs() -> None
```

Initializes the flow configs based on the config.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._internal_error_action_result(
    message: str
) -> nemoguardrails.actions.actions.ActionResult
```

staticmethod

Helper to construct an action result for an internal error.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._process_start_action(
    action_name: str,
    action_params: dict,
    context: dict,
    events: typing.List[dict],
    state: nemoguardrails.colang.v2_x.runtime.statemachine.State
) -> typing.Tuple[typing.Any, typing.List[dict], dict]
```

async

Starts the specified action, waits for it to finish and posts back the result.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._remove_flows_action(
    state: nemoguardrails.colang.v2_x.runtime.statemachine.State,
    args: dict = {}
) -> None
```

async

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x._run_action(
    action_name: str,
    start_action_event: dict,
    events_history: typing.List[typing.Union[dict, nemoguardrails.colang.v2_x.runtime.flows.Event]],
    state: nemoguardrails.colang.v2_x.runtime.statemachine.State
) -> dict
```

async

Runs the locally registered action.

Args
action\_name: The name of the action to be executed.
start\_action\_event: The event that triggered the action.
events\_history: The recent history of events that led to the action being triggered.

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x.generate_events(
    events: typing.List[dict]
) -> typing.List[dict]
```

async

```python
nemoguardrails.colang.v2_x.runtime.runtime.RuntimeV2_x.process_events(
    events: typing.List[dict],
    state: typing.Union[typing.Optional[dict], nemoguardrails.colang.v2_x.runtime.statemachine.State] = None,
    blocking: bool = False,
    instant_actions: typing.Optional[typing.List[str]] = None
) -> typing.Tuple[typing.List[typing.Dict[str, typing.Any]], nemoguardrails.colang.v2_x.runtime.statemachine.State]
```

async

Process a sequence of events in a given state.

Runs an "event processing cycle", i.e., process all input events in the given state, and
return the new state and the output events.

The events will be processed one by one, in the input order. If new events are
generated as part of the processing, they will be appended to the input events.

By default, a processing cycle only waits for the local actions to finish, i.e,
if after processing all the input events, there are local actions in progress, the
event processing will wait for them to finish.

In blocking mode, the event processing will also wait for the local async actions.

**Parameters:**

A sequence of events that needs to be processed.

The state that should be used as the starting point. If not provided,
a clean state will be used.

If set, in blocking mode, the processing cycle will wait for
all the local async actions as well.

The name of the actions which should finish instantly, i.e.,
the start event will not be returned to the user and wait for the finish event.

**Returns:** `Tuple[List[Dict[str, Any]], State]`

(output\_events, output\_state) Returns a sequence of output events and an output
state.

```python
nemoguardrails.colang.v2_x.runtime.runtime.convert_decorator_list_to_dictionary(
    decorators: typing.List[nemoguardrails.colang.v2_x.lang.colang_ast.Decorator]
) -> typing.Dict[str, typing.Dict[str, typing.Any]]
```

Convert list of decorators to a dictionary merging the parameters of decorators with same name.

```python
nemoguardrails.colang.v2_x.runtime.runtime.create_flow_configs_from_flow_list(
    flows: typing.List[nemoguardrails.colang.v2_x.lang.colang_ast.Flow]
) -> typing.Dict[str, nemoguardrails.colang.v2_x.runtime.statemachine.FlowConfig]
```

Create a flow config dictionary and resolves flow overriding.

```python
nemoguardrails.colang.v2_x.runtime.runtime.log = logging.getLogger(__name__)
```