***

title: replace_in_history
slug: /reference/python/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/python/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="str | bool" default="True" toc={true}>
  * `True` — remove the tool-call and result pair from history entirely
  * A `str` — replace the pair with an assistant message containing this text
</ParamField>

## **Returns**

[`FunctionResult`][functionresult] — self, for chaining.

## **Examples**

### Remove Sensitive Exchange

```python {13}
from signalwire import AgentBase
from signalwire import FunctionResult

agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")

@agent.tool(name="verify_identity", description="Verify caller identity")
def verify_identity(args, raw_data):
    ssn = args.get("ssn")
    # ... verify SSN ...
    return (
        FunctionResult("I've verified your identity.")
        .replace_in_history(True)
    )

agent.serve()
```

### Replace with Summary

```python {13}
from signalwire import AgentBase
from signalwire import FunctionResult

agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")

@agent.tool(name="process_payment", description="Process a payment")
def process_payment(args, raw_data):
    card_number = args.get("card_number")
    # ... process payment ...
    return (
        FunctionResult("Payment processed successfully.")
        .replace_in_history("Payment information was collected and processed.")
    )

agent.serve()
```