Deep Research Agent
createDeepAgent packages planner + parallel sub-agents + compression into a single opinionated factory for long-horizon research tasks.
ts
import { createDeepAgent } from 'personaforge/skills';Quick start
ts
const deep = createDeepAgent({
generate: (prompt) => llm.generate(prompt),
tools: [webSearchTool, wikipediaTool],
});
const result = await deep.run('What are the long-term economic effects of UBI?');
console.log(result.answer);
console.log(result.subQuestions);
console.log(result.rawSubAnswers);
console.log(result.steps.map((s) => `${s.phase}: ${s.detail}`));Pipeline
- Plan — the LLM decomposes the question into focused sub-questions.
- Research — each sub-question runs in parallel. Optional tools (search, Wikipedia) are called first, and their results are injected into the research prompt.
- Synthesize — the findings are concatenated and a final synthesis prompt produces a structured answer with inline citations.
Configuration
ts
interface DeepAgentConfig {
generate: (prompt: string) => Promise<string>; // any LLM
tools?: Array<{ name; description; execute }>; // called per sub-question
maxParallel?: number; // default 5
maxQuestions?: number; // default 5
subAnswerMaxChars?: number; // default 2000
}Result shape
ts
interface DeepResearchResult {
answer: string; // multi-paragraph synthesis
steps: Array<{ phase; detail }>; // audit trail
subQuestions: string[];
rawSubAnswers: Array<{ question; answer }>;
}Usage tips
- Narrow
maxQuestionsfor simple queries to avoid over-decomposition. - Add a reranker after the tool calls to filter noisy search results before feeding them to the sub-agent.
- Chain with compression if the synthesis prompt grows beyond the model's context window.
Related pages
- Planner — lower-level task decomposition.
- Orchestration — multi-agent pipeline patterns.
- Compression — token budget control.