# ISessionTrimmingService

Namespace: **Wisej.AI.Services**

Assembly: **Wisej.AI** (3.5.0.0)

Provides functionality to trim messages in a session to reduce the number of tokens.

{% tabs %}
{% tab title="C#" %}

```csharp
public interface ISessionTrimmingService
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Interface ISessionTrimmingService
```

{% endtab %}
{% endtabs %}

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) TrimmingPercentage

[Single](https://docs.microsoft.com/dotnet/api/system.single): Gets or sets the percentage of messages to remove (between 0.1 and 0.9).

### ![](/files/ptrKjmmRoQB76pvrIqh0) TrimmingStrategy

[TrimmingStrategy](/ai/components/api/smartsession/wisej.ai.smartsession.trimmingstrategy.md): Gets or sets the strategy for handling context overflow.

## Methods

### ![](/files/ptrKjmmRoQB76pvrIqh0) TrimAsync(session, messages)

Trims the messages in the *session* to reduce the number of tokens.

| Parameter                                     | Type                                                                                            | Description                                                                        |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **session**                                   | [SmartSession](/ai/components/api/smartsession.md)                                              | The SmartSession to be trimmed.                                                    |
| **messages** ![](/files/52BqKf9SltWQ97FbQSBF) | [MessageCollection](/ai/components/api/smartsession/wisej.ai.smartsession.messagecollection.md) | Message collection to be trimmed. If null, it uses the messages in the *session* . |

**Returns:** [Task](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task).

## Implemented By

| Name                                                                                                          | Description                                                                          |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [DefaultSessionTrimmingService](https://docs.wisej.com/api?q=wisej.ai.services.defaultsessiontrimmingservice) | Provides functionality to trim messages in a session to reduce the number of tokens. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/api/services/isessiontrimmingservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
