# InteractionContextSettings

How an interaction keeps its conversation within the model's context window, and how many rounds of tool calls an agent may make in one turn.

**Kind:** an object, used in requests and responses. In a request it is called `InteractionContextSettingsInput`.

## In a request

| Field | Type | Required | Description |
|---|---|---|---|
| `mode` | [`ContextTrimmingMode`](https://docs.maitento.com/reference/types/context-trimming-mode.md) |  | What happens when the conversation no longer fits the model's context window. |
| `targetUtilization` | `number` |  | How full the context window may get, as a fraction from 0 to 1, before the conversation is shortened. |
| `toolResultTrimmingMode` | [`ToolResultTrimmingMode`](https://docs.maitento.com/reference/types/tool-result-trimming-mode.md) |  | When the results of earlier tool calls are replaced, to save space. |
| `toolResultTrimmingMaxCycles` | `integer \| null` |  | With `toolResultTrimmingMode` set to `AfterCycles` or `Both`: once an agent has had this many turns, every tool result but the latest is replaced. |
| `toolResultTrimmingStyle` | [`ToolResultTrimmingStyle`](https://docs.maitento.com/reference/types/tool-result-trimming-style.md)`\| null` |  | What a replaced tool result becomes. Null: `Placeholder`. |
| `toolResultTrimmingReplacement` | `string` |  | The text a replaced tool result becomes, with the `Placeholder` style. |
| `compactionType` | [`CompactionType`](https://docs.maitento.com/reference/types/compaction-type.md)`\| null` |  | Whether, and how, older parts of a long conversation are summarised to make room. Suits long, many-turn conversations such as chats. Null: no summaries (`None`). |
| `lowWaterUtilization` | `number \| null` |  | With compaction on: how far a forced trim shortens the conversation, as a fraction of the context window from 0 to 1, so that it is not trimmed again on the very next turn. Null: 0.2. Never more than `targetUtilization`. |
| `compactAtUtilization` | `number` |  | How full the context window gets, as a fraction from 0 to 1, before the conversation is summarised (0.85 is 85% full). |
| `compactKeepRecentTokens` | `integer` |  | The most recent part of the conversation kept word for word when it is summarised, in tokens. |
| `compactTargetTokens` | `integer` |  | The length the summary aims for, in tokens. `compactMaxTokens` is the hard limit. |
| `maxToolCallLoops` | `integer \| null` |  | The most rounds of tool calls an agent may make in one turn. After that its tools are withheld and it is told to answer. `0` means no limit; null means 10. |
| `responseMaxTokens` | `integer \| null` |  | The most the model may write in one reply, in tokens, including any reasoning; that much of the context window is kept free for the reply. Null or `0` allows the model's maximum. A value above the model's maximum is lowered to it. |
| `compactMaxTokens` | `integer \| null` |  | The most a summary may be, in tokens, when compaction is on. Null: 40,000. A value above the model's maximum is lowered to it. |

```json
{
  "mode": "None",
  "targetUtilization": 0,
  "toolResultTrimmingMode": "Never",
  "toolResultTrimmingMaxCycles": 0,
  "toolResultTrimmingStyle": "Placeholder",
  "toolResultTrimmingReplacement": "...",
  "compactionType": "SameAgent",
  "lowWaterUtilization": 0,
  "compactAtUtilization": 0,
  "compactKeepRecentTokens": 0,
  "compactTargetTokens": 0,
  "maxToolCallLoops": 0,
  "responseMaxTokens": 0,
  "compactMaxTokens": 0
}
```

## In a response

Every field is present in a response; empty ones are `null`.

| Field | Type | Description |
|---|---|---|
| `mode` | [`ContextTrimmingMode`](https://docs.maitento.com/reference/types/context-trimming-mode.md) | What happens when the conversation no longer fits the model's context window. |
| `targetUtilization` | `number` | How full the context window may get, as a fraction from 0 to 1, before the conversation is shortened. |
| `toolResultTrimmingMode` | [`ToolResultTrimmingMode`](https://docs.maitento.com/reference/types/tool-result-trimming-mode.md) | When the results of earlier tool calls are replaced, to save space. |
| `toolResultTrimmingMaxCycles` | `integer \| null` | With `toolResultTrimmingMode` set to `AfterCycles` or `Both`: once an agent has had this many turns, every tool result but the latest is replaced. |
| `toolResultTrimmingStyle` | [`ToolResultTrimmingStyle`](https://docs.maitento.com/reference/types/tool-result-trimming-style.md)`\| null` | What a replaced tool result becomes. Null: `Placeholder`. |
| `effectiveToolResultTrimmingStyle` | [`ToolResultTrimmingStyle`](https://docs.maitento.com/reference/types/tool-result-trimming-style.md) | The style actually used: `toolResultTrimmingStyle`, or `Placeholder` when that is null. Set by Maitento. |
| `toolResultTrimmingReplacement` | `string` | The text a replaced tool result becomes, with the `Placeholder` style. |
| `compactionType` | [`CompactionType`](https://docs.maitento.com/reference/types/compaction-type.md)`\| null` | Whether, and how, older parts of a long conversation are summarised to make room. Suits long, many-turn conversations such as chats. Null: no summaries (`None`). |
| `effectiveCompactionType` | [`CompactionType`](https://docs.maitento.com/reference/types/compaction-type.md) | The compaction actually used: `compactionType`, or `None` when that is null. Set by Maitento. |
| `lowWaterUtilization` | `number \| null` | With compaction on: how far a forced trim shortens the conversation, as a fraction of the context window from 0 to 1, so that it is not trimmed again on the very next turn. Null: 0.2. Never more than `targetUtilization`. |
| `effectiveLowWaterUtilization` | `number` | The low-water mark actually used: `lowWaterUtilization` when it is above 0 and at most 1, otherwise 0.2; never more than `targetUtilization`. Set by Maitento. |
| `compactAtUtilization` | `number` | How full the context window gets, as a fraction from 0 to 1, before the conversation is summarised (0.85 is 85% full). |
| `compactKeepRecentTokens` | `integer` | The most recent part of the conversation kept word for word when it is summarised, in tokens. |
| `compactTargetTokens` | `integer` | The length the summary aims for, in tokens. `compactMaxTokens` is the hard limit. |
| `maxToolCallLoops` | `integer \| null` | The most rounds of tool calls an agent may make in one turn. After that its tools are withheld and it is told to answer. `0` means no limit; null means 10. |
| `effectiveMaxToolCallLoops` | `integer` | The limit actually applied: `maxToolCallLoops`, or 10 when that is null. `0` means no limit. Set by Maitento. |
| `responseMaxTokens` | `integer \| null` | The most the model may write in one reply, in tokens, including any reasoning; that much of the context window is kept free for the reply. Null or `0` allows the model's maximum. A value above the model's maximum is lowered to it. |
| `compactMaxTokens` | `integer \| null` | The most a summary may be, in tokens, when compaction is on. Null: 40,000. A value above the model's maximum is lowered to it. |

```json
{
  "mode": "None",
  "targetUtilization": 0,
  "toolResultTrimmingMode": "Never",
  "toolResultTrimmingMaxCycles": 0,
  "toolResultTrimmingStyle": "Placeholder",
  "effectiveToolResultTrimmingStyle": "Placeholder",
  "toolResultTrimmingReplacement": "...",
  "compactionType": "SameAgent",
  "effectiveCompactionType": "SameAgent",
  "lowWaterUtilization": 0,
  "effectiveLowWaterUtilization": 0,
  "compactAtUtilization": 0,
  "compactKeepRecentTokens": 0,
  "compactTargetTokens": 0,
  "maxToolCallLoops": 0,
  "effectiveMaxToolCallLoops": 0,
  "responseMaxTokens": 0,
  "compactMaxTokens": 0
}
```

## Where it's used

- Inside [`ManagedInteractionCreateRequest`](https://docs.maitento.com/reference/types/managed-interaction-create-request.md)
- Inside [`ManagedInteractionUpdateRequest`](https://docs.maitento.com/reference/types/managed-interaction-update-request.md)
- Inside [`ManagedInteractionVersion`](https://docs.maitento.com/reference/types/managed-interaction-version.md)
- Inside [`OneShotInteractionCreateRequest`](https://docs.maitento.com/reference/types/one-shot-interaction-create-request.md)
- Inside [`OneShotInteractionUpdateRequest`](https://docs.maitento.com/reference/types/one-shot-interaction-update-request.md)
- Inside [`OneShotInteractionVersion`](https://docs.maitento.com/reference/types/one-shot-interaction-version.md)
- Inside [`RoundRobinInteractionCreateRequest`](https://docs.maitento.com/reference/types/round-robin-interaction-create-request.md)
- Inside [`RoundRobinInteractionUpdateRequest`](https://docs.maitento.com/reference/types/round-robin-interaction-update-request.md)
- Inside [`RoundRobinInteractionVersion`](https://docs.maitento.com/reference/types/round-robin-interaction-version.md)
