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

# Build Context • AI Agent SDK

> build_context: Build a prepared turn context from agent and request.

# build\_context

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

> This is a method of the [**DefaultTurnContextBuilder**](../classes/DefaultTurnContextBuilder) class in the [**context\_builder**](../modules/context_builder) module.

Build a prepared turn context from agent and request.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def build_context(agent: AgentProtocol, prompt: str) -> PreparedTurnContext
```

## Parameters

<ParamField query="agent" type="AgentProtocol" required={true}>
  The agent instance
</ParamField>

<ParamField query="prompt" type="str" required={true}>
  The user prompt for this turn \*\*kwargs: Additional request parameters including: - model: Override model ID - tools: Override tools list. Omit or pass None to use agent.tools. Pass \[] to explicitly disable tools for this turn. - stream: Enable streaming - temperature: Model temperature - max\_tokens: Token limit - session\_id: Session identifier - turn\_id: Turn identifier
</ParamField>

### Returns

<ResponseField name="Returns" type="PreparedTurnContext">
  A prepared turn context ready for execution
</ResponseField>

## Uses

* `PreparedTurnContext`
* `time.time`
* `logger.debug`
* `context.get_message_count`
* `logger.error`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/runtime/context_builder.py#L48">
  `praisonaiagents/runtime/context_builder.py` at line 48
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Context Concept" icon="layer-group" href="/docs/docs/concepts/context" />

  <Card title="Context Management" icon="sliders" href="/docs/docs/features/context-management" />

  <Card title="Context Strategies" icon="diagram-project" href="/docs/docs/features/context-strategies" />
</CardGroup>
