Foresight.Reflect.Expand (Foresight v0.3.0)

Copy Markdown View Source

The agentic reflect expand tool: drill previously retrieved memories up the hierarchy. "chunk" (the default) returns each memory with its provenance and the neighbouring memories of the same document, the surrounding context a truncated fact is missing; "document" returns the owning document's title and text. The id list is model-controlled, so it is de-duplicated, filtered to valid ids and capped before any query runs. cited_ids/1 lists every memory id an expansion put in front of the model, for grounding.

Summary

Functions

Every memory id an expansion surfaced: the expanded units and their neighbours.

Normalise the tool's depth argument; anything but "document" is "chunk".

Expand ids within bank_id. Must run inside the caller's tenant scope; repo_opts carries the tenant prefix.

Upper bound on memory ids expanded per call.

Unique, well-formed memory ids, at most max_ids/0 of them, in request order.

Functions

cited_ids(expanded)

@spec cited_ids([map()]) :: [String.t()]

Every memory id an expansion surfaced: the expanded units and their neighbours.

depth(arg1)

@spec depth(term()) :: String.t()

Normalise the tool's depth argument; anything but "document" is "chunk".

expand(repo, bank_id, ids, depth, repo_opts)

@spec expand(module(), String.t(), term(), String.t(), keyword()) :: [map()]

Expand ids within bank_id. Must run inside the caller's tenant scope; repo_opts carries the tenant prefix.

max_ids()

@spec max_ids() :: pos_integer()

Upper bound on memory ids expanded per call.

normalize_ids(ids)

@spec normalize_ids(term()) :: [String.t()]

Unique, well-formed memory ids, at most max_ids/0 of them, in request order.