> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Config • Rust AI Agent SDK

> ContextConfig: Configuration for context management.

# ContextConfig

> Defined in the [**context**](../modules/context) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Configuration for context management.

## Fields

| Name                 | Type                | Description                                  |
| -------------------- | ------------------- | -------------------------------------------- |
| `model`              | `String`            | Model name for token limits                  |
| `max_tokens`         | `usize`             | Maximum context tokens (0 = auto from model) |
| `strategy`           | `OptimizerStrategy` | Optimization strategy                        |
| `monitoring`         | `bool`              | Enable context monitoring                    |
| `output_reserve_pct` | `f64`               | Output reserve percentage                    |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> Self
```

Create a new context config

### `model`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn model(mut self, model: impl Into<String>) -> Self
```

Set model

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `model` | `impl Into&lt;String&gt;` |

### `max_tokens`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn max_tokens(mut self, tokens: usize) -> Self
```

Set max tokens

**Parameters:**

| Name     | Type    |
| -------- | ------- |
| `tokens` | `usize` |

### `strategy`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn strategy(mut self, strategy: OptimizerStrategy) -> Self
```

Set optimization strategy

**Parameters:**

| Name       | Type                |
| ---------- | ------------------- |
| `strategy` | `OptimizerStrategy` |

### `with_monitoring`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_monitoring(mut self) -> Self
```

Enable monitoring

### `output_reserve_pct`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn output_reserve_pct(mut self, pct: f64) -> Self
```

Set output reserve percentage

**Parameters:**

| Name  | Type  |
| ----- | ----- |
| `pct` | `f64` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/context/mod.rs#L194">
  `praisonai/src/context/mod.rs` at line 194
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Context Management" icon="layer-group" href="/docs/rust/context-management" />

  <Card title="Rust Token Management" icon="coins" href="/docs/rust/token-management" />

  <Card title="Rust Configuration" icon="gear" href="/docs/rust/configuration" />

  <Card title="Rust Installation" icon="download" href="/docs/rust/installation" />
</CardGroup>
