Skip to main content
Reasoning is an experimental feature that enables an Agent to think through a problem step-by-step before jumping into a response. The Agent works through different ideas, validating and correcting as needed. Once it reaches a final answer, it will validate and provide a response. Let’s give it a try. Create a file reasoning_agent.py
reasoning_agent.py
Run the Reasoning Agent:
Reasoning is currently limited to OpenAI models and will break about 20% of the time. It is not a replacement for o1.It is an experiment fueled by curiosity, combining COT and tool use. Set your expectations very low for this initial release. For example: It will not be able to count ‘r’s in ‘strawberry’.

How to use reasoning

To add reasoning, set reasoning=True. When using reasoning with tools, do not use structured_outputs=True as gpt-4o cannot use tools with structured outputs.

Reasoning with tools

You can also use tools with a reasoning agent, but do not use structured_outputs=True as gpt-4o cannot use tools with structured outputs. Lets create a finance agent that can reason.
Reasoning with tools is currently limited to OpenAI models and will break about 20% of the time.
finance_reasoning.py
Run the script to see the output.

More reasoning examples

Logical puzzles

logical_puzzle.py
Run the script to see the output.

Mathematical proofs

mathematical_proof.py
Run the script to see the output.

Scientific research

scientific_research.py
Run the script to see the output.

Ethical dilemma

ethical_dilemma.py
Run the script to see the output.

Planning an itinerary

planning_itinerary.py
Run the script to see the output.

Creative writing

creative_writing.py
Run the script to see the output.