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

# Prepare Context • Rust AI Agent SDK

> prepare_context: Prepare context data for handoff based on context policy

# prepare\_context

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**Handoff**](../classes/Handoff) class in the [**handoff**](../modules/handoff) module.

Prepare context data for handoff based on context policy

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def prepare_context(
        &self,
        messages: Vec<serde_json::Value>,
        source_agent: &str,
        chain: &HandoffChain,
        extra_context: HashMap<String, serde_json::Value>,
    ) -> HandoffInputData
```

## Parameters

<ParamField query="messages" type="Vec<serde_json::Value>" required={true}>
  No description available.
</ParamField>

<ParamField query="source_agent" type="&str" required={true}>
  No description available.
</ParamField>

<ParamField query="chain" type="&HandoffChain" required={true}>
  No description available.
</ParamField>

<ParamField query="extra_context" type="HashMap<String" required={true}>
  No description available.
</ParamField>

<ParamField query="serde_json" type=":Value>" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="HandoffInputData">
  The result of the operation.
</ResponseField>

***

## 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" />
</CardGroup>
