> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-turn Conversation (Interactions)

> Persist previous_interaction_id across turns with a database so GeminiInteractions keeps context server-side.

The Interactions API keeps conversation history server-side. After the first turn, the model sends only the new message and references the prior turn via `previous_interaction_id`. Multi-turn needs a database so the interaction ID from each response is persisted and read back on the next turn.

## Code

```python multi_turn.py theme={null}
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.google import GeminiInteractions

agent = Agent(
    model=GeminiInteractions(id="gemini-3.5-flash"),
    add_history_to_context=True,
    db=SqliteDb(db_file="tmp/data.db"),
    markdown=True,
)

if __name__ == "__main__":
    # First turn - establishes the interaction
    agent.print_response("My name is Alice and I love hiking in the mountains.")

    # Second turn - references the previous interaction for context
    agent.print_response("What did I just tell you about myself?")

    # Third turn - continues the conversation chain
    agent.print_response(
        "Suggest a hiking destination based on what you know about me."
    )
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Set your API key">
    ```bash theme={null}
    export GOOGLE_API_KEY=xxx
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "google-genai>=2.0" sqlalchemy agno
    ```
  </Step>

  <Step title="Run Agent">
    Save the code above as `multi_turn.py`, then run:

    ```bash theme={null}
    python multi_turn.py
    ```
  </Step>
</Steps>
