Mirascope Frog Logo
Mirascope
DocsBlogPricingCloud
⌘K
Type to search
⌘Kto search
Escto close
mirascope
v1.25.7
1.3k
Join our
Docs v1 (legacy)API ReferenceGuidesDocs
Overview
Getting Started
QuickstartStructured OutputsDynamic Configuration & ChainingTools & Agents
Agents
Web Search AgentAgent Executor: Blog WritingDocumentation AgentLocal Chat with CodebaseLocalized AgentQwant Search Agent with SourcesGenerate SQL with LLM
More Advanced
Code Generation and ExecutionDocument SegmentationExtracting from PDFExtraction using VisionGenerate Captions for an ImageGenerate Synthetic DataLLM Validation With RetriesNamed Entity Recognitiono1 Style ThinkingPII ScrubbingQuery PlanRemoving Semantic DuplicatesSearch with SourcesTranscribing SpeechSupport Ticket RoutingText ClassificationText SummarizationText TranslationKnowledge Graph
Prompt Engineering
Self-AskPlan and SolveContrastive Chain of ThoughtTabular Chain of ThoughtChain of ThoughtThread of ThoughtRereadingEmotion PromptingRephrase and RespondCommon Phrases (Prompt Mining)Role Prompting
Evaluations
Evaluating Documentation AgentEvaluating Web Search Agent with LLMEvaluating Generating SQL with LLM
Langgraph Vs Mirascope
LangGraph Quickstart using Mirascope
# Plan and Solve [Plan and Solve](https://arxiv.org/pdf/2305.04091) is another variation of zero-shot [Chain of Thought](https://arxiv.org/abs/2201.11903) whereby the LLM is asked to reason with the improved prompt `"Q: {prompt} A: Let's first understand the problem and devise a plan to solve it. Then, let's carry out the plan and solve the problem step by step"`. Plan-and-solve has shown improvements compared to standard CoT in reasoning and mathematical tasks. <Info title="Mirascope Concepts Used" collapsible={true} defaultOpen={false}> <ul> <li><a href="/docs/v1/learn/prompts/">Prompts</a></li> <li><a href="/docs/v1/learn/calls/">Calls</a></li> </ul> </Info> ```python from mirascope.core import openai, prompt_template pas_augment = """Let's first understand the problem and devise a plan to solve it. Then, let's carry out the plan and solve the problem step by step.""" @openai.call(model="gpt-4o-mini") @prompt_template("{modifiable_query}") def call(query: str, pas_prompt: bool = False) -> openai.OpenAIDynamicConfig: if pas_prompt: modifiable_query = f"Q: {query}\nA: {pas_augment}" else: modifiable_query = query return {"computed_fields": {"modifiable_query": modifiable_query}} prompt = """The school cafeteria ordered 42 red apples and 7 green apples for students lunches. But, if only 9 students wanted fruit, how many extra did the cafeteria end up with?""" print(call(query=prompt, pas_prompt=True)) ``` ``` To find out how many extra apples the cafeteria ended up with, we can follow these steps: 1. **Calculate the total number of apples ordered:** - Red apples: 42 - Green apples: 7 - Total apples = Red apples + Green apples = 42 + 7 = 49 apples 2. **Identify how many apples were taken by the students:** - Number of students who wanted fruit = 9 apples (since each student is presumably taking one apple) 3. **Calculate the number of extra apples:** - Extra apples = Total apples - Apples taken by students - Extra apples = 49 - 9 = 40 Therefore, the cafeteria ended up with **40 extra apples** after the students took their fruit. ``` <Info title="Effective Plan and Solve Usage"> <ul> <li><strong>Encourage Structured Thinking</strong>: The Plan and Solve approach promotes a more organized problem-solving process, starting with understanding and planning before execution.</li> <li><strong>Break Down Complex Problems</strong>: Use this technique for problems that benefit from being broken down into smaller, manageable steps.</li> <li><strong>Improve Problem Comprehension</strong>: By asking the LLM to first understand the problem, it can lead to better overall comprehension and more accurate solutions.</li> <li><strong>Enhance Step-by-Step Reasoning</strong>: The explicit instruction to solve the problem step by step can result in clearer, more detailed explanations.</li> <li><strong>Apply to Various Domains</strong>: While particularly effective for mathematical and reasoning tasks, Plan and Solve can be adapted for a wide range of problem types.</li> </ul> </Info> Plan and Solve enhances the standard Chain of Thought approach by explicitly structuring the problem-solving process into distinct phases: understanding, planning, and execution. This structured approach can lead to more comprehensive and accurate solutions, especially for complex problems that benefit from careful planning before execution. By encouraging the LLM to first grasp the problem and outline a strategy, Plan and Solve can result in more thoughtful and well-organized responses across various types of reasoning and mathematical tasks.

Provider

On this page

Provider

On this page

© 2026 Mirascope. All rights reserved.

Mirascope® is a registered trademark of Mirascope, Inc. in the U.S.

Privacy PolicyTerms of Use