10 Agent reasoning and evaluation
This chapter moves from agent memory and retrieval to the capstone capability of planning, which blends reasoning, understanding, evaluation, and feedback. It shows how prompt engineering can extend large language models beyond simple completion into structured thinking and action selection, using practical orchestration with tools like Prompt Flow and Semantic Kernel. The material frames a progression of strategies—ranging from direct prompts to multi-step reasoning and evaluative workflows—aimed at producing more reliable, goal-directed behavior in agents.
The chapter first grounds planning in direct solution prompting styles: question–answer prompts that use provided context and simple similarity-based evaluation; few-shot prompts that imprint patterns and personas to induce behaviors not in pretraining; and zero-shot prompts that leverage generalization for tasks like classification with minimal instruction. It then escalates to reasoning techniques: Chain-of-Thought with worked examples to model stepwise logic; zero-shot CoT triggered by “think step by step” cues; and prompt chaining that decomposes problems, computes intermediate results, and synthesizes final answers. Challenging time-travel scenarios serve as a consistent testbed, illustrating how these formats expose reasoning processes yet may still falter or become verbose without safeguards.
To improve reliability, the chapter introduces evaluation-centric methods. Self-consistency generates multiple solutions at higher diversity, embeds and compares them, and selects the most coherent outcome, simulated via batch runs in a DAG-style workflow. Tree of Thought integrates branching generation with evaluation at each stage, pruning weaker paths and advancing stronger ones in a breadth-first fashion through reusable semantic functions and thresholded scoring—more capable on hard problems but costlier in compute. The overarching lesson is to pair reasoning-oriented prompts with systematic evaluation and adaptive feedback so agents converge on accurate, consistent plans across varied problem classes.
How the two planning prompt engineering strategies align with the various techniques and how we will explore them in this chapter (and later ones)
The flow.dag.yaml, open in the visual editor, and highlighting the various components of the flow
The complexity of the time travel problems we intend to solve using LLMs with reasoning and planning
The flow of the Chain of Thought
The prompt chaining flow
Comparing the various prompt engineering strategies to enable reasoning and planning from LLMs
The self-consistency prompt generation beside the evaluation flow
The step by step process of launching a batch process
The VS Code is open to the batch run output folder. Highlighted are the metrics.json file and the output showing the most similar answer.
Breadth versus depth-first execution on Tree of Thought pattern
Tree-of-Thought pattern expressed and Prompt Flow flow.
Summary
- Direct solution prompting is a foundational method of using prompts to direct LLMs toward solving specific problems or tasks, emphasizing the importance of clear question-and-answer structures.
- Few-shot prompting provides LLMs with a few examples to guide them in handling new or unseen content, highlighting its power in enabling the model to adapt to unfamiliar patterns.
- Zero-shot learning and prompting demonstrate how LLMs can generalize from their training to solve problems without needing explicit examples, showcasing their inherent ability to understand and apply knowledge in new contexts.
- Chain of thought prompting guides the LLMs through a reasoning process step-by-step to solve complex problems, illustrating how to elicit detailed reasoning from the model.
- Prompt chaining breaks down a problem into a series of prompts that build upon each other, showing how to structure complex problem-solving processes into manageable steps for LLMs.
- Self-consistency is a prompt technique that generates multiple solutions to a problem and selects the most consistent answer through evaluation, emphasizing the importance of consistency in achieving reliable outcomes.
- Tree of thought prompting combines self-evaluation and prompt chaining to create a comprehensive strategy for tackling complex problems, allowing for a systematic exploration of multiple solution paths.
- Advanced prompt engineering strategies provide insights into sophisticated techniques like self-consistency with CoT and Tree of Thought, offering methods to increase the accuracy and reliability of LLM-generated solutions.