Repository navigation
Knowledge PageIndex Tree Optimizer
title: PageIndex Tree Optimizer summary: How PageIndex reshapes an imported tree so leaves fit a token target (merge tiny sections, split oversized leaves at printed headings, add anchored key_items and capped summaries), with dry runs by default, per-pass completion stamps, lock protection and the optimizer_eval harness.
A tree built from a PDF or a markdown file often has the wrong shape for retrieval: one leaf holds a whole chapter
while its siblings hold a single short paragraph each. The optimizer reshapes the nodes of imported documents
(nodes that carry a doc_id and a revision in the segment store) so that the tree is
cheaper to route and to read:
- it merges duplicate and undersized leaves into a neighbour, and folds empty leaves into their parent;
- it splits leaves over
target_leaf_tokensat the printed headings they contain — or, when a leaf has none, at standalone bold or upper-case title lines; - with a model, it can split at heading-like printed lines the layout missed and attach
key_itemsto leaves that stay large; - it writes capped summaries bottom-up (deterministic without a model).
What it does not do:
- It never invents a node title. A new node is titled from a heading segment of the revision, or from a printed line
the model proposed and that passes the heading-like check. Concepts that are not headings become
key_items. - It never changes the source text. Revision files are read-only to it;
optimizenever writes a revision, so every citation validated before an optimization (samedoc_id/revision) still validates after it. - It never touches nodes without a
doc_id, locked nodes or their descendants (see Locks). - No edit tool calls it:
add_node,delete_node,update_node,update_node_content,tag_nodeandrename_treeleave the tree shape alone.
Tokens are always counted over the segments a node owns (its owned ranges), never estimated from page counts.
-
OptimizerSettings— the tuning knobs -
OptimizeReport— whatoptimizereturns (as a dict) -
KeyItem— an anchored label on a node -
plan_deterministic— the model-free planner -
validate_candidate— ownership, anchor and protected-node checks -
reconcile_key_items— re-homes or drops key items whose anchor left their node -
is_heading_text— the "reads like a printed heading" rule -
pseudo_heading_segments— bold/upper-case title lines used when a leaf has no heading segment -
window_reads— splits a node's segments into windows underLLM_INPUT_BUDGET_TOKENS -
run_llm_passes— heading, key-item and summary passes -
describe_document— framed document description on optimized imports -
evaluate_corpus— the evaluation harness -
tuned_target— clamps the harness suggestion to a safe range -
PageIndexToolkit—optimize(),optimize_on_import,optimizer_settings
PageIndexToolkit.optimize() plans on a deep copy of the tree. For every imported document root in scope:
-
Repair ownership.
validate_ownershipruns over the document's nodes. An overlap aborts that document and is reported inerrors. A gap (segments no node owns, for example after a deleted child) is re-owned by the deepest, narrowest unlocked node whose span covers it, and counted inrepaired_gaps. -
Normalize. Bottom-up, per sibling list: an empty leaf (no children, no owned ranges) is folded into its
parent (
empty) — itsconcept_idbecomes a parent alias, so a published tree with a blank "Preface" or title-page node still validates; a published empty leaf without aconcept_idis kept, because removing it could never validate. A leaf whosespanequals a later sibling's absorbs it (duplicate_span); a leaf undermin_leaf_tokensis merged into the previous or next sibling leaf when their owned ranges are contiguous (under_minimum). A non-contiguous small leaf stays. The absorbing node keeps the absorbedconcept_idinaliasesand gains aliteralkey item labelled with the absorbed title, anchored at its first owned segment; itsspanwidens over the absorbed owned ranges, so step 3 keeps them (and that key item) with it. Nothing is dropped from the text. -
Assign ownership. Parent spans widen to cover their children; a parent owns the residual text before, between
and after its children (
render_bodyshows<!-- continues in: <title> -->markers where a child takes over). -
Expand at headings. A leaf over
target_leaf_tokenswith heading segments inside (excluding a first heading that repeats its own title) is split at its shallowest heading level, recursively, up tomax_depth. A split is taken only when the cost model allows it: every piece has at leastmin_leaf_tokens, and the routing cost of the new children (title tokens plus summary tokens, orrouting_tokens_per_childwhen a piece has no summary yet) plus the largest piece is smaller than the leaf it replaces. A leaf with no usable heading segment falls back to pseudo-headings (pseudo_heading_segments): single-line paragraphs fully wrapped in**…**/__…__(split runs such as**P****ROLOGO**included) or written in upper case, whose cleaned title passesis_heading_text. A title repeated more thanPSEUDO_HEADING_MAX_REPEATS(2) times in the leaf is a running header or footer and is ignored, and split points that would leave a piece undermin_leaf_tokensare dropped first, so one stray short line cannot veto the split. This is how ebook and markdown imports, whose chapter titles arrive as bold paragraphs rather than#headings, are expanded without a model; segment kinds are not changed (the segmenter still types those linesparagraph). Repeat counts are keyed byrunning_key(casefold, digit runs collapsed to#), so a running footer that differs only by its page number (CHAPTER THREE PAGE 19,APPENDIX C PAGE 428) counts as one repeated title and is ignored once it occurs more thanPSEUDO_HEADING_MAX_REPEATStimes. That count only sees one leaf, and a two- or three-page piece holds its footer once or twice, so a paged revision also has document running lines (FEAT-859,issue:5a605ae51f61):document_running_keys(revision)returns therunning_keyof every paragraph title that sits on more thanPSEUDO_HEADING_MAX_REPEATSdistinct pages, never twice on one page, and covers at leastRUNNING_LINE_MIN_DENSITY(0.8) of the page range it spans.pseudo_heading_segmentsdrops those titles in any leaf.plan_deterministiccomputes the set once per document (a document has one root per top-level section) and passes it toexpand_at_headings, which hands it down the recursion (running_keys; called without it, each function computes it itself). A page footer covers its whole range once per page; a real heading repeated through a book does not (Kant'sPRIMERA SECCIÓNcovers 0.03 of its range, numbered chapters 0.30), and reference labels such as[SP 800-39]stack on one page, so both stay with the per-leaf rule. An unpaged revision has no document running lines. Pieces created from a paged revision (a PDF) carrystart_index(page of the first owned segment) andend_index(page of the last owned segment); pieces of an unpaged revision (ebook, markdown) carry neither key. Every split — layout or LLM — moves the split leaf's key items onto the piece that now owns their anchor. A leaf with neither a heading nor a pseudo-heading split point can still be one long table (FEAT-861,issue:f31b01d845b0): table rows aretablesegments, and the only repeated line inside, the page footer, is ignored. Whentablesegments hold at leastTABLE_SPLIT_MIN_SHARE(0.5) of the leaf's owned tokens and sit on at least two pages,table_page_splitssplits the leaf at page boundaries: the firsttablesegment, then the first owned segment of each later page. Pages are packed from the last page backward up totarget_leaf_tokens, so a short trailing page (often just the next page's running header) joins the piece before it instead of pushing a piece over the target or vetoing the split, and the points then go through the samemin_leaf_tokenscoalescing. The text before the table (its title, a lead-in paragraph) stays with the parent. Each piece is titled after the leaf plus its page range —TABLE C-17: SYSTEM AND SERVICES ACQUISITION FAMILY (page 481),… (pages 484-485), PDF page indexes likestart_index/end_index— passed tosplit_at(..., titles=…); the expand action's source stays"layout". A table on a single page and a singletablesegment larger than the target are not split. -
LLM heading pass (live model and
llm_passesonly). Only the leaf's heading-like segments are sent, framed and windowed underLLM_INPUT_BUDGET_TOKENS(see Framing); a leaf without any makes no call. The model returns segment numbers of printed sub-headings. A proposal is accepted only when it names a segment the leaf owns and that segment is heading-like: one line, not a table/code/caption segment, and its cleaned text passesis_heading_text— at mostMAX_HEADING_WORDSwords, no trailing.,;,:or,, no trailing lower-case conjunction (and,or,nor,y,e,o,u,ni), no list-marker prefix ((a),a),(iv),-,•,*).1. IntroductionandAppendix Estay valid; a sentence fragment ending in; anddoes not. Accepted seqs go through the same cost model (source: "llm"). Rejections count inrejected_proposals. -
Key-items pass (live model only). Leaves still over
target_leaf_tokensget up tomax_key_itemskey items. An oversized leaf is windowed: each window is asked for its share (ceil(max_key_items / windows)) and at mostmax_key_itemsare accepted in total. -
Re-home key items.
reconcile_key_itemsmoves any key item whose anchor left its node's owned ranges (after a split, or after the toolkit restores the ranges a merge absorbed) to the node that now owns the anchor, counted inkey_items_rehomed. When that node is outside the optimizer's scope the item is dropped and counted inrejected_proposals. It runs at the end of deterministic planning and again before the summary pass, so summary digests see the final key items. One stale anchor therefore no longer discards the whole candidate. - Summary pass. Depth by depth, deepest first, so a parent is composed after its children (see Summaries).
-
Validate.
validate_candidatechecks that the owned ranges of every document form a partition of the revision, that every key item's anchor is inside its node's owned ranges, and that no protected node was removed or changed. A candidate with errors publishes nothing; the report carrieserrors.
| Field | Default | Meaning |
|---|---|---|
target_leaf_tokens |
1500 |
A leaf above this many owned tokens is a split candidate (and a key-item candidate). |
min_leaf_tokens |
200 |
A leaf below this merges into a contiguous sibling leaf; no split may leave a piece below it. |
inline_summary_tokens |
120 |
A leaf at or below this uses its own text as summary, with no LLM call. |
summary_max_words |
60 |
Summary cap; output is trimmed to 1.2 × this many words. |
max_key_items |
8 |
Cap on key items accepted per node from one proposal. |
routing_tokens_per_child |
48 |
Routing cost assumed for a new child that has no summary yet. |
max_depth |
8 |
Depth limit for recursive heading expansion. |
llm_passes |
True |
Run the model-backed passes when a live adapter exists. |
The defaults were confirmed on 2026-11-09 by the host evaluation run (deterministic and LLM mode, see
Evaluation): target_leaf_tokens stays at 1500 because the harness suggestion moves
with the corpus composition (1100 on the compliance corpus alone, 2100 with three Spanish books added, 2200 in LLM
mode), so no single number is better supported than the shipped one. Ledger issues issue:7111d74a3066 and
issue:336eef8010a1 were closed by that run.
settings_hash() returns a 16-character digest of the settings; it is part of every completion stamp.
-
Per toolkit:
PageIndexToolkit(..., optimizer_settings=OptimizerSettings(...))or a plain dict (optimizer_settings={"target_leaf_tokens": 1200}); missing keys keep their defaults. -
Per call:
await toolkit.optimize(tree, target_leaf_tokens=1200, min_leaf_tokens=150, llm_passes=False)overrides those fields for that call only. -
CLI:
parrot pageindex optimize --target-tokens 1200.
PageIndexToolkit(optimize_on_import=True) is the default. With it, import_pdf, insert_markdown and
insert_ebook run the optimizer inside the import transaction, after the document's revision is attached:
- The builder is told not to write per-node summaries (and, for
import_pdf, not to write the document description); the optimizer's summary pass writes them instead.import_pdfpasses itswith_summariesflag through;insert_markdownandinsert_ebookalways run the summary pass, which is deterministic without a model. - Sections under
min_leaf_tokens(200 by default) that are contiguous with a sibling leaf merge into it, so a markdown import with many short sections yields fewer, larger leaves; each merged title survives as aliteralkey item and itsconcept_idas an alias. - The import fails (nothing is published) if the optimized candidate does not validate.
optimize_on_import=False reproduces the pre-optimizer import output byte-for-byte.
await toolkit.optimize(
tree_name,
node_id=None, # restrict to the subtree under this node
apply=False, # dry run by default
llm_passes=True,
target_leaf_tokens=None,
min_leaf_tokens=None,
) -> dict # OptimizeReport.model_dump()-
Dry run (
apply=False): plans on a copy, opens no transaction, publishes nothing. The report shows what an apply would do. -
Apply (
apply=True): runs inside the toolkit's write transaction. If another writer published in the meantime the plan is rebuilt from the fresh snapshot (cached LLM answers are reused only for identical pass keys). Node ids are reindexed, missingconcept_ids derived, bodies re-rendered for the touched nodes, and a new generation is published only when the candidate differs from the current tree; otherwise the transaction is a no-op andgeneration_after == generation_before. - Unknown tree or node raises
KeyError. -
pageindex_optimizeis the same method exposed as a tool. It is not inllm_dependent_tools, so a local MCP server withoutllm:serves it (see PageIndex Local MCP Toolkit).
OptimizeReport fields: tree_name, node_id, dry_run, generation_before, generation_after, documents
(doc ids in scope), nodes_before, nodes_after, leaves_over_target_before, leaves_over_target_after, merged
(list of MergeAction: absorbed/into concept id and title, reason one of duplicate_span, empty,
under_minimum), expanded (list of ExpandAction: parent title and concept id, piece titles, source layout or
llm), key_items_added, summaries_written, repaired_gaps, skipped_locked, skipped_stamped,
rejected_proposals (rejected model proposals and dropped key items), key_items_rehomed, llm_passes ("ran",
"skipped (no model)" or "skipped (disabled)"), llm_calls_estimated, llm_calls_made, errors, and the
effective settings.
llm_calls_made counts adapter calls actually issued: every window is one call, and results served from the retry
cache (for example an apply that reuses its dry run) are not counted. llm_calls_estimated counts the windows each
pass is expected to send on the current candidate.
A key item is {label, kind, seq, page, ordinal}:
-
kind: "literal"— the label must occur in the anchor segment's text (case- and whitespace-normalized). Merge key items (the absorbed title) are literal. -
kind: "abstractive"— a model-written label; it still needs a valid anchor (seqinside the node's owned ranges).
Proposals naming a segment the node does not own, or literal labels absent from their anchor, are rejected and counted. Labels are indexed everywhere a node is matched:
- the BM25 corpus text (
title summary labels body); - the embedded text and the embedding cache key (
content_key(..., extra=labels)) — the key is unchanged for a node without key items, so only nodes that gained labels are re-embedded; - search results (
key_itemson each hit) andoutlineentries.
Each node keeps an optimizer record: passes maps headings, key_items and summary to a PassStamp
(version, input, settings, execution, at), and summary records the summary origin (inline, llm,
composed, none).
- A pass is skipped when a stamp matches on all four of optimizer version, settings hash, input digest and
execution digest. The execution digest covers the mode (
liveordeterministic), the prompt version and, for a live adapter, the client class and model name — never credentials. - Deterministic planning writes no stamps. Stamps are recorded only for passes that actually ran and succeeded, and are finalized after the passes; a record whose input changed meanwhile is dropped, and an already-matching record keeps its original timestamp.
-
Deferred work: a pass that was unavailable (no model), disabled (
llm_passes=False), failed, or not requested (with_summaries=False) is not marked complete, so a later run with a model or with summaries enabled does it. A summary written without a model carries adeterministicexecution digest; once a model is configured the summary pass runs again live for every node aboveinline_summary_tokens(inline leaf summaries stay as they are). -
Dependency invalidation: the summary input of a node includes its own
key_itemsand each child's title, summary, key items and span. A changed child summary or key item therefore invalidates the parent summary (and its retry-cache key) even when titles, spans and owned ranges are identical. -
Idempotence: a second
optimize(apply=True)with the same inputs, settings and execution context publishes no new generation, makes no LLM calls and reports zero merges, expansions, key items and summaries. - Older
optimizerrecords that are not in this per-pass form never match, so their passes run once.
- A node with
locked: trueand all its descendants are out of scope. Anode_idunder a locked ancestor selects nothing — ancestor locks above a selected subtree apply too. Skipped nodes count inskipped_locked. -
update_node(..., locked=True)setslockedwithlocked_reason: "manual";locked=Falseremoves both. -
update_node_contenton a segment-backed node (one with adoc_id) setslocked: trueandlocked_reason: "body_edited". Its body is now the edited text; its owned ranges still describe the source, soread_segmentsstill reads the revision, butoptimizewill not reshape it. - A subtree optimize (
node_id=...) leaves every node outside the subtree unchanged exceptnode_idrenumbering — same bodies,body_refand stamps. Body staging only re-renders nodes the optimizer owns in this run; protected nodes are restored from the base tree, and the final validation after staging and stamp finalization rejects any change to them without publishing.
- A leaf at or below
inline_summary_tokensuses its own owned text (trimmed) — no LLM call (summary: "inline"). - A larger leaf: with a live model, one framed call capped at
summary_max_words("llm") — or, when the leaf exceedsLLM_INPUT_BUDGET_TOKENS, one call per window followed by one reduce call over the framed partial summaries; without a model, its own text trimmed to the cap. - A parent is composed after its children: with a model, from the child summaries and its key items (each clipped
to a quarter of
LLM_INPUT_BUDGET_TOKENS) and the first window of its own framed text that fits the remaining budget; without one, its own text plusSubsections cover: <child titles>("composed"). - Every summary is trimmed to 1.2 ×
summary_max_wordswords. - With no adapter, or an adapter without a client (Bookstore's
_NullAdapter), no call is made and the deterministic summaries are used.
Every optimizer prompt — headings, key items, leaf summaries, parent composition — wraps document-derived text in
<document_text …> frames (frame_segments) and passes DATA_FRAMING_INSTRUCTION as the system prompt;
instructions stay outside the frame and the framing helpers neutralize embedded closing tags.
Bounded prompts. No optimizer call frames more than LLM_INPUT_BUDGET_TOKENS (20 000) tokens of document text.
window_reads splits a node's segments, in order, into windows under that budget (each segment costs its stored
token count plus a small frame allowance); a single segment over the budget forms its own window, clipped and marked
truncated. The heading pass frames only heading-like candidates, the key-items pass and leaf summaries make one call
per window (summaries add a reduce call whose partial summaries are framed too), and parent composition clips its
inputs. A 157k-token leaf therefore fits a 200k-context model instead of producing a ~300k-token request that every
attempt rejects. The budget is a module constant in optimizer_llm, deliberately not an OptimizerSettings field and
not tied to the prompt version, so changing it does not invalidate completion stamps.
On an optimized import_pdf, the document description (with_doc_description=True and a live adapter) comes from
describe_document, which frames the cleaned structure with frame_text; the legacy unframed description helper is
not used on that path. A model proposal that names a segment it was not shown is rejected, including a cached
proposal replayed after a retry.
When normalization merges node B into node A, B's concept_id is added to A's aliases. An empty leaf folded into
its parent leaves its concept_id on the parent the same way.
-
Toolkit lookup:
OKFToolkit.get_conceptandciteresolve an alias to the absorbing node. A liveconcept_idalways wins over an equal alias. -
Bundle export: links and
relates_totargets naming an alias are rewritten to the absorbing node's file andconcept_id. Noaliaseskey is written to the exported frontmatter.
parrot pageindex optimize <tree> --storage-dir <dir> [--node <node_id>] [--apply] \
[--llm provider:model] [--target-tokens N] [--json]Dry run unless --apply. Without --llm no model is configured, so the report says
llm: skipped (no model) and only the deterministic passes and summaries run. --target-tokens overrides
target_leaf_tokens; --json prints the full report.
bookstore optimize <book_id> [--global] [--apply] [--no-llm] [--llm provider:model] [--json]Calls Bookstore.optimize_book. Without --apply the card and the tree are unchanged. With --apply and no errors
it republishes the tree and rewrites the card's toc, toc_digest, chapter_count and page_count from the
optimized tree. --no-llm skips the model-backed passes; otherwise they follow whether the bookstore has an LLM.
bookstore add of a PDF already yields an optimized tree, because the Bookstore's toolkit keeps
optimize_on_import=True, and its card TOC is derived from that tree.
python -m parrot.knowledge.pageindex.optimizer_eval <pdf|dir>... \
[--target-leaf-tokens N] [--min-leaf-tokens N] [--llm provider:model] [--out DIR]Each PDF is imported into a temporary storage directory with optimize_on_import=False and
structure_mode="layout", then optimized with optimize(apply=True) (LLM passes only when --llm is given). The JSON
report (<out>/optimizer_eval-<timestamp>.json, default artifacts/logs/optimizer_eval/) holds, per PDF, the file
stem and numbers only — never a node title: pages, nodes_before/after, leaves_before/after,
leaf_tokens_p50/p90/max, leaves_over_target_before/after, key_items, summary_words_mean, llm_calls,
seconds, llm_heading_splits.
suggested_target_leaf_tokens is the 75th percentile of the owned tokens of all layout-built (pre-optimizer)
leaves, rounded to 100, and is None with fewer than three PDFs. The command prints tuned_target, which returns the
suggestion only when it lies in [2 × min_leaf_tokens, 2 × target_leaf_tokens] of the current defaults, else None.
How the shipped target_leaf_tokens was set. Host run of 2026-11-09 on dev @ 09c95b1646, settings
target_leaf_tokens=1500, min_leaf_tokens=200. Inputs: the four compliance PDFs of corpus/compliance_soc2_hipaa/raw/,
the arXiv fixture, and three public-domain Spanish PDFs from the local Bookstore library (Analectas, Kant's Crítica,
Marco Aurelio's Meditaciones). Reports live under artifacts/logs/optimizer_eval/ (git-ignored); their sha256:
| Report | sha256 |
|---|---|
deterministic/optimizer_eval-20261109T121801073795Z.json (8 PDFs) |
fe02a470e2101f067a99475a6ff5851e587f1b737a70266df82666193a5890e2 |
deterministic_corpus_only/optimizer_eval-20261109T122507348707Z.json (corpus + arXiv) |
b7affece84d877fe28cfbe3d8ce1a428d6d5c4e296de09b47a77484b4b824e43 |
llm_small/optimizer_eval-20261109T122255854142Z.json (google:gemini-3.5-flash-lite) |
680cdf81a824923dd7efccbfa2061434eef880068b12572388a7435a75ade3d9 |
llm_800_53/optimizer_eval-20261109T122706159755Z.json (google:gemini-3.5-flash-lite) |
7651c039e41d02c793fb80f4f9aff8050d576c4ecb9790663639c8520a777660 |
Deterministic run (no model):
| Pages | Nodes before → after | Leaves after | Leaf tokens p50 / p90 / max | Leaves over target after | Key items | Seconds | |
|---|---|---|---|---|---|---|---|
| aicpa_tsc_2017 | 75 | 12 → 12 | 8 | 1560 / 11245 / 27651 | 4 | 0 | 20.8 |
| hipaa_45cfr164_2022 | 61 | 129 → 129 | 68 | 896 / 968 / 1126 | 0 | 0 | 14.5 |
| nist_800_53_r5 | 492 | 118 → 106 | 69 | 1214 / 8271 / 28862 | 28 | 12 | 149.4 |
| nist_csf_2_0 | 32 | 23 → 23 | 20 | 577 / 1396 / 4338 | 2 | 0 | 4.2 |
| arxiv_2408_09869 | 9 | 18 → 14 | 11 | 382 / 1730 / 5398 | 2 | 4 | 9.9 |
| Analectas (Confucio) | 150 | 45 → 45 | 39 | 2086 / 3179 / 9744 | 30 | 0 | 15.5 |
| Crítica de la razón pura (Kant) | 206 | 5 → 5 | 3 | 6 / 123592 / 154488 | 1 | 0 | 27.6 |
| Meditaciones (Marco Aurelio) | 105 | 18 → 17 | 12 | 5622 / 6002 / 6022 | 10 | 0 | 9.4 |
suggested_target_leaf_tokens: 2100 over the eight PDFs, 1100 over the corpus plus arXiv only. The suggestion
is a pooled p75, so a dozen long leaves from one book double it; that instability (ledger issue:adae36a70919) is
why the default was kept at 1500. Two documents expose optimizer bugs rather than tuning signals: Kant has no
typographic headings and stays one 154k-token leaf (issue:ab5235978ad7), and the Marco Aurelio apply is rejected
with protected node … was removed (issue:33ad15e686e9).
LLM mode (--llm google:gemini-3.5-flash-lite):
| Nodes before → after | Leaves after | Leaf tokens p50 / p90 / max | Over target after | Key items | Summary words (mean) | LLM calls | Heading splits | Seconds | |
|---|---|---|---|---|---|---|---|---|---|
| nist_csf_2_0 | 23 → 23 | 20 | 577 / 1396 / 4338 | 2 | 11 | 49.7 | 39 | 0 | 34.0 |
| arxiv_2408_09869 | 18 → 15 | 11 | 382 / 1730 / 2361 | 2 | 19 | 45.4 | 26 | 1 | 32.5 |
| Analectas (Confucio) | 45 → 53 | 46 | 1960 / 2908 / 4300 | 31 | 211 | 52.4 | 122 | 1 | 87.1 |
| nist_800_53_r5 | 118 → 132 | 81 | 991 / 7661 / 28862 | 28 | 0 | 0.0 | 221 | 8 | 246.9 |
suggested_target_leaf_tokens in LLM mode: 2200. Summaries land under the 60-word cap (45–52 words mean) and the
heading pass splits only at printed headings (Analectas: the 14-page introduction became 8 titled sections). The
800-53 row is a rejected candidate: two key_items whose anchors left their node's owned ranges failed
validate_candidate, so none of the 221 calls was published (issue:66f376157327). The LLM-dependent defaults
(inline_summary_tokens, summary_max_words, max_key_items) were kept.
from parrot.knowledge.pageindex import PageIndexToolkit
from parrot.knowledge.pageindex.optimizer import OptimizerSettings
toolkit = PageIndexToolkit(
storage_dir="/data/pageindex",
optimizer_settings=OptimizerSettings(target_leaf_tokens=1200),
)
# Preview: nothing is published.
report = await toolkit.optimize("handbook")
print(report["leaves_over_target_before"], report["leaves_over_target_after"], len(report["merged"]))
# Publish, deterministic passes only.
report = await toolkit.optimize("handbook", apply=True, llm_passes=False)
assert not report["errors"]
# Optimize one chapter.
await toolkit.optimize("handbook", node_id="0007", apply=True)
# Keep the old import shape.
legacy = PageIndexToolkit(storage_dir="/data/pageindex", optimize_on_import=False)-
Legacy trees: nodes without
doc_id/revision(hand-added nodes, imports from before the segment store) and nodes whose revision file is missing are out of scope.optimizeleaves them untouched and reports no documents for them; re-import the source to make it optimizable. - A leaf with no heading segments inside cannot be split deterministically; without a model it stays over target and
shows in
leaves_over_target_after. - The key-items pass only runs with a live model, and only on leaves that are still over
target_leaf_tokens. -
parrot pageindex optimizehas no--min-leaf-tokensflag; useoptimizer_settingsoroptimize(min_leaf_tokens=…). - Editing a segment-backed node's body locks it. Unlocking it with
update_node(..., locked=False)puts it back in the optimizer's scope, where its body is treated as a view of its owned segments again. - An overlap in the existing ownership aborts that document; the report lists it in
errorsand nothing is published.
- PageIndex — trees, builders and configuration options
-
PageIndex Segment Store — revisions, owned ranges,
read_segments, citations -
PageIndex Generation Publication — transactions and generations
optimizepublishes into - PageIndex Layout Structure Builder — where the heading segments come from
-
PageIndex Local MCP Toolkit —
pageindex_optimizewithoutllm: -
Bookstore Codex —
bookstore add/bookstore optimize
- 1. MCP Server — exposing tools as a service
- 2. A2A — exposing agents and orchestrators as services
- 3. Toolkits for third party services and Cloud Security composition
- 4. Interaction surface — WebSockets, audio, integrations
- 5. Hardening — anti prompt injection, PBAC and tool gating
- 6. Cross cutting concerns and reference deployment
- 7. AgentCrew — Sequential, Parallel, Flow and Loop execution
- 8. AgentsFlow — DAG first orchestration with per node FSM
- 9. Ontologic RAG — graph first retrieval, intent routing & multi tenant knowledge
- 10. Observability — OpenLIT + OpenTelemetry
- Class Catalog by Module
- Module level Functions Catalog
- AI Parrot — Exposure, Interoperability & Hardening Architecture
- Agent Mesh
- AgentService — Standalone Runtime for Autonomous Agents
- AbstractClient: The Provider Client Family
- Anthropic client
- Bedrock Mantle Client
- TypeSafe System One Client (
JevClient) - Meta Model API Client (Muse Spark)
- OpenAI Compatible Client Base (
OpenAIBaseClient) - Per Loop LLM Client Cache
- Question Token Budgets (Bedrock Converse, Nova text, Bedrock Mantle)
- Agent Configure Lifecycle
- AgentTalk Integration Guide
- Agent Configuration via
agents.yaml - AgentFactory HTTP API
- Agent Studio — API Reference
- Agent CLI Daemon (agentd)
- FirefliesInsightsAgent
- Follow up Suggestion Chips (FEAT 752)
- Agents and Chatbots: The Bot Class Hierarchy
- Agent Studio — database storage (host guide)
- Ephemeral User Agents — Frontend Integration Handoff
parrot agent— Agent Terminal Workspace- Crew Handler
- Database Agent
- Running the CVE Experts
- Domain Experts (FEAT 778)
- FEAT 437
- Technical Voice Guide (AgentTalk Voice) for Frontend
- AgentDashboard — A2UI v1.0 Technical Reference for
navigator frontend next - Semantic UI Model → Adaptive Cards (FEAT 303)
- Exposing an AI Parrot Agent as an MCP Server
- AgentCrew User Guide
- AgentsFlow User Guide
- Crew Definition Storage
- A2UI Agent Functions Runtime — the v1.0 RPC leg (FEAT 469)
- Capabilities of an AI Parrot Analytical Agent (PandasAgent)
- Agent Security Guardrails (FEAT 761)
- SpawnSubAgentTool
- Testagent
- Agentic End to End Testing (FEAT 581)
- Uiagent
- WebAgent — Browser Interaction via Chrome DevTools
- WebNavigatorAgent — Catalogued Web Navigation on Your Chrome Profile
- ExecutionMemory Integration Guide
- Agent Brain
- Agent Memory
- Conversation History Ownership
- Conversation Memory Subsystem Overview
- Dream Cycle — episodic → wiki brain consolidation
- Durable Conversation Memory
- Memory Dynamics
- Per Turn Conversation Compaction
- Recoverable Task Memory (FEAT 538)
- Task Memory — Phase 0 Integration Map (FEAT 538 / TASK 2970)
- User Memory
- Bookstore Agentic Retrieval
- Bookstore in Codex
- Bookstore Conceptual Relations — the book graph (FEAT 533)
- Bookstore notebooks
- Contracts catalog performance (FEAT 539, AC14)
- Contracts pilot acceptance — Bob's twelve cases (FEAT 539, AC15)
- Contracts Card & Ontology (FEAT 539)
- Luau parser resource policy (FEAT 532 TASK 2896)
- Glossary of Terms (FEAT 917)
- GraphIndex core seams (FEAT 540)
- GraphIndex — Structured Knowledge Graph Indexing
- Local Knowledge Base
- Procedure Graph — Assembly Manuals (FEAT 601)
- Ontology backend programme
- Ontology vocabulary store
- PageIndex Agentic Retrieval and Citations
- PageIndex Generation Publication
- PageIndex Layout Structure Builder
- PageIndex Local MCP Toolkit
- PageIndex Segment Store
- PageIndex Tree Optimizer
- PageIndex — Tree Based RAG for Document Retrieval
- ArxivTool for AI Parrot
- Accounting metrics layer
- Tool Result Compression Pipeline (FEAT 380)
- DatasetManager Implementation Walkthrough
- FredAPITool Documentation
- EmployeesTool Employee Hierarchy Tool for AI Parrot
- HoobaToolkit
- Jira text templates (JiraToolkit)
- Expose Toolkits as Local MCP (
parrot mcp local) - MultiStoreSearch Toolkit — Multi Origin Retrieval for Agents
- Supervised Obscura Browser Integration
- OdooHelpdeskToolkit — Softhealer helpdesk on Odoo 19
- OdooToolkit Capabilities
- QuerysourceToolkit
- ReadOnlyRepoToolkit (FEAT 484)
- PythonREPLTool Sandbox: Worker Process Execution Model
- Research Tools for Agents
- gVisor Installation Guide for AI Parrot Secure Sandbox
- SDD Sandbox — OS Setup
- Governed semantic layer
- Tool optimizations for Claude Code and Codex (FEAT 543)
- AbstractTool Clone Method
- Toolbar API Documentation
- AudioNoteCaptureToolkit
- ExecutionPlanToolkit — Reference
- Host toolkits for Agent Studio
- Infographic Authoring for Data Agents (FEAT 326)
- InfographicToolkit — Reference
- Tool System Internals: Tools, Toolkits and ToolManager
- AI Parrot Tools Documentation
- What If Scenario Analysis
- Workday worker history
- DecisionFlowNode Usage Guide
- Multi Agent Orchestration: AgentCrew and AgentsFlow
- Docker Tool Executor & Execution Policy
- Generic Gate Host
- HeartbeatManager — Per Agent Autonomous Heartbeat Loop
- JobManager
- Node Types Reference
- OrchestratorAgent — Multi Party Conferencing (
confer) - Planogram compliance cycle (perceive → identify → compare)
- Planogram compliance — migrating configurations to the new cycle (FEAT 574, FEAT 612)
- Planogram perception spike — FEAT 574
- Scheduler backends in multi worker deployments
- Thales User Guide
- Per tenant skills (FEAT 707)
- Skill routing and trigger caching
- Skills system: discovery, toolkits and mixin
- Contextual Embedding Headers
- DocumentDB Usage Patterns
- DocumentDB Interface Guide
- DynamoDB Local (docker compose)
- Fully offline local agent with LanceDB (FEAT 542)
- LanceDB vector, full text and hybrid store (FEAT 542)
- Loader Metadata Standard
- Document Loaders for RAG
- Matryoshka Embedding Truncation
- Parent Child Retrieval (Small to Big)
- Storage Backends Guide
- User stores (Redis by default)
- Vector Stores and Embeddings Reference
- Vector Store Handler — API Reference
- A2A Secure Communication Demo
- Agent as a Local MCP Server (parrot toolkits install agent)
- add repository:
- GitHub MCP Installation and Usage
- MCP integration: client, server and agent tools
- Create and configure agent
- Roost — local inter agent sub protocol
- Roost carriers
- Roost performatives, protocols and obligations
- Simple Mcp Server
- SimpleMCPServer Configuration
- API Endpoints Reference
- Admin UI (FEAT 468)
- Infographic Render Endpoint — Reference
- EventBus v2 Configuration Reference (
[bus]/[bus.alerts]) - EventBus v2 Migration Notes (FEAT 310)
- EventBus v2 — Unified Event Fabric (FEAT 310)
- Session file store
- A2UI Dashboard + Widget Renderer — Frontend Build Guide
- Avatar Technical Guide (LiveAvatar Phase A) for Frontend
- Frontend Guide for SvelteKit: LiveAvatar FULL Mode and VoiceBot (FEAT 248)
- DEPRECATED: Native Voice Avatar (LiveAvatar Phase C) Technical Guide for Frontend
- Technical Guide to Structured Artifacts for Frontend
- VoiceBot · VoiceChatHandler · FEAT 245 — Frontend Guide for Realtime Conversation with Agents
- Server Layer: BotManager and HTTP Handlers
- Infographic Handler — Frontend API Contract
- Interactive Artifacts — Frontend API Contract
- Google Drive file manager
- SharePoint & OneDrive file managers
- WhatsApp Integration Implementation Summary
- WhatsApp Integration for AI Parrot
- P3 — parrot admin ui inventory (canvases / A2UI / infographic / builders)
- WhatsApp + AutonomousOrchestrator Integration
- Audio Form Voice Modes — Developer Guide
- Who owns an OAuth2 (3LO) credential
- CommCenter — Bulk Notification Sender (FEAT 417)
- FormDesigner → MS Teams: Adaptive Card renderer and bot submit path (FEAT 551)
- GitHub reviewer
- Google OAuth 2.0 — AI Parrot Integration
- Fireflies Agent Examples
- HITL Tool Call Confirmation (FEAT 235)
- Teams HITL Channel Setup Guide (FEAT 205)
- JiraSpecialist Prompt Layer Stack
- JiraSpecialist — Daily Standup Lanes
- Jira Transition Actions — Activating
TRIGGER_AGENTDispatch - Jupyter Output Mode Documentation
- Knowledge upload from chat (FEAT 647)
- LiveAvatar over your own LiveKit (Cloud or self hosted)
- Matrix Bridges for the AI Parrot Swarm (FEAT 463)
- Matrix Clients for the AI Parrot Swarm (FEAT 463)
- Migration Guide: FEAT 202 — ai parrot integrations
- Connections on Microsoft Teams
- MS Teams Toolkit for AI Parrot
- Nova Sonic Voice Protocol Reference
- Office 365 OAuth 2.0 (Delegated) — AI Parrot Integration
- PR Review Command — Setup Guide
- Queued chat commands
- Runbook — the
issuesnamespace (Jira ticket corpus) - Dev loop kick off from Slack (FEAT 555)
- Telegram Auth Open Mode (webview | browser)
- Telegram connections
- Telegram Bot Integration Guide
- FEAT 536 — VoiceBot Nova Dual Output + LiveAvatar: Real Live Operational Acceptance
- FEAT 537 — Nova VoiceBot avatar broadcast: operational acceptance
- FEAT 537 — Nova PCM → LiveAvatar LITE → LiveKit multi subscriber live gate
- speech_report TTS backends
- Nova VoiceBot avatar broadcast for multiple browsers (FEAT 537)
- 🦜 AI Parrot Voice Chat
- WhisperX Setup Guide for AI Parrot
- A2UI Linked Surfaces (FEAT 598)
- A2UI v1.0 Wire (FEAT 470)
- === D3.js ===
- Backend HTML Design System (FEAT 493)
- FEAT 488
- FormDesigner Audio Renderer
- Form Designer — Autonomous FormSchema Persistence (Standalone Forms)
- Form Designer — Conditional Sections: Pre/Post Dependencies
- FormBuilder — LLM answer plausibility enforcement
- FormDesigner — orphan upload cleanup (FEAT 731)
- FormDesigner — public response controls
- Form Designer — Relational Fields
- Serving FormDesigner forms from a Teams agent
- Form Designer — Unknown Field Capture Policy for Form Submissions
- FormDesigner — validation audit trail
- Infographic Recipes (FEAT 324)
- Inline A2UI Component Routing (FEAT 755)
- Metric Definition Registry (FEAT 756)
- Smart OutputFormatter Documentation
- N4 — navigator api backend inventory (dashboards / widgets / templates / modules / programs)
- P1 — ai parrot HTTP/WS endpoint inventory (report builder lens)
- P2 — ai parrot (Python) UI components, models, renderers, persistence — inventory for a REPORT BUILDER
- P4 — ai parrot prior art for a Report Builder (SDD inventory)
- ai parrot server — Admin / Bots / Studio / misc endpoint inventory
- P1 — ai parrot HTTP/WS endpoint inventory (report builder lens) ( core)
- parrot formdesigner — HTTP/WS endpoint inventory
- Report Builder — ai parrot inventory and analysis
- WeasyPrint 69.0 CSS Support — Empirical Findings
- Identity Capability User Guide
- Layers Reference
- Output Language (FEAT 638)
- PromptBuilder — User Modifiable Variables
- PromptBuilder User Guide
- Delegated OAuth2 connections
- Delegated OAuth2 connections on the web channel — deployment recipe and live harness
- Deterministic Groundedness Scoring
- ONNX Backend for the Prompt Injection Guardrail (FEAT 439)
- PBAC Guardrails — Policy Driven Tool Call Denial (FEAT 406)
- SecurityAdvisor — SOC2 Oriented Read Only Advisory Agent
- User Profile Management
- AI Parrot MCP Server AWS Deployment Guide
- Bot Cleanup Lifecycle
- Business Automation — Operator Runbook
parrot loginand connections- CompanyInfoToolkit
- Per component and per agent LLM defaults (FEAT 796, FEAT 882)
- Answer Accuracy Metrics for the Evaluation Harness (FEAT 652)
- Infographic CSP and Signed URLs — Operations Guide
- Global install: the parrot managed runtime (reference)
- Runbook — the Fireflies Meeting Registry
- Wiki standup briefs — runbook
parrot.finance— the finance satellite- Migration — FEAT 201: ai parrot embeddings
- Migration — FEAT 203: ai parrot server
- FEAT 223 — Structured Artifact Contract: Migration Guide
- FEAT 273 — Legacy output mode deprecations → A2UI
- Migration — FEAT 315: Unified NovaClient for all Amazon Nova models
- Migration — FEAT 421: Client declared tenant in the forms URL
- Migration — FEAT 446: SaaS Auth Hardening (S0 of Parrot Research Cloud)
- Migration — FEAT 473: A2UI v1.0 for STRUCTURED_CHART / STRUCTURED_TABLE / STRUCTURED_MAP
- Migration — FEAT 523: PEP 420 LLM Client Extraction
- Gemini 2.5 retirement (FEAT 798)
- Migration — FEAT 564: Reliable video reels with Gemini Omni and Veo 3.1
- Native Claude sandbox for SDD sessions (FEAT 768)
- Complementary (collaborative) research partner (FEAT 482)
- Dev flow per seat LLM configuration (
DevFlowModelPlan) - Dev loop
novabackend (AWS Bedrock) - sdd worker as orchestrator of parallel sdd coder seats (FEAT 549)
- SDD compaction capability record
- SDD execution optimization — operation and rollout
- Proposals to Reduce SDD Execution Time
- Dev flow / dev loop telemetry accounting
- Language Agnostic Validation Runners (FEAT 709)
- Spec Driven Development in Google Gemini / Antigravity CLI
- Guide to using the SDD slash commands
- AI Parrot Spec Driven Development (SDD) Platform
- SDD on Google Antigravity (agy)
/sdd donecloseout hooks- Decision Audit (FEAT 784)
- SDD experience memory
- SDD Expert Consult
- Ledger outbox (FEAT 758)
- FEAT 580 LSP Pilot — Live Evaluation Results
- SDD LSP research pilot (FEAT 580)
- Necessity Ladder (FEAT 908)
- Procedure Graph
- Test selection in the SDD flow — the Validation Contract (FEAT 699)
- wikitoolkit Cheatsheet
- wikitoolkit inbox
- wikitoolkit lint
- LLM Wiki — an agent maintained knowledge repository
- Schema Plane — Operator Guide (FEAT 600)
- SQLite concurrency for wiki and ledger
- wikitoolkit standup
- WikiToolkit as Claude Code infrastructure
- Authentication uses Navigator Auth
- AbstractClient base changes require a decision
- Clients are memory less
- Configuration uses NavConfig
- Graph backends — retire ArangoDB for PostgreSQL + SurrealDB
- Conversation history has one writer
- HTTP stack uses aiohttp
- LangChain is not part of the stack
- Async code remains non blocking
- Concrete tools live in ai parrot tools