> This page is for version Latest (default).
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.25.0: https://docs.nvidia.com/nemo/guardrails/v0.25.0/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> 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.

# nemoguardrails.library.cel.actions

## Module Contents

### Functions

| Name                                                                                       | Description                                                                                            |
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| [`_evaluate`](#nemoguardrails-library-cel-actions-_evaluate)                               | Evaluate all of a tool's CEL expressions, blocking when any is true.                                   |
| [`_program`](#nemoguardrails-library-cel-actions-_program)                                 | The compiled program for *expression*, cached outside the config (see CelOptions.compile_expressions). |
| [`_tool_options`](#nemoguardrails-library-cel-actions-_tool_options)                       | Return the tool's CEL options for *source*.                                                            |
| [`evaluate_tool_call_cel`](#nemoguardrails-library-cel-actions-evaluate_tool_call_cel)     | Checks a tool call's arguments against that tool's CEL expressions.                                    |
| [`evaluate_tool_result_cel`](#nemoguardrails-library-cel-actions-evaluate_tool_result_cel) | Checks a tool result's content against that tool's CEL expressions.                                    |

### Data

[`log`](#nemoguardrails-library-cel-actions-log)

### API

```python
nemoguardrails.library.cel.actions._evaluate(
    source: str,
    tool_name: str,
    variables: typing.Dict[str, typing.Any],
    options: nemoguardrails.library.cel.rail_config.CelOptions
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

Evaluate all of a tool's CEL expressions, blocking when any is true.

A failing expression (an error or a non-boolean result) raises even if another expression
matched, so the rail fails closed.

```python
nemoguardrails.library.cel.actions._program(
    expression: str
) -> cel.Program
```

The compiled program for *expression*, cached outside the config (see CelOptions.compile_expressions).

```python
nemoguardrails.library.cel.actions._tool_options(
    config: nemoguardrails.RailsConfig,
    source: str,
    tool_name: str
) -> nemoguardrails.library.cel.rail_config.CelOptions
```

Return the tool's CEL options for *source*.

Raises when none are configured, so the rail fails closed: a tool the CEL rail runs for
with no expressions to check cannot be validated.

```python
nemoguardrails.library.cel.actions.evaluate_tool_call_cel(
    source: str,
    tool_call: nemoguardrails.types.ToolCall,
    tool_definition: typing.Optional[nemoguardrails.guardrails.tool_schema.Tool],
    config: nemoguardrails.RailsConfig,
    kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

async

Checks a tool call's arguments against that tool's CEL expressions.

**Parameters:**

**`source`** `str`

Fixed per surface, always "tool_call".

---

**`tool_call`** `ToolCall`

[`ToolCall`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/types#nemoguardrails-types-ToolCall) — The tool call to check. Its arguments are `args` and its name is `tool`.

---

**`tool_definition`** `Optional[Tool]`

`Optional[` [`Tool`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/guardrails/tool_schema#nemoguardrails-guardrails-tool_schema-Tool) `]` — The declared tool, used only by @tool_call_validation to check
the call's arguments against its schema before this function runs.

---

**`config`** `RailsConfig`

[`RailsConfig`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/rails/llm/config#nemoguardrails-rails-llm-config-RailsConfig) — The rails configuration object.

---

**Returns:** [`RailOutcome`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/actions/rail_outcome#nemoguardrails-actions-rail_outcome-RailOutcome)

RailOutcome that blocks when any expression is true, with the matched expressions in

```python
nemoguardrails.library.cel.actions.evaluate_tool_result_cel(
    source: str,
    tool_call: nemoguardrails.types.ToolCall,
    tool_result: nemoguardrails.guardrails.tool_schema.ToolResult,
    config: nemoguardrails.RailsConfig,
    kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

async

Checks a tool result's content against that tool's CEL expressions.

**Parameters:**

**`source`** `str`

Fixed per surface, always "tool_result".

---

**`tool_call`** `ToolCall`

[`ToolCall`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/types#nemoguardrails-types-ToolCall) — The prior call this result answers. Its arguments are `args` and its name
is `tool`.

---

**`tool_result`** `ToolResult`

[`ToolResult`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/guardrails/tool_schema#nemoguardrails-guardrails-tool_schema-ToolResult) — The tool result to check. Its content is `result`, as the tool returned it.

---

**`config`** `RailsConfig`

[`RailsConfig`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/rails/llm/config#nemoguardrails-rails-llm-config-RailsConfig) — The rails configuration object.

---

**Returns:** [`RailOutcome`](/nemo/guardrails/guardrails-python-sdk/nemoguardrails/actions/rail_outcome#nemoguardrails-actions-rail_outcome-RailOutcome)

RailOutcome that blocks when any expression is true, with the matched expressions in

```python
nemoguardrails.library.cel.actions.log = logging.getLogger(__name__)
```