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

# Conversational AI

> The AI Agent side panel — multi-model chat with automatic study context

The AI Agent is a persistent side panel inside every study that combines multi-model chat, a prompt library, and pathway-editing tools in one place.

## Opening the Side Panel

Click the **AI Agent** button in the study toolbar. The panel opens on the right and stays open as you navigate — your open chat, selected model, and attached context persist until you explicitly reset.

The panel has three tabs:

| Tab         | Purpose                                            |
| ----------- | -------------------------------------------------- |
| **Agent**   | The chat interface itself                          |
| **Prompts** | A library of pre-built prompts grouped by category |
| **Models**  | Per-chat model selection                           |

The AI Agent is only available to study team members inside a study context.

## Models

Four models are available. Select one per chat from the **Models** tab; your selection persists for the session.

| Model                 | Tag         | When to use                                           |
| --------------------- | ----------- | ----------------------------------------------------- |
| **Claude Sonnet 4.6** | Recommended | Default — balanced speed and quality for most tasks   |
| **Claude Opus 4.8**   | Advanced    | Deep reasoning on complex clinical logic              |
| **Gemini 3.5 Flash**  | Fast        | Quick answers, long-context tasks, PDF-heavy analysis |

Model selection persists for the current session.

## Context — What the AI Can See

The Agent automatically attaches relevant context based on where you are in the app:

* **Study metadata** — key study information is always included, so you don't have to restate which study you are in
* **Active artifact** — the CRF version, workflow, or document you are viewing
* **Participant context** — when you are on a participant page, the pseudonym and record are passed along (only if you have participant-data roles)

You can also attach files manually:

| File type                                               | Limit          |
| ------------------------------------------------------- | -------------- |
| PDF, plain text (`.txt`), Markdown (`.md`, `.markdown`) | 15 MB per file |

PDFs are extracted server-side using Gemini 3.5 Flash with a prompt that preserves tables, diagrams, lists, and document structure. Extracted content is cached by content hash, so re-attaching the same file in a later conversation is instant.

## Tools the AI Can Call

Some prompts cause the AI to call **tool functions** — read-only utilities that fetch data from your study, plus the AI Pathway Builder tools for editing pathways.

Read-only tools (available everywhere):

* Get study info, list and read documents
* List and read CRF versions
* List and read workflows

Conditional tools:

* **Get participant record** — only if you have participant-data roles and a participant is in context
* **AI Pathway Builder** (suggest pathway outline, section detail, questionnaire edit) — only when you are viewing a CRF version and have the **Study AI Prompts** permission

Tool calls are validated server-side against your permissions. The AI cannot use a tool you do not have access to. See the [AI Pathway Builder](/ai-features/ai-pathway-builder) for details.

## Starting, Resetting, and Limits

<Steps>
  <Step title="Type a Prompt">
    Ask a question, request help, or describe what you want to build.
  </Step>

  <Step title="Attach Context (Optional)">
    Attach a PDF, Markdown, or text file via the **Attach file** button.
  </Step>

  <Step title="Send">
    The AI streams its response in the panel. Tool calls surface as status messages (for example, "Working…").
  </Step>

  <Step title="Reset Chat When Done">
    Click **Reset Chat** to clear history and start fresh. Resets are scoped to the current chat context.
  </Step>
</Steps>

Built-in limits (enforced silently with a toast when hit):

| Limit                     | Value                |
| ------------------------- | -------------------- |
| Message size              | 3.5M characters      |
| File size                 | 15 MB per attachment |
| History sent to the model | Last 50 messages     |
| Tool calls per response   | 10                   |

## Privacy — "Private Mode"

The panel shows a **Private Mode** tag. This signals the AI's data contract:

* Your inputs are sent to the selected model provider only for the duration of the request.
* Conversation content is discarded after use and is not stored long-term by Carelane.
* Data is **not** used to train the model.
* Conversations are kept only in your browser's memory for the current session.

Every AI request is still written to the study's audit trail with the model used, token counts, and duration — for compliance traceability, not content storage.

## Prompt Library

The **Prompts** tab contains pre-built prompts organised by category (study setup, data collection, troubleshooting, pathway building). Click a prompt to insert it into the input; edit before sending.

## Best Practices

<AccordionGroup>
  <Accordion title="Pick the Right Model">
    Use Sonnet 4.6 by default. Switch to Opus 4.8 for intricate clinical logic, or Gemini 3.5 Flash
    when you are working with large PDFs.
  </Accordion>

  <Accordion title="Let Context Work for You">
    Navigate to the relevant artifact (study page, participant, CRF version) before asking — the AI
    will pick it up automatically.
  </Accordion>

  <Accordion title="Reset Between Unrelated Tasks">
    Long chats drift. If you switch topic, reset rather than continuing.
  </Accordion>

  <Accordion title="Review Tool-Driven Changes">
    When the AI proposes pathway edits via its tools, review each ghost suggestion card before
    accepting.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="AI Pathway Builder" icon="wand-magic-sparkles" href="/ai-features/ai-pathway-builder">
    Inline AI suggestions for pathway structure.
  </Card>

  <Card title="AI Study Wizard" icon="sparkles" href="/ai-features/ai-study-wizard">
    Generate a study from a protocol document.
  </Card>
</CardGroup>
