Table of Contents

Choose the Right Planning Strategy for Your Agent

Every LM-Kit.NET agent uses a planning strategy that controls how it reasons before, during, and after generating a response. The PlanningStrategy enum offers six options ranging from zero-overhead direct responses to multi-branch exploratory reasoning. Choosing the wrong strategy wastes tokens on simple tasks or produces shallow answers on complex ones. This guide walks through each strategy with working code, explains when to use it, and gives you a decision framework for picking the right one.


TL;DR

var agent = Agent.CreateBuilder(model)
    .WithPlanning(PlanningStrategy.ReAct)  // change this to match your use case
    .Build();
If your agent needs to... Use
Answer simple questions fast None
Reason through math or logic ChainOfThought
Call tools (search, APIs, calculators) ReAct
Execute a complex multi-step plan PlanAndExecute
Produce high-accuracy, self-checked output Reflection
Explore multiple creative solutions TreeOfThought

Why This Matters

Two problems that strategy selection solves:

  1. Wasted tokens on simple tasks. Running TreeOfThought for a "What time is it?" query generates three candidate approaches, evaluates each on a 1-10 scale, and selects the best. That is dozens of unnecessary inference calls for a one-tool lookup. Using None or ReAct returns the answer in a fraction of the time and cost.
  2. Shallow answers on complex tasks. Using None for "Research the competitive landscape and write a strategy memo" skips all planning. The model produces a single-pass response with no tool calls, no self-checking, and no structured decomposition. PlanAndExecute or Reflection would produce dramatically better output for the same model.

The right strategy matches the cognitive demand of the task to the reasoning overhead of the strategy.


Prerequisites

Requirement Minimum
.NET SDK 8.0+
VRAM 4+ GB (for a 4B model)
Model Any LM-Kit.NET supported model. Tool-calling models recommended for ReAct

Strategy Overview

Strategy How It Works Token Cost Latency Best For Avoid When
None Direct response. No reasoning scaffolding. Lowest Fastest Simple Q&A, pipeline stages, high-throughput endpoints Tasks requiring reasoning or tools
ChainOfThought Adds "Let's think step by step" prompt. Model reasons linearly, then outputs a "Final Answer:" marker. Low Low Math, logic puzzles, multi-step analysis without tools Tool-calling agents (no action loop)
ReAct Thought/Action/Observation loop. Agent reasons, calls a tool, observes the result, repeats. Medium Medium Any agent that uses tools: search, APIs, calculations Tasks with no tools (adds overhead for nothing)
PlanAndExecute Two phases: (1) generate a numbered plan, (2) execute each step, (3) synthesize results. Medium-High Medium-High Complex multi-step tasks with clear decomposition Simple questions, latency-sensitive workloads
Reflection Generate, then self-critique, then refine. Configurable cycles (default: 1). High (2-3x base) High (2-3x base) Accuracy-critical output: legal, medical, compliance, content quality Real-time chat, latency-sensitive endpoints
TreeOfThought Generates multiple candidate approaches (default: 3 branches), scores each 1-10, selects the best. Highest Highest Ambiguous problems, creative tasks, problems with multiple valid solutions Well-defined tasks with a single correct answer

Step 1: None (Direct Response)

The simplest strategy. The agent generates a response with no reasoning scaffolding, no tool loop, and no self-reflection. Use this for high-throughput scenarios where every millisecond counts, or for agents that serve as individual stages in a pipeline orchestrator.

using System.Text;
using LMKit.Model;
using LMKit.Agents;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

// Load model
Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:4b",
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Build agent with no planning
var agent = Agent.CreateBuilder(model)
    .WithPersona("Quick Responder")
    .WithInstruction("Answer questions directly and concisely. Do not elaborate unless asked.")
    .WithPlanning(PlanningStrategy.None)
    .Build();

var result = await agent.RunAsync("What is the capital of France?");

if (result.IsSuccess)
    Console.WriteLine($"Answer: {result.Content}");

When to use None:

  • Simple factual Q&A where the model already knows the answer.
  • Pipeline stages in a PipelineOrchestrator where each agent has a narrow, well-defined role.
  • High-throughput batch processing where latency per request must be minimal.
  • Agents that rely entirely on their system prompt and do not need tools.

Step 2: ChainOfThought (Step-by-Step Reasoning)

The agent receives a "Let's think step by step" prompt injection that encourages linear reasoning before producing a final answer. The framework looks for the Final Answer: marker to extract the result. This adds minimal overhead while significantly improving accuracy on reasoning tasks.

using System.Text;
using LMKit.Model;
using LMKit.Agents;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:4b",
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Build agent with Chain-of-Thought planning
var agent = Agent.CreateBuilder(model)
    .WithPersona("Math Tutor")
    .WithInstruction("You solve math and logic problems. Show your work clearly, " +
                     "then provide the final numeric answer.")
    .WithPlanning(PlanningStrategy.ChainOfThought)
    .Build();

var result = await agent.RunAsync(
    "A store sells apples for $1.50 each and oranges for $2.00 each. " +
    "If I buy 4 apples and 3 oranges, and I have a 10% discount coupon, " +
    "how much do I pay?");

if (result.IsSuccess)
{
    Console.WriteLine($"Answer: {result.Content}");

    // The reasoning trace shows the step-by-step logic
    if (!string.IsNullOrEmpty(result.ReasoningTrace))
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"\nReasoning:\n{result.ReasoningTrace}");
        Console.ResetColor();
    }
}

Example reasoning trace:

Step 1: Calculate cost of apples: 4 * $1.50 = $6.00
Step 2: Calculate cost of oranges: 3 * $2.00 = $6.00
Step 3: Calculate subtotal: $6.00 + $6.00 = $12.00
Step 4: Apply 10% discount: $12.00 * 0.10 = $1.20
Step 5: Calculate final total: $12.00 - $1.20 = $10.80

Final Answer: $10.80

When to use ChainOfThought:

  • Math word problems and arithmetic.
  • Logic puzzles and deduction tasks.
  • Multi-step analysis where the model needs to reason before answering.
  • Tasks where you want to audit the model's reasoning process.

Step 3: ReAct (Reasoning + Acting with Tools)

The agent enters a structured loop of Thought: (reason about what to do), Action: (call a tool), Observation: (interpret the tool's result), and repeats until it reaches a Final Answer:. This is the recommended default for any agent that uses tools.

using System.Text;
using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Tools.BuiltIn;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:4b",
    downloadingProgress: (_, len, read) =>
    {
        if (len.HasValue) Console.Write($"\r  Downloading: {(double)read / len.Value * 100:F1}%   ");
        return true;
    },
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Build agent with ReAct planning and tools
var agent = Agent.CreateBuilder(model)
    .WithPersona("Research Assistant")
    .WithInstruction("You help users find accurate, current information. " +
                     "Always use web search for factual questions about recent events. " +
                     "Use the calculator for any numeric computations. " +
                     "Cite your sources.")
    .WithPlanning(PlanningStrategy.ReAct)
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.WebSearch);    // DuckDuckGo, no API key
        tools.Register(BuiltInTools.Calculator);
        tools.Register(BuiltInTools.DateTime);
    })
    .WithMaxIterations(10)
    .Build();

var result = await agent.RunAsync(
    "What is the current population of Tokyo, and what percentage of Japan's total population does it represent?");

if (result.IsSuccess)
{
    Console.ForegroundColor = ConsoleColor.Cyan;
    Console.WriteLine($"Answer: {result.Content}");
    Console.ResetColor();

    // Show the Thought/Action/Observation trace
    if (!string.IsNullOrEmpty(result.ReasoningTrace))
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"\nReasoning trace:\n{result.ReasoningTrace}");
        Console.ResetColor();
    }

    // Show tool calls
    if (result.ToolCalls.Count > 0)
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"\nTools used: {string.Join(", ", result.ToolCalls.Select(tc => tc.ToolName))}");
        Console.ResetColor();
    }
}

Example ReAct loop:

Thought: I need to find the current population of Tokyo and Japan's total population,
         then calculate the percentage.
Action: web_search("current population of Tokyo 2025")
Observation: Tokyo metropolitan area population is approximately 13.96 million...

Thought: Now I need Japan's total population to calculate the percentage.
Action: web_search("current population of Japan 2025")
Observation: Japan's population is approximately 123.9 million...

Thought: I can now calculate the percentage.
Action: calculator("13960000 / 123900000 * 100")
Observation: 11.27

Final Answer: Tokyo has a population of approximately 13.96 million, which represents
about 11.3% of Japan's total population of 123.9 million.

When to use ReAct:

  • Any agent that calls tools (web search, APIs, file operations, databases).
  • Research tasks that require gathering information from multiple sources.
  • Tasks where the agent needs to adapt its approach based on intermediate results.
  • Interactive assistants that need to decide whether a question requires a tool or can be answered directly.

Step 4: PlanAndExecute (Structured Multi-Step Planning)

The agent operates in two distinct phases. First, it generates a numbered plan outlining all steps needed to complete the task. Then, it executes each step in order, tracking progress. Finally, it synthesizes the results into a cohesive response. This strategy excels at tasks that benefit from upfront decomposition.

using System.Text;
using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Tools.BuiltIn;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:8b",
    downloadingProgress: (_, len, read) =>
    {
        if (len.HasValue) Console.Write($"\r  Downloading: {(double)read / len.Value * 100:F1}%   ");
        return true;
    },
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Build agent with PlanAndExecute strategy
var agent = Agent.CreateBuilder(model)
    .WithPersona("Strategic Analyst")
    .WithInstruction("You research topics thoroughly and produce well-structured reports. " +
                     "Break complex requests into clear steps before executing them.")
    .WithPlanning(PlanningStrategy.PlanAndExecute)
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.WebSearch);
        tools.Register(BuiltInTools.Calculator);
    })
    .WithMaxIterations(15)
    .Build();

var result = await agent.RunAsync(
    "Compare the renewable energy adoption rates of Germany, China, and the United States. " +
    "Include solar and wind capacity for each country, then rank them by percentage of " +
    "total energy from renewables.");

if (result.IsSuccess)
{
    Console.ForegroundColor = ConsoleColor.Cyan;
    Console.WriteLine($"Report:\n{result.Content}");
    Console.ResetColor();

    // The reasoning trace shows the generated plan and execution of each step
    if (!string.IsNullOrEmpty(result.ReasoningTrace))
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"\nPlanning trace:\n{result.ReasoningTrace}");
        Console.ResetColor();
    }
}

Example plan generated by the agent:

Plan:
1. Search for Germany's current solar and wind energy capacity
2. Search for China's current solar and wind energy capacity
3. Search for the United States' current solar and wind energy capacity
4. Search for each country's total energy consumption and renewable percentage
5. Calculate and compare the renewable energy percentages
6. Rank the countries and synthesize the findings into a report

When to use PlanAndExecute:

  • Complex research tasks that require information from multiple sources.
  • Report generation where the output has clear sections.
  • Tasks where the user's request naturally decomposes into ordered steps.
  • Scenarios where you want the agent to commit to a plan before spending tokens on execution.

Step 5: Reflection (Self-Critique and Refinement)

The agent generates an initial response, then enters a reflect-and-refine cycle. In each cycle, it critiques its own output, identifies weaknesses, and produces an improved version. The number of reflection cycles is configurable (default: 1 cycle). Each cycle roughly doubles the token cost and latency, so this strategy is reserved for tasks where accuracy justifies the overhead.

using System.Text;
using LMKit.Model;
using LMKit.Agents;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:8b",
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Build agent with Reflection strategy
var agent = Agent.CreateBuilder(model)
    .WithPersona("Legal Document Reviewer")
    .WithInstruction("You review legal clauses for accuracy, completeness, and potential risks. " +
                     "Be thorough and flag any ambiguities or missing protections. " +
                     "After your initial review, critically examine your own analysis " +
                     "for anything you may have missed.")
    .WithPlanning(PlanningStrategy.Reflection)
    .Build();

var result = await agent.RunAsync(
    "Review this clause: 'The Contractor shall deliver the software by December 31, 2025. " +
    "In the event of delay, the Client may terminate the agreement with 30 days notice. " +
    "The Contractor's total liability shall not exceed the fees paid under this agreement.'");

if (result.IsSuccess)
{
    Console.ForegroundColor = ConsoleColor.Cyan;
    Console.WriteLine($"Review:\n{result.Content}");
    Console.ResetColor();

    // The reasoning trace shows the generate-reflect-refine cycle
    if (!string.IsNullOrEmpty(result.ReasoningTrace))
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"\nReflection trace:\n{result.ReasoningTrace}");
        Console.ResetColor();
    }
}

Example reflection cycle:

[Initial Response]
The clause has three key provisions: delivery deadline, termination rights, and
liability cap. Issues identified: (1) No force majeure exception for delays...

[Reflection]
My initial analysis missed several important points:
- I did not address whether "fees paid" means fees paid to date or total contract value
- I did not flag the lack of a cure period before termination
- I should have noted that 30 days notice during a delay creates ambiguity...

[Refined Response]
The clause contains five issues requiring attention:
1. No force majeure or excusable delay provision...
2. Ambiguous liability cap: "fees paid" could mean fees paid to date or total fees...
3. No cure period: the Client can terminate without giving the Contractor a chance to fix...

When to use Reflection:

  • Legal, medical, or compliance document review where missing an issue has high consequences.
  • Content generation where quality must be publication-ready.
  • Accuracy-critical data extraction where errors are costly.
  • Any task where you would normally ask a human to "double-check their work."

Step 6: TreeOfThought (Multi-Branch Exploration)

The agent generates multiple candidate approaches (default: 3 branches), evaluates each on a 1-10 scale, and selects the highest-scoring approach as its final answer. This strategy has the highest computational cost but excels when the problem is ambiguous or has multiple valid solutions.

using System.Text;
using LMKit.Model;
using LMKit.Agents;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:8b",
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Build agent with TreeOfThought strategy
var agent = Agent.CreateBuilder(model)
    .WithPersona("Product Strategist")
    .WithInstruction("You help teams explore product strategy options. " +
                     "Consider multiple approaches, evaluate trade-offs, " +
                     "and recommend the strongest path forward with clear reasoning.")
    .WithPlanning(PlanningStrategy.TreeOfThought)
    .Build();

var result = await agent.RunAsync(
    "Our SaaS startup has 500 paying customers and is growing 15% month-over-month. " +
    "We have runway for 8 months. Should we focus on (a) raising a Series A, " +
    "(b) reaching profitability by cutting costs, or (c) accelerating growth to " +
    "improve fundraising metrics? Consider the risks and trade-offs of each approach.");

if (result.IsSuccess)
{
    Console.ForegroundColor = ConsoleColor.Cyan;
    Console.WriteLine($"Recommendation:\n{result.Content}");
    Console.ResetColor();

    // The reasoning trace shows all branches and their scores
    if (!string.IsNullOrEmpty(result.ReasoningTrace))
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"\nExploration trace:\n{result.ReasoningTrace}");
        Console.ResetColor();
    }
}

Example branch evaluation:

Branch 1: Raise Series A immediately
  Approach: Begin fundraising now with current metrics (500 customers, 15% MoM)
  Pros: Extends runway, enables hiring
  Cons: Current metrics may not command strong valuation
  Score: 6/10

Branch 2: Cut costs to reach profitability
  Approach: Reduce burn rate by 40%, reach break-even in 4 months
  Pros: Eliminates runway pressure, fundraise from position of strength
  Cons: May slow growth, risk losing competitive window
  Score: 5/10

Branch 3: Accelerate growth for 3 months, then raise
  Approach: Invest in growth for 3 months to reach 800+ customers, then fundraise
  Pros: Stronger metrics improve valuation and terms significantly
  Cons: Reduces runway to 5 months, increases pressure
  Score: 8/10

Selected: Branch 3

When to use TreeOfThought:

  • Strategic decisions with multiple valid approaches.
  • Creative tasks (writing, design, naming) where exploring alternatives improves quality.
  • Ambiguous problems where the best solution is not obvious upfront.
  • Brainstorming scenarios where you want the model to consider diverse options.

Inspecting the Reasoning Trace

Every AgentExecutionResult includes a ReasoningTrace property that captures the internal reasoning steps, regardless of which strategy was used. This is invaluable for debugging, auditing, and understanding why the agent produced a particular answer.

using System.Text;
using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Tools.BuiltIn;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:4b",
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

var agent = Agent.CreateBuilder(model)
    .WithPersona("Assistant")
    .WithInstruction("Answer questions accurately.")
    .WithPlanning(PlanningStrategy.ReAct)
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.Calculator);
    })
    .Build();

var result = await agent.RunAsync("What is 17 factorial?");

if (result.IsSuccess)
{
    // Final answer
    Console.WriteLine($"Answer: {result.Content}");

    // Full reasoning trace (Thought/Action/Observation steps for ReAct,
    // step-by-step logic for ChainOfThought, branch evaluations for TreeOfThought, etc.)
    if (!string.IsNullOrEmpty(result.ReasoningTrace))
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine("\n--- Reasoning Trace ---");
        Console.WriteLine(result.ReasoningTrace);
        Console.ResetColor();
    }

    // Tool call details
    foreach (var call in result.ToolCalls)
    {
        Console.ForegroundColor = ConsoleColor.DarkGray;
        Console.WriteLine($"  Tool: {call.ToolName}, Result: {call.ResultJson}");
        Console.ResetColor();
    }

    // Execution metadata
    Console.ForegroundColor = ConsoleColor.DarkGray;
    Console.WriteLine($"  Duration: {result.Duration.TotalSeconds:F1}s, Inferences: {result.InferenceCount}");
    Console.ResetColor();
}

The ReasoningTrace content varies by strategy:

Strategy Trace Contains
None Empty or minimal
ChainOfThought Step-by-step reasoning leading to "Final Answer:"
ReAct Thought/Action/Observation loop iterations
PlanAndExecute The numbered plan, then execution logs for each step
Reflection Initial response, self-critique, and refined response
TreeOfThought All candidate branches with scores and the selection rationale

Decision Flowchart

Use these questions in order to narrow down the right strategy:

  1. Does the task require calling tools (web search, APIs, calculators)? Yes: use ReAct. It provides the Thought/Action/Observation loop that tool-calling agents need.

  2. Is the task complex enough to need a multi-step plan? Yes: use PlanAndExecute. It commits to a structured plan before executing, which prevents wandering.

  3. Is accuracy critical, and is 2-3x latency acceptable? Yes: use Reflection. The self-critique cycle catches errors the initial response missed.

  4. Does the problem have multiple valid solutions or approaches? Yes: use TreeOfThought. Exploring branches surfaces solutions the model might miss with linear reasoning.

  5. Does the task involve math, logic, or multi-step reasoning (but no tools)? Yes: use ChainOfThought. Step-by-step reasoning significantly improves accuracy at minimal cost.

  6. Is the task simple, or is latency the top priority? Yes: use None. Zero overhead, direct response.

When in doubt, start with ReAct for tool-using agents and ChainOfThought for reasoning-only agents. These two strategies cover the majority of use cases with a good balance of quality and efficiency.


Combining Strategies with Multi-Agent Workflows

In a multi-agent architecture, different agents can use different planning strategies. A supervisor agent might use ChainOfThought to reason about which worker to delegate to, while the worker uses ReAct to execute the task with tools.

using System.Text;
using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Orchestration;
using LMKit.Agents.Tools.BuiltIn;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:8b",
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// Supervisor uses ChainOfThought to reason about delegation
var supervisorAgent = Agent.CreateBuilder(model)
    .WithPersona("Team Lead")
    .WithInstruction("You manage a team. Analyze each request and decide which specialist " +
                     "should handle it. Think through the request type before delegating.")
    .WithPlanning(PlanningStrategy.ChainOfThought)
    .Build();

// Research worker uses ReAct to call tools
var researcher = Agent.CreateBuilder(model)
    .WithPersona("Researcher")
    .WithInstruction("You research topics using web search and provide factual, sourced answers.")
    .WithPlanning(PlanningStrategy.ReAct)
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.WebSearch);
        tools.Register(BuiltInTools.Calculator);
    })
    .WithMaxIterations(10)
    .Build();

// Writer uses Reflection to produce polished content
var writer = Agent.CreateBuilder(model)
    .WithPersona("Writer")
    .WithInstruction("You write clear, polished content. Review your own output " +
                     "for clarity and accuracy before finalizing.")
    .WithPlanning(PlanningStrategy.Reflection)
    .Build();

// Wire into a supervisor orchestrator
var supervisor = new SupervisorOrchestrator(supervisorAgent)
    .AddWorker(researcher)
    .AddWorker(writer);

var result = await supervisor.ExecuteAsync(
    "Find the latest quarterly revenue numbers for NVIDIA and write a brief summary paragraph.");

if (result.IsSuccess)
    Console.WriteLine(result.Content);

This pattern lets each agent use the strategy that best matches its role: fast reasoning for routing decisions, tool loops for data gathering, and self-reflection for polished output.


Troubleshooting

Problem Cause Fix
Agent never calls tools despite using ReAct Model does not support tool calling Check model.HasToolCalls after loading. Use qwen3:4b or gemma3:4b
ChainOfThought output includes reasoning in the final answer Model did not emit the Final Answer: marker Use a larger model (4B+) or rephrase the instruction to emphasize concise final answers
PlanAndExecute generates a plan but fails during execution Plan steps are too vague for the model to execute Add more specific instructions, or increase MaxIterations to give the agent more room
Reflection produces the same output on each cycle Model is too small to meaningfully self-critique Use an 8B+ model for Reflection. Smaller models tend to repeat rather than improve
TreeOfThought branches are too similar Model lacks diversity in generation Increase temperature via sampling configuration, or use a larger model with broader knowledge
Agent loops without reaching a final answer MaxIterations too low for the task complexity Increase MaxIterations. For PlanAndExecute with tools, 15-20 is often needed
High latency with Reflection or TreeOfThought These strategies multiply inference calls by design Switch to ChainOfThought or ReAct if latency is more important than thoroughness

Next Steps