planning_system_prompt = """ % Role: Planning Assistant - Create a sequence of tool operations based on user query. % Tools: - wikipedia: Searches Wikipedia and returns a snippet (needs search query) - calculate: Evaluates a mathematical expression and returns the result (needs operation string) % Instructions: 1. Analyze user query and plan necessary steps with available tools 2. Use EXACTLY ONE tool per step 3. Reference variables from memory when needed 4. Do not execute tasks, only create the plan % Output Format: One step per line, format: [tool_name] [variables if needed] """
replan_system_prompt = """ % Role: Replanning Assistant - Adjust remaining plan based on execution results. % Tools: - wikipedia: Searches Wikipedia and returns a snippet (needs search query) - calculate: Evaluates a mathematical expression and returns the result (needs operation string) % Memory: Original Plan: {original_plan} Executed Tasks: {memory_tasks} Execution Results: {memory_responses} Remaining Tasks: {remaining_tasks} % Instructions: 1. Analyze execution results and determine if plan changes are needed 2. If no changes needed, indicate with "REPLAN: NO" 3. If changes needed, provide updated plan with "REPLAN: YES" 4. Use EXACTLY ONE tool per step in any new plan % Output Format: First line: "REPLAN: YES" or "REPLAN: NO" If replanning, follow with one step per line, format: [tool_name] [variables if needed] """
Planned actions: 1.1. wikipedia "Radius of Earth" 2.2. wikipedia "Radius of Sun" 3.3. calculate "Radius of Sun / Radius of Earth"
Executing task: 1. wikipedia "Radius of Earth" Tool result: Earth radius (denoted as R🜨 or RE) is the distance from the center of Earth to a point on or near its surface. Approximating the figure of Earth by an Earth spheroid (an oblate ellipsoid), the radius ranges from a maximum (equatorial radius, denoted a) of nearly 6,378 km (3,963 mi) to a minimum (polar radius, denoted b) of nearly 6,357 km (3,950 mi). A globally-average value is usually considered to be 6,371 kilometres (3,959 mi) with a 0.3% variability (±10 km) for the following reasons. The I...
No replanning needed. Continuing with original plan.
Executing task: 2. wikipedia "Radius of Sun" Tool result: Solar radius is a unit of distance used to express the size of stars in astronomy relative to the Sun. The solar radius is usually defined as the radius to the layer in the Sun's photosphere where the optical depth equals 2/3: 1 R ⊙ = 6.957 × 10 8 m ... Replanning needed. Updating plan... Updated plans: 1. 1. wikipedia "Radius of Earth" 2. 2. wikipedia "Radius of Sun" 3. calculate "6.957 × 10^8 m / 6,371,000 m" Executing task: calculate "6.957 × 10^8 m / 6,371,000 m" Tool result: 109.1979281117564