replaceInHistory

View as MarkdownOpen in Claude

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.

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.

Parameters

text
string | booleanDefaults to true
  • true — remove the tool-call and result pair from history entirely
  • A string — replace the pair with an assistant message containing this text

Returns

FunctionResultthis, for chaining.

Examples

Remove Sensitive Exchange

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult('Order checked.')
4 .replaceInHistory();

Replace with Summary

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult('Sensitive data retrieved.')
4 .replaceInHistory('Data was retrieved successfully.');