Overview
Tool Name
Purpose
The document_index_tools enable you to create, manage, and query document indices for high quality search, question answering, and document organization. Ideal for building reusable source collections by ingesting files from Git, local storage, or other repositories, then performing keyword and semantic retrieval at scale.Use
document_index_tools for custom or uploaded collections that you
manage, such as specs, runbooks, PDFs, and policies. Genesis product
documentation is searched separately with search_genesis_docs(...) and
read_genesis_doc(...) in Context Tools.
When indexes are bundled into knowledge bases assigned to an agent, runtime
retrieval uses search_knowledge_bases(...) and read_knowledge_base_doc(...)
instead. Document indexes are not
the same as knowledge bases: indexes store the underlying searchable source
material, while knowledge bases are reusable bundles of one or more index
names that you assign to agents. Use
Knowledge Base Admin Tools
to register or delete those bundles, then use
Bot Management Tools to inspect
or replace agent assignments.Index create, rename, and delete operations refresh capability discovery
immediately. After a mutation,
manage_context(action="SEARCH_CONTEXT", search_scope="document_indexes")
can discover the updated index names without restarting Genesis.Functions Available
_document_index:Single multifunction entry point controlled by the action parameter that performs index and document operations.CREATE_INDEX: Create a new index for future ingestion and search.RENAME_INDEX: Rename an existing index without reingesting content.DELETE_INDEX: Delete an index and all of its files from every embedding-model collection that holds it.LIST_INDICES: List indices with basic metadata.ADD_DOCUMENTS: Add one file or an entire directory to an index. Supports recursive ingest.LIST_DOCUMENTS: List files inside an index with optional path and text filters. Page withstart/count; responses includetotal_count,actual_count,has_more, andnext_start.GET_DOCUMENT: Read file content with pagination by lines, characters, or chunks.DELETE_DOCUMENT: Remove a specific file from an index.RENAME_DOCUMENT: Rename a file within an index.SEARCH: Run keyword or semantic search across one or many indices.ASK: Answer natural language questions using composable retrieval across indices.GET_INDICES_STATS: Return per index statistics such as counts, timestamps, and chunking defaults.RECHUNK: Re-chunk an existing index in place with new chunk size, overlap, or strategy.propose_kb_edit: Stage a Git-backed knowledge-base text or metadata file change for operator approval. Also the recovery path whenmanaged_repo_guardblocksgit_action,file, orconnection_api_actionwrites to a documents/KB repo.open_kb_pull_request: Open or update a pull request or merge request for staged managed KB document changes.
Key Features
Build and Maintain Indices
Create, rename, list, and delete indices to keep document collections organized.
Ingest Files and Folders
Add single files or whole directories recursively, then manage documents over time.
Full Text Search
Search across one or multiple indices and receive ranked results with context.
Question Answering
Ask natural language questions and retrieve sourced answers from indexed content.
Preview at Scale
Read documents with line or character pagination or navigate chunk based previews.
Govern and Clean Up
Delete or rename documents and indices to maintain hygiene without full reindexing.
Input Parameters for Each Function
Common to _document_index
Chunking parameters
Optional onCREATE_INDEX, ADD_DOCUMENTS, ADD_TEXT, and RECHUNK. Sizes are in tokens (approx. 4 characters per token).
CREATE_INDEX stores provided chunk parameters as per-index defaults in index
metadata. ADD_DOCUMENTS and ADD_TEXT accept per-call overrides; when omitted,
they inherit the index defaults. When neither call nor index defaults are set,
ingestion uses the prior behavior (no explicit sentence splitter). With
one_chunk_per_doc, chunk_size is ignored and a warning may be returned.CREATE_INDEX
RENAME_INDEX
DELETE_INDEX
Deletion spans the active embedding-model collection and any prior
model-specific collections that still hold chunks for the index — the same
inventory
GET_INDICES_STATS (and GET /api/indexes) surfaces with
needs_reindex: true. Genesis purges stranded copies first, then the active
copy, and detaches indexed files only after every physical copy is confirmed
gone. If a collection could not be read or purged, the action returns
Success: false with an Error naming the surviving collection name(s), for
example Index wiki still exists in openai_text_embedding_3_large_index; retry to finish removing it — call DELETE_INDEX again to finish removal.LIST_INDICES
No additional parameters. Returns the registered index names from memory for the
active document manager, rather than scanning every ChromaDB chunk on each call.
Genesis seeds this name set from collection metadata during initialization and
retries a lazy seed when the initial read fails. The IndexDetails field still
contains statistics; use GET_INDICES_STATS (or GET /api/indexes) when you need
the broader inventory, including indexes stranded in prior model-specific
collections.
ADD_DOCUMENTS
Document ingestion applies built-in exclusions for generated and binary content,
including
**/__pycache__/**, **/node_modules/**, **/.git/**, **/*.o,
**/target/**, **/build/**, and **/dist/**. Patterns match complete path
segments or filenames, not text within a name: docs/05-dual-targeting.md is
not excluded just because it contains target. Recursive and pattern-based
ingestion skips excluded files and reports them in its excluded count. If you
explicitly name a file covered by an exclusion pattern, ADD_DOCUMENTS
rejects the request instead of indexing it; move the file or use a path outside
the excluded location.ADD_DOCUMENTS now tolerates transient ChromaDB WAL compaction failures more
gracefully. During larger ingests, Genesis may pause briefly at checkpoints to
let the compactor flush, then automatically retry insert operations that fail
with transient compaction errors before returning an error to the caller.Vector inserts during ingestion are split into batches of 64 vectors. This
limits how long an individual insert can block other server work during a
large upload.
LIST_DOCUMENTS
LIST_DOCUMENTS returns one page at a time. Read TotalCount, has_more, and
next_start from the response, then call again with start=next_start until
has_more is false. When more pages exist, Message summarizes the range
(for example, “Showing first 50 of 142 items. 92 more items exist.”). Pagination
metadata appears before the Documents array so output previews retain the
signal when response size is capped.To build a listing, Genesis first collects the index’s chunk IDs, then reads
chunk records in pages of up to 2,000. This avoids materializing every chunk’s
metadata and content at once; this internal read size is separate from the
50-document response page limit.
GET_DOCUMENT
For code and structured text prefer
pagination_mode="lines". For prose prefer pagination_mode="chars". Use chunk mode when you want the tool’s native segmentation.DELETE_DOCUMENT
Prefer
file_id when the document came from Genesis file storage. If the
backing file has already been removed but its index entry remains,
DELETE_DOCUMENT can still remove that orphaned entry by file_id. When
you delete by filepath, Genesis also tolerates leading or trailing /, so
equivalent path forms still resolve to the same indexed document entry.RENAME_DOCUMENT
SEARCH
ASK
ADD_TEXT
RECHUNK
GET_INDICES_STATS
No additional parameters. Returns per-index statistics: name, file_count,
created_at, needs_reindex (boolean, default false), and chunk_config
(chunk_size, chunk_overlap, chunk_strategy — null when unset). When the
active embedding identity’s resolved collection is missing indexes that still
exist in another model-specific *_index collection on disk (any provider
prefix), those stranded indexes are included with needs_reindex: true and
chunk_config set to all null. Genesis normalizes embedding identity before
collection resolution — provider and model case are folded, and a genuine
provider/ prefix on the model name is stripped when it matches the normalized
provider — so alternate spellings of the same embedding space (for example bare
openai + text-embedding-3-large versus LiteLLM-routed litellm_openai +
openai/text-embedding-3-large) can share one populated collection instead of
leaving indexes falsely stranded after a routing change. When the derived
collection name for the active identity holds no user documents but an alternate
historical spelling already does, Genesis adopts that populated collection.
file_count reflects user-indexed documents only: startup demo seed rows and
metadata-backend index markers are discounted. System metadata-backend indexes
twin and harvester are excluded from needs_reindex surfacing. This matches
the Config → Documents list and GET /api/indexes. Prefer this action over
LIST_INDICES when you need the full inventory after an embedding-model change.
propose_kb_edit
Provide either non-empty
content or non-empty search, but not both. Supported
files must be under a first-level folder in documents_root; sidecars such as
kb-manifest.json and genesis-kb.yml use the same workflow.
Genesis owns the proposal branch worktree. Do not commit to that branch through
git_action, commit_files_via_api, or provider file APIs; the next
open_kb_pull_request force-pushes the staged worktree state and overwrites
commits made through those routes.
open_kb_pull_request sends the managed branch push through Action Review. A
pending or denied review leaves the branch and pull request unchanged; do not
retry while the proposal is waiting or when its outcome is uncertain.
When git_action, file(action="write"), or connection_api_action returns
managed_repo_guard on a Git-backed documents/KB repo, the response includes
managed_document_repo: true and next_steps that point here — stage the
supported KB file with propose_kb_edit, then call open_kb_pull_request.
open_kb_pull_request
The response includes
changed_files, the authoritative list of files in the
PR. Each entry contains a repository-relative path and a status: A (added),
M (modified), D (deleted), or R (renamed). Use this list when describing
the PR rather than relying on earlier staging calls.
Git-backed knowledge-base documents cannot be edited in place with
ADD_DOCUMENTS, ADD_TEXT, or DELETE_DOCUMENT, and Genesis-owned KB
checkouts cannot be written with git_action, file(action="write"), or
connection_api_action. Use propose_kb_edit to stage supported KB files,
then open_kb_pull_request when the changeset is ready for review. If a
blocked mutation returns managed_repo_guard with managed_document_repo: true, follow the tool’s next_steps and call propose_kb_edit instead of
retrying file or git mutations. For ad-hoc indexes or one-off uploads,
continue using the standard _document_index actions.Use Cases
- Mission document collection Build an internal source collection for requirements, SOPs, and architecture notes. Example: Index a runbooks folder and enable search plus Q&A for on call engineers.
- RAG for Onboarding Provide new team members with a question answering interface over onboarding materials. Example: Ask, “How do I rotate credentials” and get a sourced answer.
- Git Docs Discovery Ingest a docs directory from Git and search by keyword or path. Example: Find all pages mentioning “rate limit” in API docs.
- Analyst Document Access Search PDFs and specs, then preview with pagination to pull the right excerpt. Example: Return 100 lines starting from line 300 in a long changelog.
- Governance Library Maintain data policy indices and generate summaries on demand. Example: Ask for retention rules and cite the policy document.
- Git-backed knowledge base
Stage markdown fixes from chat, then open a PR/MR for operator review.
Example:
propose_kb_edit(source_id_or_index="team-kb", relative_path="runbooks/oncall.md", search="page the SRE", replace="page the platform on-call"), thenopen_kb_pull_request(source_id_or_index="team-kb"). - Tune chunking for long documents
Create an index with larger chunks for narrative docs, or call
RECHUNKafter ingestion to change strategy without re-uploading files. Example:CREATE_INDEXwithchunk_strategy="one_chunk_per_doc"for short policy PDFs, orRECHUNKwithchunk_size=512andchunk_overlap=50for tighter retrieval on code comments.
Workflow/How It Works
- Step 1: Create or Select an Index
Use
CREATE_INDEXor locate an existing one viaLIST_INDICES. - Step 2: Ingest Content
Use
ADD_DOCUMENTSto add single files or entire directories. PreferBOT_GIT:paths for repository sources. - Step 3: Explore Inventory
Use
LIST_DOCUMENTSwithpath_filterorqueryto scope the file set. For indexes with more than 50 files, page withstartandcount, followingnext_startuntilhas_moreisfalse. - Step 4: Retrieve Content Snippets
Use
GET_DOCUMENTwith pagination to preview without loading entire files. - Step 5: Discover or Ask
Use
SEARCHfor precise discovery with ranked results. UseASKfor natural language answers with sources. - Step 6: Reuse as Agent Knowledge
When an agent should reuse one or more indexes across many threads, create a
knowledge-base bundle with
create_knowledge_base(...), then assign thatknowledge_base_idwithset_bot_knowledge_bases(...). - Step 7: Adjust Chunking (optional)
Use
RECHUNKto apply new chunk defaults to an existing index, or passchunk_size/chunk_overlap/chunk_strategyonADD_DOCUMENTSorADD_TEXTto override per ingest. - Step 8: Maintain Hygiene
Use
RENAME_DOCUMENTorDELETE_DOCUMENTfor files andRENAME_INDEXorDELETE_INDEXfor indices.
Integration Relevance
- file_manager_tools and git_action: Register or modify files, then ingest using
ADD_DOCUMENTSwithBOT_GIT:paths. - project_manager_tools: Link indices to project or mission tasks for traceability.
- web_access_tools: Scrape pages, save content, then index for unified search.
- google_drive_tools: Export summaries to Docs or Sheets. Ingest Drive downloads after staging.
- handoff: Automate nightly indexing, refreshes, or QA sweeps.
Configuration Details
- Directory strategy: Organize repo paths such as
BOT_GIT:docs/specsandBOT_GIT:runbooksfor predictable listings. - File types: Prefer text friendly formats like Markdown and plain text for better chunking and recall.
- Chunking settings: Set per-index defaults on
CREATE_INDEXwithchunk_size,chunk_overlap, andchunk_strategy. Override per ingest onADD_DOCUMENTSorADD_TEXT, or re-apply to existing content withRECHUNK. Sentence splitting defaults are1024tokens with200overlap; useone_chunk_per_docwhen each source file should map to a single searchable chunk. - Embedding input windows: When explicit chunking is active, Genesis may warn if chunks exceed the active embedding model’s input window (for example,
512characters for Snowflake Cortex,8000for LiteLLM-routed providers). Full chunk text is still stored and returned; semantic similarity uses only the leading portion within that window. - Index healing: See Document Indexes — embedding recovery for startup recovery and temporary
SEARCHwarnings. - Embedding runtime: Document ingestion and semantic retrieval use the active embeddings configuration from Config -> AI Providers (the same runtime exposed by
GETandPUT /api/config/models/embeddings/config). When no complete embedding identity resolves, Genesis fails closed —CREATE_INDEX,ADD_DOCUMENTS,ADD_TEXT,SEARCH, andASKreturn an error rather than silently routing through an unconfigured OpenAI default.LIST_INDICES,LIST_DOCUMENTS, andGET_INDICES_STATSmay return an empty inventory with anEmbeddingIdentityStatediscriminator instead of raising.EMBEDDING_PROVIDER/EMBEDDING_MODELseed that identity only while it is unset; a saved identity wins over them. When the saved provider/model pair is incoherent — for example a Cortex-only catalog model such ase5-base-v2paired with a non-Cortex provider in a Cortex-capable deployment (Snowflake Native App / SPCS or Cortex with public REST access) — Genesis corrects the provider tocortexat config read time instead of routing through LiteLLM/OpenAI. Custom deployment names onazureopenaiandlitellm_proxyare never auto-corrected. Genesis also runs a one-time embedding connection smoke test at startup (5-second timeout for LiteLLM-routed providers); failures are logged but do not block boot — check server logs forfailed startup smoke testwhen indexing fails after restart. When the active provider is LiteLLM Proxy, Genesis routes embedding calls through the configured proxy even if the selected model is shown as a bare model name. When the active provider is AWS Bedrock (litellm_bedrock) with a custom endpoint and a non-bearercustom_auth_header(for examplex-api-key), Genesis applies the same custom-header proxy kwargs as chat —extra_headersplus placeholder SigV4 credentials — rather than env-based bearer auth (the chat-only Fake Stream setting,fake_stream, is not forwarded to embedding calls). Default-endpoint, bearer, and IAM Bedrock embedding calls continue to authenticate through AWS environment credentials only. When the active provider isSnowflake Cortex, Genesis uses the embedding method saved on the Cortex provider card (restby default, orsqlwhen explicitly selected). In Snowflake Native App / SPCS runtimes, document indexing always uses the Snowflake SQL embedding function via the deployment session. Outside SPCS,restcalls the Cortex REST API with the saved PAT or a short-lived JWT from the saved key pair;sqlopens a direct Snowflake connection (account URL or Snowflake account, PAT or PEM private key, and Snowflake User required; optional warehouse and role) and runsSNOWFLAKE.CORTEX.EMBED_TEXT_768. - Embedding collection resolution: Document embeddings live in model-specific Chroma collections named
{provider}_{sanitized_model}_index. Genesis resolves the active collection for the current embedding identity by adopting an already-populated historical spelling when the derived name holds no user documents — for example after OpenAI routing moves to LiteLLM credentials while the prior bare-provider collection still holds indexed files. Background re-embed from prior*_indexcollections copies only when embedding identity is verified from collection metadata (or, for older collections without metadata, when the inferred provider matches and embedding dimensions match). A dimension-only match is not treated as conclusive, so Genesis keeps the source collection on disk instead of archiving it. On every server startup, Genesis also scans for user indexes that still exist only in other model-specific*_indexcollections for the active embedding provider and schedules a background full re-embed into the current collection (including the internal harvester metadata index). This stranded-collection sync runs independently of legacy provider-to-model migration when the active collection is empty, and it covers embedding changes applied through config files or deployment templates that do not go through the Embeddings UI save path — the path that already starts reindexing when you activate a new provider or model in Config → AI Providers. While sync runs,GET_INDICES_STATSmay still list affected indexes withneeds_reindex: true; pollGET /api/config/models/embeddings/reindexing-statusor watch server logs for messages such asRe-embedding stranded documents after embedding model change...for progress. Opening a persisted collection may require an initial disk read; that read no longer pauses other server work, even on slow storage. - ChromaDB compaction guardrails:
ADD_DOCUMENTSpauses every50inserted documents by default (GENESIS_DOCUMENT_INDEX_COMPACTION_CHECKPOINT_INTERVAL, integer, default50) for0.5seconds (GENESIS_DOCUMENT_INDEX_COMPACTION_CHECKPOINT_SLEEP_S, float, default0.5) and retries transient compaction failures up to3times (GENESIS_DOCUMENT_INDEX_COMPACTION_MAX_RETRIES, integer, default3). - Access controls: Align indices with team access. Do not mix confidential and public content in the same index.
Limitations or Notes
- Large files and PDFs Text extraction quality depends on parsers. Consider OCR or cleanup for scanned content.
- Binary formats Non text binaries are not semantically indexed. Store summaries separately if needed.
- Path stability
Renaming or moving files outside the tool requires readding or a
RENAME_DOCUMENTcall to maintain searchability. - ASK scope
ASKtypically runs across all indices and ignoresindex_name. UseSEARCHto scope to a specific index. - Pagination fidelity
Line and character counts can vary due to encoding. Rely on
has_moreandactual_countfor navigation. - Delete conflicts If a delete is already in progress for an index, conflicting operations on that same index return a conflict error until cleanup completes.
- Partial cross-collection delete
When
DELETE_INDEXcannot purge every physical copy (for example a prior embedding collection is unreadable), Genesis leaves surviving copies in place and returnsSuccess: falsewith the collection name(s) still holding the index. RetryDELETE_INDEXafter fixing storage access; the index stays listed until all copies are gone. - Compaction recovery
If a ChromaDB compaction error persists after retries during
ADD_DOCUMENTS, Genesis attempts automatic recovery. If recovery succeeds, retry the same ingest request. If recovery fails, manual cleanup or a service restart may still be required. - Rechunk conflicts
RECHUNKholds a deletion marker for the target index for the full rebuild-and-swap. Other writes to that index fail with a conflict error until the operation finishes. - Embedding window truncation Chunks longer than the active embedding provider’s input limit are embedded from their leading characters only. Retrieval still returns the full stored chunk text.
Output
- Index Management
Success flags and messages for create, rename, and delete.
CREATE_INDEXmay includechunk_configwhen chunk parameters were set.DELETE_INDEXreturnsSuccess: truewithMessage: "Index deleted successfully"when every physical copy is removed; when copies survive in one or more collections it returnsSuccess: falseand anErrorlisting those collection names withretry to finish removing it.LIST_INDICESreturns the active document manager’s registered names from memory, while itsIndexDetailsfield contains statistics.GET_INDICES_STATSreturnsname,file_count,created_at,needs_reindex, andchunk_configfor every index in the resolved active collection plus any stranded indexes from other model-specific*_indexcollections that need re-embedding after an embedding-model change (excluding system metadata-backend indexestwinandharvester). - Chunking and Rechunk
RECHUNKreturnsdocs_rechunked,chunks_before,chunks_after,chunk_config, and optionalWarningsorapproximate_reassembly_noteswhen text had to be reassembled from stored chunks. On failure, the original index is preserved and a temporary index name may be returned for inspection. - Ingestion and Inventory
For
ADD_DOCUMENTSandADD_TEXT, success messages may append chunking warnings (for example, ignoredchunk_sizewithone_chunk_per_doc, or chunks exceeding the embedding input window).ADD_DOCUMENTSalso returns a per-file status report with added and skipped items. If a ChromaDB compaction failure exhausts retries, the error message explains whether automatic recovery completed and whether you should retry the ingest or perform manual cleanup.LIST_DOCUMENTSreturnsTotalCount,start,count,actual_count,has_more,next_start, an optionalMessage, and aDocumentsarray of paths, sizes, timestamps, and optional metadata (up to 50 items per page). - Reading and Retrieval
GET_DOCUMENTreturns a content slice withstart,count,actual_count, andhas_more.SEARCHreturns ranked results with score, snippet, index name, and path.ASKreturns a best answer plus sources and footnotes.
Prefer
SEARCH when you need multiple hits with scores. Prefer ASK when you want a concise answer with citations.
