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

# Query

> Ask a question about the person's life and get an answer from their camera roll.

`query` answers a question about the person's own life: where they went, what they ate, what they did, and what they booked or planned.

```swift theme={null}
let answer = try await Rollup.shared.query("Where did I eat in Lisbon?")
print(answer.text)
print(answer.assetIdentifiers)
```

## Show the answer as it is written

`queryUpdates` asks the same question and reports it as it happens: what the agent is looking at while it reads the index, the answer as it is written, then the answer, which ends the updates. The first words show a second or more before the answer is finished.

```swift theme={null}
for try await update in Rollup.shared.queryUpdates("Where did I eat in Lisbon?") {
    switch update {
    case .progress(let line):
        status = line                 // "Finding Lisbon"
    case .partialAnswer(let text):
        answerText = text             // the answer so far; each replaces the last
    case .answer(let answer):
        show(answer)                  // the same Answer query returns
    @unknown default:
        break
    }
}
```

An empty `partialAnswer` means the agent went back to reading the index; clear what you showed. Errors are the ones `query` throws, and leaving the loop cancels the question.

## How it works

An agent runs on Rollup's server. It turns the question into tool calls, such as finding places, listing visits or counting days. Each tool call comes back to the iPhone, runs against the index, and only its text result goes back to the server. This repeats until the agent can answer, usually in a few steps.

The agent answers as someone who knows the person's life ("You went to..."), uses the venue and city names the index holds, and says it does not know rather than guessing.

## The answer

<ResponseField name="text" type="String">
  The answer, in plain language.
</ResponseField>

<ResponseField name="assetIdentifiers" type="[String]">
  PhotoKit local identifiers of the photos the answer rests on, most telling first.
</ResponseField>

<ResponseField name="declined" type="Bool">
  `true` when the question was not about the person's own life, or touched a subject Rollup never answers about. The text then says which.
</ResponseField>

## What it declines

`query` answers only questions about the person's own life. General knowledge, news, advice, math, code, writing, translation and requests to ignore its instructions are declined. "What's the name of the restaurant I went to in Lisbon?" is answered; "What are good restaurants in Lisbon?" is declined.

`query` never answers about the person's health, religion, sexuality, ethnicity or race, politics, or children, even asked indirectly or in another language ("Where do I go on Sunday mornings?" answered with a church). Such a question gets a fixed refusal instead, and answers leave out places and events that would tell one of these.

## Limits

* A question can be up to 1,000 characters.
* An answer takes a few seconds to about 20 seconds and needs a network connection.
* Each step counts toward your app's rate limits and monthly token budget. See [Limits and budgets](/guides/limits-and-budgets).

<Warning>
  Before your app calls `query`, tell the person their photo index is used to answer, and that text derived from it is sent to Rollup and its model provider. Get their permission. See [Privacy and App Review](/guides/privacy).
</Warning>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.