## TL;DR

Multi-page receipts arrive as separate images with no guaranteed order. Sort pages by detecting page numbers or by receipt-flow heuristics (header first, totals last), and flag ambiguous sets for human ordering instead of guessing.

## Error

```text
agent failed to handle multi-page receipts: page order error
```

## Steps

1. Detect page-number markers ("page 1 of 3") via OCR on each image. Expected: explicit ordering where the receipt provides it.
2. Where no markers exist, apply flow heuristics: the page with the merchant header goes first, the page with the total goes last. Expected: a best-guess order.
3. Score the confidence of the ordering; below a threshold, queue the set for human review. Expected: ambiguous sets do not get silently misordered.
4. Store the page order with the receipt record so downstream parsing reads pages in sequence. Expected: line items flow correctly across pages.
5. When capturing, advise snapping pages in order and keeping them as one multi-page upload. Expected: fewer unordered sets over time.

## When to use

- An agent misorders pages of multi-page receipts.
- Line items split across pages parse incorrectly.

## When not to use

- Single-page receipts fail OCR (see the OCR skills).
- Pages are missing entirely (request the missing pages).

## Tool compatibility

- Custom agent receipt pipelines; multi-page image sets.

## Variant phrasings

### Receipt pages out of order

Same failure, plain wording.

### Could not sequence multi-page receipt

The ordering-specific phrasing.

## Why it happens

Phone cameras produce one image per snap with no sequence metadata. Without page numbers, the agent has no intrinsic order and must infer it from content.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_7Wf-kNJrWZkQWefnGyOb-w
