> ## 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 Budgeter • Rust AI Agent SDK

> ContextBudgeter: Manages context budget allocation.

# ContextBudgeter

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

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

Manages context budget allocation.

## Fields

| Name             | Type     | Description    |
| ---------------- | -------- | -------------- |
| `model`          | `String` | Model name     |
| `max_tokens`     | `usize`  | Maximum tokens |
| `output_reserve` | `usize`  | Output reserve |

## Methods

### `new`

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

Create a new budgeter for a model

**Parameters:**

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

### `with_limits`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_limits(model: impl Into<String>, max_tokens: usize, output_reserve: usize) -> Self
```

Create with custom limits

**Parameters:**

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

### `available`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn available(&self) -> usize
```

Get available tokens (total - output reserve)

### `allocate`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn allocate(&self) -> BudgetAllocation
```

Allocate budget

### `allocate_custom`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn allocate_custom(
        &self,
        system_pct: f64,
        history_pct: f64,
        tools_pct: f64,
    ) -> BudgetAllocation
```

Allocate with custom ratios

**Parameters:**

| Name          | Type  |
| ------------- | ----- |
| `system_pct`  | `f64` |
| `history_pct` | `f64` |
| `tools_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#L359">
  `praisonai/src/context/mod.rs` at line 359
</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 Budget" icon="wallet" href="/docs/rust/budget" />
</CardGroup>
