# Tree of Thoughts Investigation Reasoning

## Overview

A financial crime analyst investigating a complex syndicate has three credible theories on the table: the funds are being layered through shell companies in two jurisdictions, the account holder is a nominee for a politically exposed person, or the activity is coordinated with a related investigation already under a court restraint order. Each theory implies a different sequence of next actions. Pursuing only the first theory and ignoring the others risks missing the correct path entirely.

The Tree of Thoughts Investigation Reasoning module addresses this problem by applying multi-hypothesis reasoning to complex investigations. Rather than producing a single chain of thought, the engine generates and evaluates multiple competing hypotheses simultaneously, prunes the least plausible branches, expands the survivors to deeper reasoning levels, and synthesizes a final recommendation from the best-scoring branch. Analysts receive not just a recommendation but a full transparency view of every hypothesis the AI explored and the plausibility score assigned to each, so they can challenge or redirect the reasoning at any point.

Simple investigations with fewer than five entities continue to use standard single-pass RAG for speed. Tree of Thoughts activates automatically for complex investigations at the five-entity threshold.

```mermaid
flowchart TD
    A[Investigation Context] --> B[Generate Initial Hypotheses 3]
    B --> C1[Hypothesis 1]
    B --> C2[Hypothesis 2]
    B --> C3[Hypothesis 3]
    C1 --> D[Score All Hypotheses]
    C2 --> D
    C3 --> D
    D --> E[Prune to Top 2]
    E --> F1[Expand Hypothesis 1a]
    E --> F2[Expand Hypothesis 1b]
    E --> F3[Expand Hypothesis 2a]
    E --> F4[Expand Hypothesis 2b]
    F1 --> G[Score Second Level]
    F2 --> G
    F3 --> G
    F4 --> G
    G --> H[Synthesize Best Branch]
    H --> I[Final Recommendations]
```

**Last Reviewed:** 2026-04-14
**Last Updated:** 2026-04-14

## Key Features

- **Multi-Hypothesis BFS Exploration**: Breadth-first search explores three initial hypotheses at the root level, expanding the most plausible survivors at each depth level before pruning. This ensures competing theories are explicitly considered rather than collapsed into a single chain of thought.

- **LLM-Assessed Plausibility Scoring**: Each thought node receives a plausibility score from 0 to 1 assigned by Claude. The scoring prompt provides the full investigation context so scores reflect entity relationships, recent events, and available evidence rather than prior probability alone.

- **Transparent Thought Tree**: Every hypothesis generated and every score assigned is persisted to the tot_analyses audit table and exposed through the ToTThoughtTree frontend component. Analysts toggle between a synthesized final answer and the full reasoning tree, with each node showing its content, score, and position in the hierarchy.

- **Best-Branch Synthesis**: After pruning and expansion are complete, the engine identifies the highest-scoring branch and asks Claude to synthesize a coherent set of investigative actions from that branch. The synthesis is then parsed into structured NextBestAction objects via tool use, maintaining the same schema as single-pass RAG.

- **Fast Path for Simple Investigations**: Investigations with fewer than five entities bypass Tree of Thoughts and use the existing single-pass RAG path. The public recommend_next_actions interface is unchanged; routing is determined internally by entity count and ToTEngine availability.

- **Full Audit Trail**: Every ToT run is stored in tot_analyses with the complete thought tree as JSONB, the model used, synthesis confidence, and generation timestamp. The table is INSERT and SELECT only for the application role; no updates or deletes are permitted, satisfying ETSI TS 103 701 AI provenance requirements.

## Use Cases

- **Complex Financial Crime Investigation**: An analyst investigating a multi-entity financial crime case where multiple competing theories about layering routes, beneficial ownership, or coordination with known networks need simultaneous evaluation. Tree of Thoughts explores each theory to a depth of three reasoning levels before synthesizing the strongest path forward.

- **Multi-Jurisdictional Network Analysis**: An investigation spanning entities in several jurisdictions where different legal frameworks, reporting obligations, and investigative powers apply to different branches of the case. The engine generates jurisdiction-specific investigative hypotheses and scores them against the investigation evidence.

- **Cold Case Re-examination**: Re-opening a complex investigation where new evidence has been added. The engine re-generates hypotheses against the updated context, potentially scoring previously low-ranked theories more highly if new entities or events support them.

- **Analyst Reasoning Review**: A senior analyst reviewing the work of a junior team member uses the Show Reasoning view to inspect which hypotheses were considered and why the synthesized recommendation was ranked above alternatives.

## Integration

- **Investigation RAG Service**: Tree of Thoughts extends the existing InvestigationRAGService. The ToTEngine is injected at construction time; if not provided, the service falls back to single-pass RAG for all investigations. The public recommend_next_actions method signature is unchanged.
- **ToT Analysis GraphQL**: The get_tot_analysis query returns the most recent ToT record for an investigation, scoped to the caller's organization_id.
- **ToTThoughtTree Component**: Frontend component in the investigation UI. Renders the thought tree with score badges, best-branch highlighting, expand and collapse controls, and a toggle between the synthesized final answer and the full reasoning tree.
- **Audit Table**: tot_analyses persists every analysis run. Organization-scoped; queried only with org_id in the WHERE clause.

## Open Standards

- Yao, S. et al. (2023). Tree of Thoughts: Deliberate Problem Solving with Large Language Models. NeurIPS 2023. arXiv:2305.10601. Princeton NLP. Open research publication.
- Lewis, P. et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. NeurIPS 2020. arXiv:2005.11401. Used for single-pass fast path.
- ETSI TS 103 701: AI transparency in ICT systems. Governs model provenance logging and the audit trail requirements.
- Claude API (Anthropic). Used for thought generation, plausibility scoring, branch synthesis, and action parsing via tool use.
