Skip to main content
Thinking states are a great way to let the user know what the model is doing. This is especially useful for long-running tasks or when the user is waiting for a response, such as when the agent is performing a slow tool call.
The @thesysai/genui-sdk package provides a makeC1Response function that can be used to add data related to thinking states to the response.Here’s a simple example of how to use thinking states:
1

Create a c1Response object

Use the makeC1Response function to create a c1Response object by importing it from the @thesysai/genui-sdk package, and start writing the LLM response content to this object:
app/api/chat/route.ts
2

Write a thinking state to the response object

To add a thinking state, use the writeThinkItem method defined on the c1Response object:
app/api/chat/route.ts
3

Use thinking states with long-running tool calls (optional)

If you’d like to use thinking states with long-running tool calls, simply call the aforementioned writeThinkItem method inside the tool call handler. For example, for the webSearch tool implemented in the Tool Calling guide, you can add a thinking state as follows:Next, modify the tool call handler to call a function that updates the thinking state:
app/api/chat/tools.ts
Next, pass the writeThinkingState function to the tool call handler:
app/api/chat/route.ts
app/api/chat/route.ts
4

Add a custom think component (optional)

If you’d like to add a custom thinking state component, you can do so by passing a customizeC1 prop to the C1Chat component or the useThreadManager hook.Your custom component should accept the following props:
thinkItems
ThinkItem[]
An array of thinking state items, where each item contains:
  • title: The title of the thinking state
  • content: The content/description of the thinking state
  • ephemeral: Whether this thinking state should be temporary or persist after the response is done streaming
thinkingInProgress
boolean
Indicates if a thinking state is active. Use this to display a loader or shimmer while processing.
Example custom think component:
You may pass your custom component to the C1Chat component or the useThreadManager hook like this:
5

Test it out

You should now see the thinking state on the UI while the agent is processing the response:
Thinking states sample image