Incremental engine for long horizon agents π Star if you like it!
CocoIndex Agents
One prompt, many files, kept current.
Incremental agents over your data, on top of CocoIndex. You describe an outcome
in a prompt ("turn the invoices under ./invoices into a table of JSON files in
./out"); an orchestrator agent decides how to split it into subagents over sources and
targets, following the recipes in its system prompt; CocoIndex makes the whole
thing incremental, so when the inputs change only the affected subagents,
reducers and model turns run again.
Status: design frozen 2026-11-04; implementation driven with a real model.
Read DESIGN.md first. The tests drive it with a
scripted model and assert on inference counts; the sample flows under flows/
drive it with a real model through LiteLLM (openai/gpt-6.1-terra) and record
what they measured: the same decomposition in three drives of each flow, no
model call on an unchanged rerun, and two or three calls after one edited
input.
Running
It needs CocoIndex 1.2.0 or later. The steps below run it from a clone of this repository, on the CocoIndex built from it. Once, from the repository root:
uv run maturin develop # build CocoIndex from this checkout
uv sync --extra litellm --inexact # the model client
uv pip install --no-deps -e examples/cocoindex_agents # this package, into the same environment
Keep --inexact on later syncs: a plain uv sync removes the last install.
The model is openai/gpt-6.1-terra, or the LiteLLM model named in
$LLM_MODEL. Put that provider's key in the environment, for example
export OPENAI_API_KEY=....
Then go to the folder your prompt is about and describe the outcome you want. Paths in the prompt are relative to that folder:
cd ~/my-project
uv run --project ~/src/cocoindex python -m cocoindex_agents.app \
"Summarize every markdown file under ./docs. Write one summary per file into ./out,
named after the source file with .md replaced by .summary.md.
Answer with one line saying what was written."
Replace ~/src/cocoindex with your clone. The command prints CocoIndex's
update report, then the answer. It keeps its state in ./.coco_db, or in
$COCOINDEX_DB when that is set. Run the same command again: when nothing
changed it makes no model call, and after you edit one file only that file's
work runs again. Delete .coco_db to start from scratch.
Two more ways to run it:
- The sample flows under
flows/come with their data, and their runner adds--statsfor cache usage and--planfor the plan it chose:uv run python examples/cocoindex_agents/flows/run.py summaries --stats. Seeflows/README.md. - A Google Drive folder of your own, read as your account after a one-time
sign-in: see The
driveflow inflows/README.md. - The web: a prompt that names a topic to research makes the orchestrator
search (Wikipedia with no key, Tavily with
TAVILY_API_KEY), read the pages, follow the leads and write a cited report; a rerun fetches each page conditionally and re-reads only what changed. Needstrafilatura(uv pip install trafilatura). See Theresearchflow inflows/README.md.
Layout
cocoindex_agents/β the package (see DESIGN.md Β§9 for the module map, Β§8 for what is implemented and tested)tests/β scripted-model tests; no API keys neededflows/β six sample flows with their data and a runner: one per shape of DESIGN.md Β§2, one over PDFs the model reads natively, one over a Google Drive folder read as the signed-in account, and one that researches a topic on the web (flows/research/, with the survey behind it); seeflows/README.mdfor how to run them and the measured model calls (--statsfor cache usage,--planfor the plan it chose and what it reused)
Running the tests
From the repository root, after uv run maturin develop:
uv run pytest examples/cocoindex_agents/tests
The tests need no API key. They run on this repository's CocoIndex, in the same environment as the steps under Running.