Skip to main content
Lesson 10 of 12 · OpenAI Reasoning: Reflection and Effort Levels, from ChatGPT to API

Combine Reasoning and Tools

Lesson 10 of 12 Updated November 5, 2026 Intermediate
On this page
  1. Go Further with Advanced Tools
  2. Reasoning as the Tool Driver
  3. Three Combination Patterns
  4. Regaining Control of Tools
  5. Visualizations That Require Judgment
  6. Your Turn
  7. Key Takeaways

Go Further with Advanced Tools

You now know how to combine reasoning with code execution and web search. This lesson explores advanced combinations: chaining tools strategically, using reasoning to drive them, and building truly autonomous workflows.

Reasoning as the Tool Driver

The difference between a model that answers without thinking and a reasoning model that uses tools is fundamental. Starting at a medium effort level—which OpenAI recommends whenever planning matters—the model can plan which tools to use and in what order, evaluate the results of each tool before proceeding, adapt its strategy when a tool doesn’t return what it expected, and combine outputs into a coherent conclusion. Concretely, it doesn’t just execute code when you ask it to: it thinks through the problem, decides that code is the best way to solve it, writes the appropriate code, analyzes the result, and then decides whether to go further. The nuance may seem subtle; it changes everything in a four-tool workflow, where a bad initial decision propagates all the way to the end.

On the API side, two mechanisms push this logic forward. With function calling, OpenAI recommends returning the reasoning items produced with the last call to the model, in addition to the function result: this keeps the model on track with what it had planned. With Programmatic Tool Calling, the model writes a JavaScript program, executed in an isolated environment, that orchestrates tool calls and filters intermediate results. Finally, in ChatGPT Work and Codex, Ultra distributes the heaviest tasks among sub-agents, at the cost of significantly higher consumption.

Three ways to chain tools Three columns. Search first: start from the web, judge sources, then calculate and plot. Your data first: start from your file, calculate in Python, then compare to the web. Iterative code: try a method, evaluate the result, switch to the fallback method. COMBINATION PATTERNS Three ways to chain tools Search first Start The web Next Judge sources End Calculate and chart Your data first Start Your file Next Python calculations End Compare to the web Iterative code Start A first method Next Evaluated result End Fallback method In the API, return reasoning items with the result of each function.
Based on the OpenAI API Reasoning models guide and the OpenAI Help Center (November 2026).

Three Combination Patterns

The first pattern—Search, then Analyze, then Code—fits market analyses and benchmarks, meaning situations where the data doesn’t exist in your possession yet.

“Search for the market shares of the top 5 cloud providers in Europe in 2025. Then, based on this data, create a bar chart and calculate the market concentration rate (HHI index). Interpret the result.”

The model then chains four distinct phases.

  1. Search the web to collect data
  2. Reason about source reliability
  3. Execute code for the chart and calculation
  4. Reason about the economic interpretation

The second phase is the one people forget when writing the prompt, yet it’s the one that prevents you from building an HHI index on approximate figures.

The second pattern reverses the starting point: it begins with your data to enrich it from the outside—Data, Code, Search, Synthesis.

“Here is my sales file by country (CSV). Calculate the growth rate by country, then search for the GDP growth rate of each country over the same period. Identify countries where our growth exceeds GDP growth (outperformance) and those where the opposite is true.”

The third pattern, iterative code with reasoning, leverages the model’s ability to write code, analyze the result, spot a problem, and rewrite—all automatically. You can even specify the fallback method.

“Here is a transaction dataset (CSV). Detect statistical anomalies. If the first method (z-score) doesn’t yield clear results, try the interquartile range method. Choose the most relevant method and explain why.”

Regaining Control of Tools

Letting the model decide is convenient, but sometimes you already know which tool fits—and telling it is more efficient than letting it explore. You can therefore restrict it: “Without searching the web, analyze only the data in the attached file and give me your conclusions based exclusively on this data,” or “Do not execute code for this question. Reason only based on the information I provide.”

For long workflows, insert checkpoints rather than launching everything in one block: “Step 1: calculate basic metrics and show me the results before continuing. Step 2 (after my validation): enrich with web data. Step 3: produce the final report.” This keeps you able to stop the process before an error propagates to costly steps.

Visualizations That Require Judgment

The combination of reasoning plus code execution shines particularly when the visualization itself implies decisions: what type of chart, what thresholds, what highlighting.

“Here is my performance data (Excel). Create a one-page dashboard with: (1) the most relevant chart for each metric—choose the chart type yourself based on the nature of the data, (2) automatic highlighting of anomalies, (3) a green/yellow/red color code based on thresholds you will determine based on the data distribution.”

The model reasons about the optimal chart type metric by metric, calculates statistically relevant thresholds instead of inventing them, and produces the corresponding code. This is exactly the work an analyst would do before opening their editor.

Your Turn

A complete workflow. Test this workflow at a high reasoning level (High in Chat, high in the API).

“I’m going to give you a CSV file of monthly expenses by category over 24 months. I want:

  1. Identify the 3 categories with the highest increase (calculation in Python)
  2. For each, search whether this is a national trend or specific to my case (web search)
  3. Produce a comparative chart: my expenses vs. the national trend (Python)
  4. Write a summary with recommendations (pure reasoning) Present the result of each step.”

During the exercise, watch what happens when code execution fails. The model can retry on its own, which is a good thing; but if the problem lies in your data, no rewrite will fix it: check the file instead of restarting. And if the request becomes too heavy, break it down into steps validated one by one.

Official sources: Reasoning models (OpenAI API: effort levels, returning reasoning items with function calls) · Programmatic Tool Calling · Data analysis with ChatGPT (code execution in ChatGPT) · Models (Ultra)

Key Takeaways

  • At a sufficient effort level, reasoning drives tools strategically, not mechanically
  • Three key patterns: search, analyze then code; data, code then search; iterative code
  • On the API side, return reasoning items with function results, and consider Programmatic Tool Calling
  • You can force or restrict tool usage based on your needs
  • Insert checkpoints in long workflows to maintain control