---
title: Q&A Agent
description: Generate an action plan and execute it. Can use external tools.
---

Answer a question from your own documents, with a cloud chat model or fully on-device.

## What it does

Q\&A Agent takes the question in **Prompt**, looks up the most relevant passages in the knowledge base connected to **Knowledge**, and answers from them. What you connect to **Model** decides how it answers; there is no setting to switch:

* **A chat model** (for example [Chat OpenAI](/nodes/builtin/ai/aidependencies/llm/openai/) or [Web LLM](/nodes/builtin/ai/aidependencies/llm/wbellm/)) writes an answer in its own words, using the passages. Without a knowledge base, it answers from what the model knows.
* **A [Local Q\&A Model](/nodes/builtin/ai/aidependencies/llm/localqamodel/)** runs in your browser: free, private and offline. It reads each retrieved passage and **quotes** the best-scoring span, so the answer always comes word for word from your documents. It needs a knowledge base, and **System message** and the output parser do not apply.

Passages are added to the prompt as reference data, not as instructions. A knowledge base marked **Device only** is never sent to a cloud model.

## When to use it

* Answer questions about your notes, manuals or saved pages.
* Look up a fact (a price, a date, a policy) in a knowledge base inside a workflow.
* Keep everything on your device with a Local Q\&A Model and [Local Embeddings](/nodes/builtin/ai/aidependencies/embeddings/localembeddings/).

For a multi-turn chat with memory over your documents, use [RAG Agent](/nodes/builtin/ai/aiagents/ragnode/). To answer from one passage you already have, use [Answer Question](/nodes/builtin/ai/localai/answer-question/).

## Inputs and settings

**Prompt** is the question, for example `{{ $input.question }}` or a fixed `What is our refund window?`.

With a Local Q\&A Model, **Max knowledge context length** limits how much of each passage the model reads.

## Outputs

Each output item has these fields:

```json title="Shape of an output item"
{
  "response": null,
  "answer": "…",
  "score": 0,
  "source": "…",
  "sources": []
}
```

* With a **chat model**, you get `response`, plus `sources` when a knowledge base is connected.
* With a **Local Q\&A Model**, `response` and `answer` hold the quoted answer (empty when none was found), `score` is the model's confidence, and `source` names the document it came from.

Each entry in `sources` has `title`, `url` (when there is one), `knowledgeId`, `sourceId` and `score`. After a run, the node shows a badge such as **3 sources cited**.

## Dependencies and credentials

* **Model**: a chat model, or a [Local Q\&A Model](/nodes/builtin/ai/aidependencies/llm/localqamodel/) to answer on-device. Cloud models hold their own API key.
* **Knowledge**: a [Local Knowledge](/nodes/builtin/ai/aidependencies/vectorstore/localknowledge/) node. Optional with a chat model, required with a Local Q\&A Model.
* **Output Parser**: shapes the chat model's answer. Ignored by the Local Q\&A Model.

## Example workflow

1. Add your product manual to a knowledge base on the [knowledge bases page](/app/knowledge-bases/overview/), or with the [Indexer](/nodes/builtin/ai/aiagents/indexernode/).
2. [Get Selected Text](/nodes/extension/getselectedtext/) reads a customer question you highlighted, with **Output field name** `question`.
3. Q\&A Agent with **Prompt** `{{ $input.question }}`, a [Local Knowledge](/nodes/builtin/ai/aidependencies/vectorstore/localknowledge/) node on **Knowledge** and a [Local Q\&A Model](/nodes/builtin/ai/aidependencies/llm/localqamodel/) on **Model**.
4. [Display Markdown](/nodes/extension/displaymarkdown/) shows `{{ $input.answer }}` and `{{ $input.source }}`.

Nothing leaves the browser.

## Common issues

* **"The Local Q\&A Model answers by quoting a passage, so it needs a context: connect a Knowledge to the Q\&A Agent."** Connect a Local Knowledge node to **Knowledge**.
* **`answer` is empty.** None of the retrieved passages contained an answer (a warning is logged). Raise **Knowledge documents (k)**, lower **Minimum relevance**, or rephrase the question.
* **"Knowledge retrieval failed: …".** The knowledge base could not be searched. Open the Local Knowledge node and check its knowledge base and embedding model.
* **"… is on this device only, but … is a cloud model."** The knowledge base is marked **Device only**. Use an on-device model, change the knowledge base's privacy, or set **Device-only knowledge with a cloud model** to *Answer without it*.
* **"Model not found".** The connected chat model node is not set up: open it and choose a model and its credential.

## Related nodes

* [RAG Agent](/nodes/builtin/ai/aiagents/ragnode/): chat over your documents, with memory.
* [Local Knowledge](/nodes/builtin/ai/aidependencies/vectorstore/localknowledge/): the knowledge base to search.
* [Local Q\&A Model](/nodes/builtin/ai/aidependencies/llm/localqamodel/): the on-device answer engine.
* [Answer Question](/nodes/builtin/ai/localai/answer-question/): on-device Q\&A over a passage you provide.