***

title: replaceInHistory
slug: /reference/typescript/agents/function-result/replace-in-history
description: Control how this function call appears in the AI's conversation history.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

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

Control how this function call appears in the AI's conversation history. Use
this to remove sensitive information (credit card numbers, SSNs) or replace
verbose tool results with concise summaries.

<Note>
  When `true` is passed, the entire tool-call/result pair is removed from history.
  When a string is passed, the pair is replaced with that text as an assistant message.
</Note>

## **Parameters**

<ParamField path="text" type="string | boolean" default="true" toc={true}>
  * `true` — remove the tool-call and result pair from history entirely
  * A `string` -- replace the pair with an assistant message containing this text
</ParamField>

## **Returns**

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

## **Examples**

### Remove Sensitive Exchange

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult('Order checked.')
  .replaceInHistory();
```

### Replace with Summary

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult('Sensitive data retrieved.')
  .replaceInHistory('Data was retrieved successfully.');
```