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

# Chat With Context • AI Agent SDK

> chat_with_context: Chat with pre-retrieved context.

# chat\_with\_context

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

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

Chat with pre-retrieved context.

This method allows AutoRagAgent or manual workflows to inject
pre-retrieved context into the agent's chat, enabling conditional
retrieval without duplicating RAG logic.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def chat_with_context(message: str, context: 'ContextPack') -> str
```

## Parameters

<ParamField query="message" type="str" required={true}>
  User message/question
</ParamField>

<ParamField query="context" type="ContextPack" required={true}>
  ContextPack from RAG.retrieve()
</ParamField>

### Returns

<ResponseField name="Returns" type="str">
  Agent response with optional citations
</ResponseField>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import AutoRagAgent

    auto_rag = AutoRagAgent(agent=my_agent)
    result = auto_rag.chat("What are the key findings?")

    # Or manually:
    context_pack = rag.retrieve("What are the key findings?")
    response = agent.chat_with_context("What are the key findings?", context_pack)
```

## Uses

* `chat`

## Used By

* [`AutoRagAgent.chat`](../functions/AutoRagAgent-chat)

## Source

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

***

## Related Documentation

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

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

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

  <Card title="Chat Feature" icon="comments" href="/docs/features/chat" />

  <Card title="Conversation Stores" icon="database" href="/docs/databases/overview" />
</CardGroup>
