Adding Tools and Agents
You can extend BioCortex with new tools (agent skills) and optional external agents (e.g. AI-Researcher) in a uniform way. The same tools appear in the Planner/Executor and on the Resources page.Two Ways to Extend
| Type | What it is | How to add |
|---|---|---|
| Tools (DomainTools) | Callable skills: one name, one function, clear parameters. The Planner/Executor choose which tool to use and generate code that calls it. | Implement a module with get_*_tools() returning list[DomainTool], register in biocortex.domains.loader. |
| External agents | Another system (e.g. AI-Researcher) that runs a long pipeline (literature → idea → implementation). | Expose it as one or a few tools that invoke that system (subprocess, HTTP, or in-process). |
search_pubmed, autofigure_generate, ai_researcher_run). External agents are wrapped as one or several such tools.
Adding a New Tool Module
Same pattern as Browser and AutoFigure:1. Create a tool module
Underbiocortex/tools/, e.g. biocortex/tools/my_tool.py.
2. Implement wrapper functions
3. Define DomainTools and a getter
4. Register in the loader
Inbiocortex/domains/loader.py:
5. Optional dependency
Inrequirements.txt:
my_skill and can generate code that calls it when the task matches.
Web UI
The same tools are used when you run an analysis from the Web UI. The backend loads all registered tools, the retriever picks relevant ones, the Planner builds the plan (Plan panel), and the Executor runs code that calls these tools. No extra setup — if a tool is in the registry, it can appear in the plan and on the Resources page.Adding AI-Researcher (or Similar External Agents)
AI-Researcher is a full autonomous research pipeline: literature → idea → implementation → (optional) paper. It uses its own env and is invoked via subprocess or CLI. You can add it to BioCortex as one or two tools that invoke that pipeline. Then a task like “Given these papers, generate a research idea and implementation” can delegate to AI-Researcher.Option A: Bridge tool (recommended)
- Add
biocortex/tools/ai_researcher_tool.pywith tools such as:ai_researcher_run_reference_based— run with a list of reference papers (idea generated by AI-Researcher).ai_researcher_run_detailed_idea— run with a detailed idea + optional references.
- Each tool runs AI-Researcher via subprocess (or HTTP if you expose an API) and returns job id, output paths, or summary.
- Register in
loader.pybehindtry/except; document env vars (e.g.AI_RESEARCHER_PATH,OPENROUTER_API_KEY). - Do not add AI-Researcher to
requirements.txtby default (heavy). Document: “Optional: install AI-Researcher and set AI_RESEARCHER_PATH”.
Option B: Run AI-Researcher separately
- Use AI-Researcher’s own UI/CLI for the full pipeline.
- Use BioCortex for other tasks (single-cell, AutoFigure, browser tools). No code change.
Caveats
- Long-running: Bridge should return quickly with job id or path; increase Executor timeout for that step if needed.
- Env: AI-Researcher expects its own env (e.g.
OPENROUTER_API_KEY,COMPLETION_MODEL,CATEGORY). You can reuse BioCortex’s.envand set the rest in the bridge or a dedicated.env. - Docker: Bridge can call
docker run ...or a script that starts the container.
Summary
- More skills → Add more
DomainToolentries and register inloader.py. No limit. - External agents → Wrap as one or more tools; keep optional in loader and requirements.
- AI-Researcher is integrated as optional bridge tools; set
AI_RESEARCHER_PATHand its.env. If not set, tools return a clear error when called.