Strategy Routing

The Strategy Router classifies every incoming task and selects one of four execution strategies: SimpleReAct, DAG Parallel, MCTS, or Hypothesis. This ensures simple tasks run quickly, complex pipelines get full multi-agent execution, and open-ended scientific questions get iterative hypothesis-driven reasoning.

Why Strategy Routing?

Biological tasks vary widely:
  • Simple: “What does BRCA1 do?” or “Convert FASTA to GenBank.”
  • Structured: “Run QC, normalization, clustering, and annotation on pbmc.h5ad.”
  • Exploratory: “Find drug repurposing candidates for target X.”
  • Scientific hypothesis: “What causes immunotherapy resistance in melanoma?” or “Propose a mechanism for FOXP3-mediated T-cell suppression.”
A single pipeline for all would be slow for simple queries and insufficient for scientific reasoning. The router assigns each task to the most appropriate engine.

Two-Phase Classification

Phase 1: Heuristic Classification

Regex and structural cues score the task for each strategy:
  • Simple indicators: lookups, conversions, single-entity queries → boost SimpleReAct.
  • Pipeline indicators: multi-step keywords, commas/semicolons, step counts → boost DAG.
  • Exploratory indicators: discovery, candidate finding, screening → boost MCTS.
  • Hypothesis indicators: “what causes”, “propose mechanism”, “generate hypothesis”, “novel biomarker”, “how does X resist/evade” → boost Hypothesis.
Task length and structure (e.g. comma count) contribute bonus terms. Hypothesis strategy requires a minimum score of 2 and dominance over other categories. Confidence is computed as the max score over the sum of all scores (plus ε).

Phase 2: LLM Classification (Ambiguous Cases)

When confidence from Phase 1 is below 0.75, the task is sent to the fast LLM with a structured prompt that asks for:
  • Strategy choice (react / dag_parallel / mcts / hypothesis)
  • Confidence (0.0–1.0)
  • Short reasoning
  • Complexity score and estimated step count
The heuristic result is provided as a hint. The LLM response is parsed to produce the final TaskClassification.

Domain Detection

Twelve biological domain patterns (genomics, pharmacology, ecology, neuroscience, cell biology, immunology, cancer biology, molecular biology, microbiology, plant biology, marine biology, bioimaging) are matched against the task to produce a multi-label domain classification. This is used for:
  • Downstream tool and KG subgraph selection
  • Episodic memory domain filtering
  • Reporting and analytics

The Four Strategies

Strategy 1: SimpleReAct

When: Simple or direct tasks (lookups, conversions, single-step data questions). How: An enhanced ReAct loop:
  1. LLM produces a short numbered plan with checkboxes.
  2. Execute one step; observe output.
  3. Update plan with [✓]/[✗]; repeat until done or max steps reached.
Benefit: Up to ~3× speedup over the full multi-agent pipeline for simple tasks.

Strategy 2: DAG Parallel

When: Structured multi-step workflows (typical bioinformatics pipelines). How:
  1. Planner decomposes the task into a TaskDAG (nodes = subtasks, edges = dependencies).
  2. Execution proceeds by topological levels; within each level, all ready nodes run in parallel (asyncio.gather()).
  3. Each node: Execute → Validate (Critic) → Retry if needed (reflection-guided repair, deep retry, or LATM).
  4. Synthesizer compiles results into a single final report.
Benefit: Parallelism and isolation of failures; full self-correction and provenance tracking.

Strategy 3: MCTS (Exploratory)

When: Open-ended tasks with high epistemic uncertainty where the optimal analysis path is unknown a priori (e.g. drug discovery, candidate screening, target identification). How:
  1. Select: UCB1-guided traversal from the root to a leaf or expandable node.
  2. Expand: LLM generates several candidate next actions.
  3. Simulate: LLM estimates the value (reward) of the path.
  4. Backpropagate: Update visit counts and average rewards along the path.
  5. After a fixed budget of iterations, extract the best path (most-visited children).
  6. Convert the path to a DAG and execute via the standard pipeline.
Benefit: Exploration of multiple reasoning paths instead of greedy sequential steps. Ideal when you don’t know which tools or analyses will be most informative.

Strategy 4: Hypothesis (Scientific Reasoning)

When: Open-ended scientific questions requiring iterative hypothesis generation, testing, and refinement. Examples:
  • “What causes resistance to immunotherapy in triple-negative breast cancer?”
  • “Propose a mechanism by which FOXP3 suppresses effector T-cell activation.”
  • “What are novel biomarkers for early-stage pancreatic cancer?”
  • “How does KRAS G12C mutation drive resistance to targeted therapy?”
How: A Generate → Test → Evaluate → Refine loop across multiple rounds:
PhaseAction
GenerateLLM produces 3–5 distinct, falsifiable candidate hypotheses (statement + mechanism + testable prediction).
DesignFor each active hypothesis, design a targeted test: code execution, literature search, knowledge-graph query, or pure reasoning.
ExecuteRun the test (sandbox code / PubMed+Semantic Scholar / KG / LLM reasoning).
EvaluateScore evidence polarity (supports / contradicts / neutral) and confidence. Contradicting evidence is penalized 1.5×.
UpdateMark hypotheses as supported, rejected, or converged (confidence ≥ threshold).
RefineAfter round 2+, surviving hypotheses are refined based on accumulated evidence to avoid repeating failed directions.
SynthesizeProduce a final scientific report: leading hypothesis + evidence trail + alternative hypotheses + recommended next steps.
Evidence scoring (net_confidence):
net_confidence = 0.5 + (Σ evidence_for - 1.5 × Σ evidence_against) / (2 × total)
Converges when net_confidence ≥ 0.80 (default, configurable) after at least 2 rounds. Inspired by:
  • Biomni A1<think>/<execute>/<observe> checklist loop with [✓]/[✗] markers
  • PantheonOS Evolution — Analyzer → Mutator → Evaluator with failed-hypothesis history (avoid repeating rejected directions)
  • CellType CLIEvidenceReasoner with weighted claim scoring and contradiction detection
Benefit: Structured scientific reasoning with explicit evidence accumulation, contradiction tracking, and a full audit trail — rather than a single LLM answer pass.

Hypothesis Trigger Keywords

The following patterns automatically route to the Hypothesis strategy (heuristic phase):
PatternExample
hypothesis (any context)“Generate a hypothesis about X”
propose mechanism”Propose a mechanism for FOXP3 suppression”
what causes”What causes drug resistance in NSCLC?”
could … cause”Could BRCA1 loss cause genomic instability?”
mechanism of/behind/for”Mechanism of cisplatin resistance”
why does/do … [disease/resistance]”Why do tumors evade immune checkpoint therapy?”
generate hypothesis”Generate hypotheses about aging”
novel biomarker”Identify novel biomarkers for early PDAC”
potential mechanism”What are potential mechanisms for X?”
how does … resist/evade/escape”How does GBM evade temozolomide?”
propose … target/candidate/pathway”Propose candidate drug targets for ALS”

Strategy Comparison

DimensionSimpleReActDAG ParallelMCTSHypothesis
Best forDirect Q&A, conversionsMulti-step pipelinesUnknown optimal pathScientific mechanism questions
PlanningChecklist planFull TaskDAGTree search pathRound-by-round design
ParallelismSequentialWithin-level parallelSequentialPer-hypothesis parallel
Self-correctionRetry loopReflection + deep retryPath re-selectionContradiction tracking + refinement
OutputCode result / answerSynthesis reportSynthesis reportEvidence-annotated scientific report
Token costLowMedium–HighHighMedium (bounded by rounds)

Forcing a Strategy

Override auto-routing from the CLI or API:
# CLI flag
biocortex run -s hypothesis "What drives EMT in pancreatic cancer?"
biocortex cli  # then: /strategy hypothesis

# Python API
agent.go(task, strategy=ReasoningStrategy.HYPOTHESIS)

Configuration

Strategy selection thresholds and LLM usage can be influenced by config (e.g. confidence threshold for LLM fallback, Hypothesis convergence threshold, max rounds). See Configuration for relevant options.

Next Steps