REASONING_ENGINE v2.4.1 // initializing kernel
Loading strategy modules: 9 strategies detected
Oracle AI Vector Search adapter: connected
Mermaid renderer v10.9.1: initialized
Chart.js v4 analytics engine: ready
┌─────────────────────────────────────────────────────────────┐
│ ALL SYSTEMS NOMINAL — BEGIN COMPARATIVE ANALYSIS │
└─────────────────────────────────────────────────────────────┘

Reasoning Strategies // Compared

── 9 approaches to the same query, dissected ──

$ "What are the key advantages of using Oracle AI Vector Search for RAG applications?"

Strategy Matrix

# Strategy Pattern Depth LLM Calls Speed Best For Risk
01 STANDARD Direct call 1 step 1 FAST Simple factual queries No reasoning chain
02 CHAIN-OF-THOUGHT Sequential steps 3-5 steps 1 FAST Step-by-step analysis Linear, no backtrack
03 TREE OF THOUGHTS BFS + pruning widthdepth = 8 ~14+ SLOW Exploring alternatives High latency
04 ReAct Thought-Action loop 1-5 cycles 1-5 MEDIUM Tool-augmented tasks Tool reliability
05 SELF-REFLECTION Draft-Critique-Refine 1-5 iterations 2-10 MEDIUM Accuracy-critical answers Infinite loop risk
06 SELF-CONSISTENCY Multi-sample vote k=5 parallel 5 PARALLEL Consensus answers 5x cost
07 DECOMPOSED Split-Solve-Merge N + 1 N + 2 MEDIUM Complex multi-part queries Bad decomposition
08 LEAST-TO-MOST Easy-to-Hard chain N questions N + 1 MEDIUM Progressive understanding Ordering quality
09 RECURSIVE Code gen + exec 1-8 steps 1-8 SLOW Computation, iteration Code safety
─────────────────── ┤ DETAILED ANALYSIS ├ ───────────────────
01 // STANDARD strategy_standard.py
Pattern
Direct LLM call
Depth
1 step
LLM Calls
1
Latency Class
Minimal (~1-3s)
Prompt Template
prompt = f"Question: {query}\n\nAnswer:" # That's it. No chain, no reasoning scaffold. # Pure signal: question in, answer out.
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a', 'clusterBkg': '#0d0d0d', 'clusterBorder': '#00ff41', 'titleColor': '#00ff41' }}}%%
graph LR
    A["QUERY
Oracle AI Vector Search
advantages for RAG?"] --> B["GENERATE
Single LLM call"] B --> C["ANSWER
Direct response"] style A fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style B fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style C fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
Example Trace
INPUT ──> "What are the key advantages of using Oracle AI Vector Search for RAG applications?"
LLM ──> Generates complete answer in one pass
OUT ──> "Oracle AI Vector Search offers several advantages for RAG: integrated vector storage within Oracle DB, SQL-based similarity search, enterprise-grade security..."
+ Strength
Speed and simplicity. No overhead. Ideal baseline.
- Weakness
No reasoning chain. No self-correction. Black box output.
02 // CHAIN-OF-THOUGHT (CoT) strategy_cot.py
Pattern
Sequential step reasoning
Depth
~3-5 steps
Detection Regex
r"(?:Step\s*(\d+)|^(\d+)\.)"
LLM Calls
1 (with structured output)
Prompt Template
system = "Think step-by-step. Number each step (Step 1, Step 2, etc.)." prompt = f"""Think step-by-step about the following question. Number each step (Step 1, Step 2, etc.). After your reasoning, provide a clear final answer. Question: {query}""" # Detection: extract steps with regex steps = re.findall(r"(?:Step\s*(\d+)|^(\d+)\.)", response, re.MULTILINE)
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph LR
    Q["QUERY"] --> S1["Step 1
Identify what
Vector Search is"] S1 --> S2["Step 2
List RAG
requirements"] S2 --> S3["Step 3
Map advantages
to requirements"] S3 --> S4["Step 4
Compare with
alternatives"] S4 --> A["ANSWER
Synthesized
conclusion"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style S1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S4 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style A fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
Example Trace
Step 1 ──> Understand what Oracle AI Vector Search provides: native vector storage, HNSW/IVF indexes, SQL-based similarity queries inside Oracle DB.
Step 2 ──> Identify RAG pipeline needs: embedding storage, fast retrieval, metadata filtering, transactional consistency.
Step 3 ──> Map advantages: no separate vector DB needed, ACID compliance, unified SQL interface, enterprise security inherited.
Step 4 ──> Compare: vs Pinecone (managed but external), vs pgvector (less mature indexing), vs Chroma (no enterprise features).
ANSWER ──> Oracle AI Vector Search uniquely combines enterprise DB capabilities with vector similarity search, eliminating the need for a separate vector database in RAG architectures.
+ Strength
Transparent reasoning. Each step is auditable. Still only 1 LLM call.
- Weakness
Linear reasoning only. No self-correction if Step 2 is wrong, Step 3 builds on the error.
03 // TREE OF THOUGHTS (ToT) strategy_tot.py
Pattern
BFS exploration + pruning
Config
width=2, depth=3
Scoring Regex
r"Score:\s*(0\.\d+|1\.0)"
Total Candidates
2^3 = 8 paths explored
System Prompt
system = "You are a logic engine. Provide detailed, academic answers." # Phase 1: Generate `width` options at each node gen_prompt = f"Generate {width} different approaches to: {query}" # Phase 2: Score each option score_prompt = f"Score this approach (0.0 to 1.0): {option}" # Phase 3: Prune low-scoring, expand best at next depth score = re.search(r"Score:\s*(0\.\d+|1\.0)", response) # Repeat for `depth` levels, then synthesize best path
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    Q["QUERY"] --> A1["Option A
Focus on architecture
Score: 0.82"] Q --> B1["Option B
Focus on performance
Score: 0.71"] A1 --> A2["A.1
Unified DB layer
Score: 0.88"] A1 --> A3["A.2
SQL integration
Score: 0.79"] B1 --> B2["B.1
HNSW indexing
Score: 0.74"] B1 --> B3["B.2
Batch processing
Score: 0.65"] A2 --> A4["A.1.1 BEST
Score: 0.91"] A2 --> A5["A.1.2
Score: 0.77"] A3 --> A6["A.2.1
Score: 0.72"] A3 --> A7["A.2.2
Score: 0.68"] A4 --> F["FINAL ANSWER
Best path synthesis"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style A1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style B1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style A2 fill:#003300,stroke:#00ff41,stroke-width:1px,color:#00ff41 style A3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style B2 fill:#1a1a00,stroke:#555500,stroke-width:1px,color:#888844 style B3 fill:#1a1a00,stroke:#555500,stroke-width:1px,color:#888844 style A4 fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style A5 fill:#1a1a00,stroke:#555500,stroke-width:1px,color:#888844 style A6 fill:#1a1a00,stroke:#555500,stroke-width:1px,color:#888844 style A7 fill:#1a1a00,stroke:#555500,stroke-width:1px,color:#888844 style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
+ Strength
Explores multiple reasoning paths. Finds non-obvious angles. Scored pruning prevents wasted effort.
- Weakness
Very slow: ~14+ LLM calls minimum. High token cost. Scoring can be inconsistent.
04 // ReAct (Reasoning + Acting) strategy_react.py
Pattern
Thought-Action-Observation loop
Max Cycles
5
Available Tools
calculate[], web_search[], search[]
Stop Token
stop=["Observation:"]
Prompt Template
system = """You have access to these tools: calculate[expression] - evaluate math web_search[query] - search the web search[query] - search local knowledge base Format: Thought: your reasoning Action: tool_name[input] Observation: (filled by system — DO NOT generate) ... repeat ... Final Answer: your answer""" # Key: stop=["Observation:"] prevents LLM from hallucinating tool results
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    Q["QUERY"] --> T1["Thought 1
I need to understand
Oracle's vector capabilities"] T1 --> A1["Action
search[Oracle AI
Vector Search features]"] A1 --> O1["Observation
(system returns results)"] O1 --> T2["Thought 2
Now I need RAG-specific
advantages"] T2 --> A2["Action
search[Oracle vector
search RAG benefits]"] A2 --> O2["Observation
(system returns results)"] O2 --> T3["Thought 3
I have enough context
to answer"] T3 --> F["Final Answer"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style T1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style T2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style T3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style A1 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style A2 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style O1 fill:#001a1a,stroke:#00ffcc,stroke-width:1px,color:#00ffcc style O2 fill:#001a1a,stroke:#00ffcc,stroke-width:1px,color:#00ffcc style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
Example Trace
Thought 1 ──> I should search for Oracle AI Vector Search capabilities to understand the technical features.
Action ──> search[Oracle AI Vector Search features and capabilities]
Observe ──> Oracle AI Vector Search supports HNSW and IVF indexes, stores vectors alongside relational data, uses SQL for queries...
Thought 2 ──> Now I need to understand how these features specifically benefit RAG architectures.
Action ──> search[RAG architecture requirements vector database]
Observe ──> RAG requires: fast similarity search, metadata filtering, consistency, scalable storage...
Thought 3 ──> I can now synthesize both to provide a comprehensive answer about Oracle AI Vector Search advantages for RAG.
Final ──> Key advantages: unified storage eliminates ETL, ACID compliance ensures consistency, SQL-based hybrid search...
+ Strength
Can use external tools for grounded answers. Stop token prevents hallucinated observations.
- Weakness
Tool reliability is a single point of failure. Unpredictable cycle count.
05 // SELF-REFLECTION strategy_self_reflection.py
Pattern
Draft → Critique → Refine loop
Max Iterations
5
Exit Condition
"CORRECT" in critique.upper() and len(critique) < 20
LLM Calls
2-10 (draft + critique per iter)
Prompt Template
# Phase 1: Generate draft draft_prompt = f"Answer this question: {query}" # Phase 2: Critique the draft critique_prompt = f"""Review this answer: {draft} Is this answer CORRECT and COMPLETE? If not, explain what's wrong or missing.""" # Exit check: short "CORRECT" response means approval if "CORRECT" in critique.upper() and len(critique) < 20: break # Accept the draft # Phase 3: Refine using critique refine_prompt = f"Improve this answer based on the critique:\n{draft}\nCritique: {critique}"
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    Q["QUERY"] --> D1["Draft v1
Initial answer"] D1 --> C1{"Critique
CORRECT?"} C1 -->|"NO: missing
security aspects"| R1["Refine v2
Add security
details"] R1 --> C2{"Critique
CORRECT?"} C2 -->|"NO: missing
cost comparison"| R2["Refine v3
Add cost
analysis"] R2 --> C3{"Critique
CORRECT?"} C3 -->|"YES"| F["FINAL ANSWER
Refined v3 accepted"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style D1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style C1 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style C2 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style C3 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style R1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style R2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
+ Strength
Self-correcting. Each iteration improves on identified flaws. Converges toward completeness.
- Weakness
May loop without real improvement. Critique quality is itself LLM-dependent. 2x calls per iteration.
06 // SELF-CONSISTENCY strategy_self_consistency.py
Pattern
Multiple samples + majority vote
Config
k=5, temperature=0.7
Answer Regex
r"Final Answer:\s*(.*)"
Selection
collections.Counter majority
Prompt Template
# Same prompt sent k=5 times at temperature=0.7 prompt = f"""Think step-by-step about this question. After reasoning, state your answer as: Final Answer: [your answer] Question: {query}""" # Extract from each sample answers = [] for response in samples: match = re.search(r"Final Answer:\s*(.*)", response) if match: answers.append(match.group(1).strip()) # Majority vote winner = Counter(answers).most_common(1)[0][0]
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    Q["QUERY"] --> S1["Sample 1
t=0.7
Unified storage"] Q --> S2["Sample 2
t=0.7
SQL integration"] Q --> S3["Sample 3
t=0.7
Unified storage"] Q --> S4["Sample 4
t=0.7
Unified storage"] Q --> S5["Sample 5
t=0.7
ACID compliance"] S1 --> V["MAJORITY VOTE
Counter analysis"] S2 --> V S3 --> V S4 --> V S5 --> V V --> F["WINNER
Unified storage (3/5)"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style S1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S4 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S5 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style V fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
+ Strength
Robust to randomness. Statistical consensus. Parallelizable for speed.
- Weakness
5x token cost. All samples may converge on same wrong answer. Majority != correctness.
07 // DECOMPOSED strategy_decomposed.py
Pattern
Decompose → Solve each → Synthesize
Depth
N sub-tasks + 1 synthesis
Context Passing
Cumulative (each task sees prior results)
LLM Calls
N + 2 (decompose + N solve + synthesize)
Prompt Template
# Phase 1: Decompose into sub-tasks decompose_prompt = f"""Break this question into smaller sub-tasks. List each as a numbered task. Question: {query}""" # Phase 2: Solve each sub-task (with context from prior tasks) for i, task in enumerate(sub_tasks): context = "\n".join(prior_results) solve_prompt = f"""Context from prior tasks: {context} Now solve: {task}""" # Phase 3: Synthesize all results synth_prompt = f"""Based on these sub-task results: {all_results} Provide a comprehensive answer to: {query}"""
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    Q["QUERY"] --> D["DECOMPOSE
Break into sub-tasks"] D --> T1["Task 1
What is Oracle AI
Vector Search?"] D --> T2["Task 2
What does RAG
require?"] D --> T3["Task 3
What are the
advantages?"] T1 -->|"result 1"| T2 T2 -->|"result 1+2"| T3 T3 --> S["SYNTHESIZE
Combine all results
into final answer"] S --> F["FINAL ANSWER"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style D fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style T1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style T2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style T3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style S fill:#001a1a,stroke:#00ffcc,stroke-width:1px,color:#00ffcc style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
+ Strength
Handles complex multi-part queries. Each sub-task gets focused attention. Context accumulates.
- Weakness
Decomposition quality is critical. Bad split = bad final answer. Extra LLM call overhead.
08 // LEAST-TO-MOST strategy_least_to_most.py
Pattern
Easy → Hard with accumulation
Depth
N sub-questions
Key Difference
No explicit synthesis; last answer = final answer
LLM Calls
N + 1 (decompose + N answers)
Prompt Template
# Phase 1: Generate ordered sub-questions (easy to hard) decompose_prompt = f"""Break this into sub-questions ordered from simplest to most complex: Question: {query}""" # Phase 2: Solve in order, each seeing previous answers accumulated = [] for q in ordered_sub_questions: context = "\n".join(accumulated) solve_prompt = f"""Previously answered: {context} Now answer: {q}""" accumulated.append(answer) # The LAST answer IS the final answer (no separate synthesis) final_answer = accumulated[-1]
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph LR
    Q["QUERY"] --> D["DECOMPOSE
Order by difficulty"] D --> E1["EASY
What is vector
search?"] E1 -->|"+ answer 1"| E2["MEDIUM
What is RAG
architecture?"] E2 -->|"+ answer 1,2"| E3["HARD
How does Oracle
vector search help
RAG specifically?"] E3 -->|"+ answer 1,2,3"| E4["HARDEST
What unique advantages
does it have over
alternatives?"] E4 --> F["FINAL
= Last answer"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style D fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style E1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style E2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style E3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style E4 fill:#003300,stroke:#00ff41,stroke-width:1px,color:#00ff41 style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
Example Trace
Q1 [EASY] ──> "What is vector search?" → A technique for finding similar items using vector embeddings...
Q2 [MED] ──> "What is RAG?" → (using Q1 answer) RAG retrieves relevant vectors then generates augmented responses...
Q3 [HARD] ──> "How does Oracle help RAG?" → (using Q1+Q2) Oracle embeds vector search inside the DB, eliminating separate vector stores...
Q4 [FINAL] ──> "What unique advantages?" → (using all) ACID transactions on vectors, SQL hybrid search, enterprise security, zero ETL pipeline...
+ Strength
Progressive understanding. Simple concepts scaffold complex ones. Natural learning order.
- Weakness
Ordering quality matters critically. If difficulty ranking is wrong, the chain degrades.
09 // RECURSIVE (Code Generation) strategy_recursive.py
Pattern
Python code gen + exec()
Max Steps
8
Code Regex
r"```python(.*?)```"
Env Tools
INPUT, sub_llm(), print, len, range
Prompt Template
system = """You are a Python code generator. To answer questions, write Python code that will be executed. Available in your environment: INPUT - the user's question (str) sub_llm(p) - call an LLM with prompt p, returns str print() - output observations len, range - standard builtins When done, set: FINAL_ANSWER = "your answer" Write code in ```python ... ``` blocks.""" # Code extraction code = re.search(r"```python(.*?)```", response, re.DOTALL).group(1) # Sandboxed execution env = {"INPUT": query, "sub_llm": sub_llm_fn, "print": capture_print, ...} exec(code, env) # Check for termination if "FINAL_ANSWER" in env: return env["FINAL_ANSWER"] # Otherwise: feed observation back, generate more code
Execution Flow
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    Q["QUERY"] --> G1["Generate Code 1
aspects = sub_llm(...)"] G1 --> X1["exec()
Run Python code"] X1 --> O1["Observation
print output captured"] O1 --> G2["Generate Code 2
details = sub_llm(...)
for aspect in aspects"] G2 --> X2["exec()
Run Python code"] X2 --> O2["Observation
detailed results"] O2 --> G3["Generate Code 3
FINAL_ANSWER = ..."] G3 --> X3["exec()
Run Python code"] X3 --> F["FINAL_ANSWER
extracted from env"] style Q fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style G1 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style G2 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style G3 fill:#0a3d0a,stroke:#39ff14,stroke-width:1px,color:#39ff14 style X1 fill:#1a0000,stroke:#ff3333,stroke-width:1px,color:#ff3333 style X2 fill:#1a0000,stroke:#ff3333,stroke-width:1px,color:#ff3333 style X3 fill:#1a0000,stroke:#ff3333,stroke-width:1px,color:#ff3333 style O1 fill:#001a1a,stroke:#00ffcc,stroke-width:1px,color:#00ffcc style O2 fill:#001a1a,stroke:#00ffcc,stroke-width:1px,color:#00ffcc style F fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
Example Generated Code
# Step 1: Decompose the question programmatically aspects = sub_llm("List 5 key aspects of Oracle AI Vector Search for RAG. One per line.") aspect_list = [a.strip() for a in aspects.split("\n") if a.strip()] print(f"Found {len(aspect_list)} aspects") # Step 2: Deep-dive each aspect results = [] for aspect in aspect_list: detail = sub_llm(f"Explain how '{aspect}' benefits RAG applications. 2-3 sentences.") results.append(f"{aspect}: {detail}") # Step 3: Compose final answer FINAL_ANSWER = "\n\n".join(results)
+ Strength
Can compute, iterate, branch. Full programming logic. Can call sub-LLMs in loops.
- Weakness
Code safety (exec is dangerous). High complexity. Generated code may have bugs or infinite loops.
─────────────────── ┤ RADAR ANALYSIS ├ ───────────────────

Multi-Axis Comparison

├── Axes: Speed (10=fastest), Depth (10=deepest reasoning), Accuracy (10=highest expected), Cost (10=cheapest), Explainability (10=most transparent)

─────────────────── ┤ DECISION MATRIX ├ ───────────────────
STRATEGY SELECTION // DECISION TREE selector.py
When to use which strategy
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#003300', 'primaryTextColor': '#00ff41', 'primaryBorderColor': '#00ff41', 'lineColor': '#39ff14', 'secondaryColor': '#0a3d0a', 'tertiaryColor': '#0a0a0a', 'edgeLabelBackground': '#0a0a0a' }}}%%
graph TD
    START["INCOMING QUERY"] --> Q1{"Need external
data/tools?"} Q1 -->|"YES"| REACT["ReAct
Tool-augmented"] Q1 -->|"NO"| Q2{"Simple
factual?"} Q2 -->|"YES"| STD["Standard
Direct call"] Q2 -->|"NO"| Q3{"Need high
accuracy?"} Q3 -->|"YES"| Q4{"Budget for
5x calls?"} Q4 -->|"YES"| SC["Self-Consistency
Majority vote"] Q4 -->|"NO"| SR["Self-Reflection
Draft + Refine"] Q3 -->|"NO"| Q5{"Multi-part
question?"} Q5 -->|"YES"| Q6{"Need synthesis
step?"} Q6 -->|"YES"| DEC["Decomposed
Split + Merge"] Q6 -->|"NO"| LTM["Least-to-Most
Easy to Hard"] Q5 -->|"NO"| Q7{"Need to explore
alternatives?"} Q7 -->|"YES"| TOT["Tree of Thoughts
BFS + Prune"] Q7 -->|"NO"| Q8{"Need
computation?"} Q8 -->|"YES"| REC["Recursive
Code Gen"] Q8 -->|"NO"| COT["Chain-of-Thought
Step-by-step"] style START fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style Q1 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q2 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q3 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q4 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q5 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q6 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q7 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style Q8 fill:#1a1a00,stroke:#ffb000,stroke-width:1px,color:#ffb000 style STD fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style COT fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style TOT fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style REACT fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style SR fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style SC fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style DEC fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style LTM fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41 style REC fill:#003300,stroke:#00ff41,stroke-width:2px,color:#00ff41
Quick Reference — Strategy Selector
def select_strategy(query_metadata): """Route queries to optimal reasoning strategy.""" if query_metadata.needs_tools: return "react" # External data needed if query_metadata.is_simple: return "standard" # Don't overthink it if query_metadata.accuracy_critical: if query_metadata.budget >= 5: return "self_consistency" # k=5 majority vote return "self_reflection" # Draft-critique loop if query_metadata.is_multi_part: if query_metadata.needs_synthesis: return "decomposed" # Split-solve-merge return "least_to_most" # Progressive buildup if query_metadata.explore_alternatives: return "tree_of_thoughts" # BFS exploration if query_metadata.needs_computation: return "recursive" # Code generation return "chain_of_thought" # Default: step-by-step