Brain Docs

Reference

Python SDKInstallationHTTP clientWire clientSync vs async
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Python SDKPagination

Pagination

Cursor-based enumeration on the HTTP tier, frame-based streaming on the wire, and the terminator each one uses.

PURPOSE

Brain never returns an unbounded list. The two tiers bound them differently: the HTTP tier pages with an opaque cursor, the wire tier streams frames. This page documents both, and the termination rule that is easy to get wrong.

HTTP: cursors

Every paging verb takes limit and cursor, and returns next_cursor.

ParameterTypeRequired
limitintegeroptional

Page size. The server caps it — ask for more and you get the cap, not an error.

cursorstroptional

Opaque. Pass back exactly what the previous page returned. Do not parse, construct, or persist one across a schema change.

An absent next_cursor is the terminator — not an empty page

An empty page is a valid intermediate result: a filter can exclude everything on one page while later pages still have rows. Stop when next_cursor is absent, never when the page came back empty.

Which verbs page

VerbReturns
memory_listitems + cursor
list_entitiesentities + count + cursor
list_statementsstatements + count + cursor
statement_historyitems + chain root + total + cursor
list_relationsrelations + cursor
graph_fetchnodes + edges + cursor
list_schemasitems + total + cursor

list_spaces, list_sessions and list_extractors take a limit but do not page — they return the whole bounded set. list_spaces instead reports cross-shard completeness, which is a different kind of incompleteness: not "there is more", but "this listing covered one shard".

Wire: frames

The wire tier streams. Every enumerating verb has two forms:

OptionTypeDefault / Env
list_entities(request)concatenated

Awaits the whole stream and returns one flat collection. Simplest, and what you want when the result is small.

list_entities_frames(request)per-frame

Returns the frames as they arrived, so you can render progressively or read the per-frame counters.

The pairs: memory_list, graph_fetch, recall, plan, reason, statement_history, traverse_relations, list_entities, list_statements, list_relations_from, list_relations_to and list_schemas.

Wire cursors are bytes, not strings, and the wire listing requests carry filters the HTTP tier does not expose — a time axis and a record/event time range on memory_list, time ranges on the statement and relation listings.

Cancel a stream you stopped reading

Abandoning the call does not stop the server computing. Call cancel_stream with the stream id when you bail out of a long enumeration.

See also
memory_listlist_entitiessubscribe

Was this page helpful?

Retries

Both retry layers — the HTTP client's automatic policy with its idempotent-only verb list, and the wire tier's with_retry combinator.

Rust SDK

The hand-written Rust client for Brain — two clients over one verb vocabulary, and every operation's reference page.

On this page

HTTP: cursorsWhich verbs pageWire: frames
Suggest an editOpen in Playground