All tutorials
Track 8·Observability

Read the generated plan

The Python the model wrote is in result.plan. Print it to see exactly what the model produced before your primitives ran it.

beginner5 min
Video coming soon
Browse this tutorial's folder in tutorials-pygithub.com/OpenSymbolicAI/tutorials-py/tree/main/08-read-the-plan

Before you start

Track 1 printed result.result, showed 53, and stopped there. But 53 is just the last line of the story. run returns an OrchestrationResult, and the most interesting thing on it is result.plan: the actual code the model wrote to answer you.

Same agent as Track 1#

Nothing here changes. It's the same three-primitive Calculator, copied as is.

Ask a handful of different questions. For each one, print the task, the plan the model wrote, and the answer your primitives computed.

python
# main.py
from calculator import Calculator
from opensymbolicai.llm import LLMConfig

QUERIES = [
    "what is 7 times 8 minus 3",
    "subtract 5 from 100",
    "multiply 6 by 4, add 2, then subtract 5",
    "I have 3 boxes of 12 apples and eat 5, how many are left",
]

agent = Calculator(llm=LLMConfig(provider="ollama", model="qwen2.5-coder:7b"))

for query in QUERIES:
    result = agent.run(query)
    print(result.task)    # what you asked
    print(result.plan)    # the code the model wrote
    print(result.result)  # what your primitives computed
bash
uv run main.py

Output:

text
what is 7 times 8 minus 3
step1 = multiply(7, 8)
result = subtract(step1, 3)
53

subtract 5 from 100
result = subtract(100, 5)
95

multiply 6 by 4, add 2, then subtract 5
result = multiply(6, 4)
result = add(result, 2)
result = subtract(result, 5)
21

What you're looking at#

Different queries produce different plans. The same three primitives get arranged into a single call, a chain of calls, or a mix of calls and plain assignments, depending on what was asked. The model chose these intermediate variable names; yours may differ from run to run. The logic does not.

The model wrote the plan once. Your primitives produced the numbers. Neither set of numbers went back to the model.