The Literature Agent searches scientific literature and synthesizes findings with inline citations. It supports multiple backends including OpenScholar, BioLit, Edison, and custom knowledge bases.
Function Signature
// src/agents/literature/index.ts
export async function literatureAgent ( input : {
objective : string ;
type : LiteratureType ;
onPollUpdate ?: OnPollUpdate ;
}) : Promise < LiteratureResult >;
type LiteratureType = "OPENSCHOLAR" | "KNOWLEDGE" | "EDISON" | "BIOLIT" | "BIOLITDEEP" ;
type LiteratureResult = {
objective : string ;
output : string ;
count ?: number ; // Number of sources found
jobId ?: string ; // External job ID for polling
reasoning ?: string []; // Real-time reasoning trace
start : string ;
end : string ;
};
Backends
OpenScholar
General scientific literature search with high-quality citations.
const result = await literatureAgent ({
objective: "What are the mechanisms of cellular senescence?" ,
type: "OPENSCHOLAR"
});
Configuration:
OPENSCHOLAR_API_URL = https://your-openscholar-api
OPENSCHOLAR_API_KEY = your_key
See OpenScholar deployment for setup.
BioLit
BioAgents Literature API with semantic search and LLM reranking.
Quick literature search for simple queries: const result = await literatureAgent ({
objective: "Effects of rapamycin on aging" ,
type: "BIOLIT"
});
Comprehensive search with multi-hop reasoning: const result = await literatureAgent ({
objective: "Molecular pathways connecting mTOR inhibition to longevity" ,
type: "BIOLITDEEP" ,
onPollUpdate : ( update ) => {
console . log ( update . reasoning ); // Real-time trace
}
});
Configuration:
PRIMARY_LITERATURE_AGENT = bio
BIO_LIT_AGENT_API_URL = https://your-biolit-api
BIO_LIT_AGENT_API_KEY = your_key
Knowledge Base
Search your custom knowledge base using vector search with Cohere reranking.
const result = await literatureAgent ({
objective: "Internal research on protein folding" ,
type: "KNOWLEDGE"
});
Setup:
Add documents
Place PDF, DOCX, or Markdown files in docs/ directory
Configure embeddings
Set embedding provider in .env: EMBEDDING_PROVIDER = openai
TEXT_EMBEDDING_MODEL = text-embedding-3-large
Enable reranking
Configure Cohere for better results: COHERE_API_KEY = your_key
USE_RERANKING = true
RERANK_FINAL_LIMIT = 5
See Knowledge Base for details.
Edison
Deep literature search via Edison AI agent (deep research mode only).
const result = await literatureAgent ({
objective: "Recent advances in CRISPR gene editing" ,
type: "EDISON"
});
Configuration:
EDISON_API_URL = https://your-edison-api
EDISON_API_KEY = your_key
See Edison deployment .
The agent returns synthesized findings with inline citations in the format:
Example:
(Rapamycin extends lifespan in mice by up to 60%)[10.1038/nature.2009.1234]
(The mechanism involves mTOR pathway inhibition)[https://example.com/paper]
Usage Example
// src/routes/chat.ts
const completedTasks : PlanTask [] = [];
for ( const task of literatureTasks ) {
const result = await literatureAgent ({
objective: task . objective ,
type: "OPENSCHOLAR"
});
task . output = result . output ;
task . start = result . start ;
task . end = result . end ;
completedTasks . push ( task );
}
Configuration
OpenScholar API base URL (optional)
OpenScholar API key (optional)
PRIMARY_LITERATURE_AGENT
string
default: "openscholar"
Primary agent: bio, openscholar, or edison
BioLit API base URL (when PRIMARY_LITERATURE_AGENT=bio)
BioLit API key (when PRIMARY_LITERATURE_AGENT=bio)
Edison API base URL (optional)
Edison API key (optional)
Path to knowledge base documents
Knowledge Base Set up vector search
Planning Agent Generates literature tasks
Deep Research Iterative research cycle