> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# setToolResponse

> Split the response into a factual result and an instruction.

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

[setresponse]: /docs/server-sdks/reference/typescript/agents/function-result/set-response

Set the structured form of the response, separating what the tool did from what
the model should do next. It replaces any string response, and the response
becomes an object with up to two keys:

```json
{
  "tool_result": "status: on hold",
  "tool_prompt": "Tell the caller you are placing them on hold."
}
```

Splitting them keeps the model from reading a status line aloud, and keeps the
instruction from being mistaken for data. For a single string, use
[`setResponse()`][setresponse].

You can also set the structured form when you create the result:
`new FunctionResult({ tool_result: '...', tool_prompt: '...' })`.

## **Parameters**

**`toolResult`** `string`

What the tool did or found: facts for the model to reason from, such as
`"payment declined"` or `"3 seats left"`. Omit it when there is nothing to
report beyond the instruction.

---

**`toolPrompt`** `string`

What the model should do next, such as `"Tell the caller how many seats are
  left."`. Omit it for a facts-only result.

---

## **Returns**

[`FunctionResult`][functionresult] -- `this`, for chaining.

## **Example**

```typescript {11-14}
import { AgentBase, FunctionResult } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'my-agent', route: '/agent' });
agent.setPromptText('You are a helpful assistant.');

agent.defineTool({
  name: 'check_seats',
  description: 'Check remaining seats for a showing',
  handler: () => {
    const seats = 3; // look this up in your booking system
    return new FunctionResult().setToolResponse(
      `seats remaining: ${seats}`,
      'Tell the caller how many seats are left and ask how many they want.',
    );
  },
});

agent.run();
```