#807·flue

@flue/react: expose bounded history (limit, before, loadOlder) in useFlueAgent

Author: rikbrownCreated Oct 1, 2026Updated Oct 1, 2026

Problem

@flue/sdk 2.2.0 added bounded history reads (54cabb7): observe({ limit }), the before cursor on the observed state, and historyBefore(cursor, { limit }). @flue/react does not expose them. AgentSession.start() calls this.client.observe({ live }) with no limit, UseFlueAgentOptions has no limit option, and the public snapshot does not include before.

A React chat UI that uses useFlueAgent therefore downloads the whole conversation on each mount and each reconnect. To load only the newest messages, it must wrap the client to add limit, and hold the older pages outside the hook.

Requested API

  • A limit option on useFlueAgent, passed to observe().
  • before on the hook's return value.
  • A loadOlder({ limit }) action that calls historyBefore, prepends the page to messages, and drops the loaded pages when before changes (a re-base).
  • loadingOlder, and hasOlder (before !== null).

The hook already reconciles optimistic and canonical user messages in converge. If the hook holds the older pages, one message list keeps stable ids and keys, so each caller does not need its own merge.

Related: #339 (closed, older API).