# LLM Kit Chain of Thought

When an agent takes multiple steps to answer a question—searching the web, analyzing documents, or querying a database—a single reasoning block cannot show how the work is structured in detail. Use the ChainOfThought component to make each operation visible in sequence.

The [ChainOfThought component](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthought) renders each operation as a named row under one collapsible header. This format helps users follow the sequence of the agent's work and gives you control over how each step appears.

The following example demonstrates the ChainOfThought component displaying a step-by-step sequence of operations.

[Demo Source](https://demos.telerik.com/kendo-react-ui/conversational-ui/llm-kit/chain-of-thought/source.txt)

## Rendering Thought Rows

The [`thoughts`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#thoughts) prop accepts an ordered array of [`Thought`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought) objects. Add a new thought when its operation starts, then update its [`label`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought#label) and [`completed`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought#completed) values as the operation progresses.

Each thought can include supporting context through [`secondaryLabel`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought#secondarylabel), detailed output through [`content`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought#content), and an operation icon through [`svgIcon`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought#svgicon).

```tsx ChainOfThought
<ChainOfThought
    svgIcon={brainIcon}
    label="Thought"
    secondaryLabel="for 6.0s"
    thoughts={thoughts}
    expandable
/>
```

```tsx Thoughts
const thoughts: Thought[] = [
    { label: 'Analyzing query intent', content: null, svgIcon: searchIcon, completed: true },
    {
        label: 'Selecting relevant tables',
        content: null,
        secondaryLabel: '3 found',
        svgIcon: tableIcon,
        completed: true
    },
    { label: 'Building SQL query', content: 'GROUP BY customer_name ORDER BY total DESC', svgIcon: codeIcon }
];
```

The component-level [`label`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#label) and [`secondaryLabel`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#secondarylabel) props describe the chain as a whole. Use them for a concise summary that remains visible when the thought rows are collapsed.

## Showing Chain Progress

After the final operation completes, set [`completed`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#completed) to `true`. The header then replaces its in-progress shimmering effect with the completed presentation.

For coding workflows, [`linesAdded`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#linesadded) and [`linesRemoved`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#linesremoved) expose diff counters directly in the header so reviewers can see the scope of a change at a glance. Leave these props unset for workflows that do not report line changes.

Use [`expanded`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#expanded) with [`onExpandedChange`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#onexpandedchange) when application state needs to control the disclosure of the chain.

```tsx
<ChainOfThought
    thoughts={thoughts}
    completed={isComplete}
    linesAdded={12}
    linesRemoved={3}
    expanded={isExpanded}
    onExpandedChange={(event) => setIsExpanded(event.expanded)}
/>
```

## Customizing the Thoughts

If the default row layout does not suit your needs, you can provide a custom template for each [`Thought`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thought) item. The [`thoughtTemplate`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthoughtprops#thoughttemplate) prop accepts a React component that receives each thought's data via [`ThoughtTemplateProps`](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/thoughttemplateprops), giving you full control over the presentation of the reasoning process.

The following example demonstrates a custom template that includes a color-coded kind pill, the tool name, and the execution duration for each step in the chain of thought.

[Demo Source](https://demos.telerik.com/kendo-react-ui/conversational-ui/llm-kit/chain-of-thought-custom-template/source.txt)

## Suggested Links

* [LLM Kit Overview](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/llm-kit)
* [Reasoning](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/llm-kit/reasoning)
* [API Reference of the ChainOfThought component](https://www.telerik.com/kendo-react-ui-develop/components/conversationalui/api/chainofthought)
