# ASP.NET Core Tool Call

When agents make decisions that trigger real-world actions, such as querying databases, calling APIs, or browsing the web, users need to know what is being done on their behalf.

The [ToolCall component](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall) makes these side effects visible by displaying the tool name, input parameters, and output result in a collapsible block. It also supports approval and error states so users remain in control.

## Configuration

The [`State`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/state) option controls the visual appearance and the interactive elements that are rendered, so keep it synchronized with your backend. Set it to `Active` when an invocation begins, then change it to `Completed` or `Error` once the result is known.

Use [`Label`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/label) for the tool name and [`SecondaryLabel`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/secondarylabel) for scannable context, such as a database name, file path, or execution time. This lets users assess the call without expanding the details panel. Pair `Icon` or [`StatusSVGIcon`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/statussvgicon) with the state to reinforce the outcome visually.

Bind [`Parameters`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/parameters) to the raw input object and [`Result`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/result) to the output; both render as formatted JSON by default. Use [`ResultTemplate`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/resulttemplate) when a plain JSON dump does not provide enough detail.

```Razor HtmlHelper
    @(Html.Kendo().ToolCall()
        .Name("toolCall")
        .Label("query_database")
        .SecondaryLabel("analytics db")
        .State(ToolCallState.Completed)
        .Expandable(true)
        .Expanded(true)
    )
```

```Razor TagHelper
    <kendo-toolcall name="toolCall"
        label="query_database"
        secondary-label="analytics db"
        state="ToolCallState.Completed"
        expandable="true"
        expanded="true">
    </kendo-toolcall>
```

## Approval Flow

When [`State`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/state) is `AwaitingApproval`, the component renders approval and denial buttons inside the expanded panel. Set [`ApprovalText`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/approvaltext) to explain the action before the user makes a decision.

```Razor HtmlHelper
    @(Html.Kendo().ToolCall()
        .Name("toolCall")
        .Label("send_email")
        .State(ToolCallState.AwaitingApproval)
        .Expandable(true)
        .Expanded(true)
        .ApprovalText("This will send an email to the selected recipients.")
    )
```

```Razor TagHelper
    <kendo-toolcall name="toolCall"
        label="send_email"
        state="ToolCallState.AwaitingApproval"
        expandable="true"
        expanded="true"
        approval-text="This will send an email to the selected recipients.">
    </kendo-toolcall>
```

Handle the user's decision through the [`Action`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/action) event, which emits a `ToolCallActionEvent`.

## Error State

When [`State`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/state) is `Error`, set [`ErrorText`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/errortext) to show a human-readable description of what went wrong. Use [`ErrorTemplate`](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall/errortemplate) to replace the default error message with a custom layout.

```Razor HtmlHelper
    @(Html.Kendo().ToolCall()
        .Name("toolCall")
        .Label("send_email")
        .State(ToolCallState.Error)
        .Expandable(true)
        .Expanded(true)
        .ErrorText("Connection timeout: Unable to reach database server.")
    )
```

```Razor TagHelper
    <kendo-toolcall name="toolCall"
        label="send_email"
        state="ToolCallState.Error"
        expandable="true"
        expanded="true"
        error-text="Connection timeout: Unable to reach database server.">
    </kendo-toolcall>
```

## See Also

* [Tool Call Demo for ASP.NET Core](https://demos.telerik.com/aspnet-core/llm_kit/tool_call)

* [LLM Kit Overview](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/conversational-ui/llm-kit/overview)

* [Server-Side API of the ToolCall HtmlHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/toolcall)

* [Server-Side API of the ToolCall TagHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/taghelpers/toolcall)

* [JavaScript API Reference of the ToolCall](https://www.telerik.com/aspnet-core-ui/documentation/api/ui/toolcall)
