Skip to content

ollama_corpus_amend

Amend corpus. Update one file’s chunks in a corpus without running a full refresh. INVARIANT CAVEAT: the corpus is normally a snapshot of disk — amend bypasses that. new_content doesn’t have to match (or even exist on) disk. The manifest records has_amended_content: true so corpus_list / corpus_health surface the break; a subsequent clean index/refresh re-establishes the invariant. Takes the per-corpus lock. Re-chunks + re-embeds the new_content using the manifest’s chunk params (unless explicitly overridden). Returns {corpus, file_path, chunks_removed, chunks_added, embed_model_resolved}.

Parameter Type Required Default Description
corpus string yes Corpus to mutate. Must already exist (ollama_corpus_index writes the initial manifest).
file_path string yes Absolute file path this content is associated with. Validated against the manifest’s allowed-roots policy even if no file exists there.
new_content string yes The replacement text for this file’s chunks. Re-chunked + re-embedded server-side. Does NOT have to match what’s on disk.
chunk_chars integer no Override the manifest’s chunk_chars for this amend only. Prefer omitting — the manifest’s value keeps the corpus internally consistent.
chunk_overlap integer no Override the manifest’s chunk_overlap for this amend only.

The JSON Schema below is generated from the same zod schema the server validates against at the wire — it cannot drift from runtime behavior.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"corpus": {
"type": "string",
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"description": "Corpus to mutate. Must already exist (ollama_corpus_index writes the initial manifest)."
},
"file_path": {
"type": "string",
"minLength": 1,
"description": "Absolute file path this content is associated with. Validated against the manifest's allowed-roots policy even if no file exists there."
},
"new_content": {
"type": "string",
"minLength": 1,
"maxLength": 5000000,
"description": "The replacement text for this file's chunks. Re-chunked + re-embedded server-side. Does NOT have to match what's on disk."
},
"chunk_chars": {
"description": "Override the manifest's chunk_chars for this amend only. Prefer omitting — the manifest's value keeps the corpus internally consistent.",
"type": "integer",
"minimum": 100,
"maximum": 8000
},
"chunk_overlap": {
"description": "Override the manifest's chunk_overlap for this amend only.",
"type": "integer",
"minimum": 0,
"maximum": 4000
}
},
"required": [
"corpus",
"file_path",
"new_content"
]
}

Every tool returns the standard envelope — tier_used, model, tokens_in/tokens_out, elapsed_ms, backend provenance, warnings. See Envelope & tiers.

Schema + handler: src/tools/corpusAmend.ts · registration: src/index.ts


Back to the Tool Reference.