> ## 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.

# Budget Allocation • Rust AI Agent SDK

> BudgetAllocation: Budget allocation for different context components.

# BudgetAllocation

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

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

Budget allocation for different context components.

## Fields

| Name             | Type    | Description                     |
| ---------------- | ------- | ------------------------------- |
| `total`          | `usize` | Total budget in tokens          |
| `system`         | `usize` | Budget for system prompt        |
| `history`        | `usize` | Budget for conversation history |
| `tools`          | `usize` | Budget for tools                |
| `output_reserve` | `usize` | Reserved for output             |

## Methods

### `new`

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

Create a new budget allocation

**Parameters:**

| Name    | Type    |
| ------- | ------- |
| `total` | `usize` |

### `with_ratios`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_ratios(total: usize, system_pct: f64, history_pct: f64, tools_pct: f64) -> Self
```

Create with custom ratios

**Parameters:**

| Name          | Type    |
| ------------- | ------- |
| `total`       | `usize` |
| `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#L146">
  `praisonai/src/context/mod.rs` at line 146
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Budget" icon="wallet" href="/docs/rust/budget" />

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