Reasoning, Code Execution, and Web Search: Automated Workflows
On this page
When Reasoning Meets Tools
Combining high-level reasoning with code execution and web search transforms a language model into an agent capable of calculating, searching, and synthesizing results into a single conclusion. This lesson shows you how to leverage that synergy. First, a note on terminology: in ChatGPT, code execution is called Data Analysis and search is called Search; in the API, these are the Code Interpreter and Web Search tools. Previous generations reserved this role for dedicated reasoning models like o3; today, it’s a setting available for every model.
Three Complementary Roles
The first pillar is the model itself. At a high reasoning level, it acts as the brain: it reasons, plans, decides which actions to take, and orchestrates the entire process.
Code execution serves as the hands. It runs Python in an isolated environment, allowing it to manipulate your Excel, CSV, or JSON files, perform complex calculations, create charts and visualizations, and clean or transform data before analysis. Web search acts as the eyes: it provides access to real-time information, whether you need up-to-date data, fact-checking, information gathered from multiple sources, or access to public websites and databases.
How the Model Decides to Use a Tool
You generally don’t need to name the tool: the model detects when a calculation or recent information is needed and calls the tool at the right moment. If you prefer a specific tool, say so: “do the calculation in Python,” “search the web.” On the API side, the Responses API goes further with Programmatic Tool Calling: the model writes a JavaScript program, executed in an isolated environment, that calls the tools—potentially in parallel—and filters intermediate results, rather than calling them one by one.
A request for a comprehensive financial analysis illustrates this sequence well.
“Here is my sales data for the last 12 months (Excel). Analyze the trends, calculate the average monthly growth rate, forecast sales for the next 3 months, and search the web for industry forecasts to compare. Produce a report with charts.”
The model can then execute a sequence like this without you needing to break it down; the exact order varies from one request to another.
- Reason: Understand the problem structure
- Execute code: Load the Excel file, calculate trends, make projections
- Search the web: Find industry forecasts
- Reason: Compare results and draw conclusions
- Execute code: Generate charts
- Reason: Write the final report
Notice the alternation: reasoning doesn’t just happen at the start; it returns between each tool call to decide the next step. This rhythm is what distinguishes an agent from a simple executor.
What the Combination Enables
Automated benchmarking is the most immediate use case, since it requires comparing your figures against external data.
“Here are my company’s financial performance metrics (Excel file). Search the web for average financial ratios in our sector (B2B SaaS in Europe) and compare them to ours. Produce a benchmarking table with color coding: green if we’re above average, red if below.”
Competitive intelligence takes on a new dimension when backed by your own data: instead of just collecting announcements, you measure their impact.
“Search for the latest announcements from our 3 competitors (Competitor A, Competitor B, Competitor C) over the last 30 days. Cross-reference this with our web traffic data (attached CSV file) to identify whether their announcements impacted our traffic.”
The third typical use case is a data-driven report with visualizations, where code execution does the heavy lifting on your internal data.
“Here is our HR data (Excel file). Calculate the turnover rate by department, the average cost of a replacement (assumption: 6 months of salary), and project the budget impact. Generate a chart per department and a summary table.”
Enabling and Controlling the Tools
In ChatGPT, Data Analysis kicks in whenever a file or calculation requires it; in an enterprise workspace, verify that an administrator hasn’t disabled it. Web search triggers when the model detects a need for recent information, and you can force it with the + button, then Search. On the API side, both tools are declared in the request. For reasoning level, OpenAI categorizes tool usage and search as low when speed is paramount, and recommends medium whenever planning and judgment matter—which is the case for multi-tool workflows.
These tools have clear boundaries you need to know. The Python environment for Data Analysis does not access the internet: it works only on the files you provide, and external data must come through search or your own imports. Response times increase significantly when all three are combined, and quotas are consumed faster, especially at higher reasoning levels.
Your Turn
All three building blocks together. Test the full combination on a case where reasoning, code, and search are all essential.
“Here is a CSV file of my monthly expenses over 12 months. (1) Analyze trends in Python and generate a chart. (2) Search the web for the inflation rate in France for each corresponding month. (3) Calculate my inflation-adjusted expenses. (4) Produce a report comparing nominal and real expenses.”
If you don’t have a CSV file handy, ask the model to generate a realistic one first. Keep three reflexes in mind during the exercise. Verify calculations: a wrong formula executed cleanly is still a wrong formula. Cross-check search sources, as results can be outdated or inaccurate. And retrieve generated files—charts, tables—before closing the conversation. One final piece of advice applies to everything: even when the model manages its own tools, complex workflows yield better results when broken into steps rather than crushed into a single giant prompt.
Official sources: Data analysis with ChatGPT (OpenAI Help Center: isolated Python, no web access) · Searching the web with ChatGPT · Code Interpreter and Web search (API tools) · Programmatic Tool Calling · Reasoning models (effort levels and tools)
Key Takeaways
- A high reasoning level combines thinking, code execution, and web search autonomously
- The model automatically decides when to use each tool; on the API side, Programmatic Tool Calling lets it orchestrate tools via code
- Code execution (Data Analysis, Code Interpreter) manipulates files and creates charts without web access; search brings in recent information
- For multi-tool workflows, start with
medium, the level OpenAI recommends when planning matters - Always verify results—tools amplify both power and the risk of error