The execution loop. Why API schemas beat text parsing.
In 2022, if you wanted an LLM to search Wikipedia, you prompted:
"If you need to search, output JSON like {"action": "search", "query": "..."}"
Then you wrote a messy Regex parser to find that JSON in the chaotic output. It failed constantly. The LLM would forget a quote, add a comment, or hallucinate a key.
Modern Models (GPT-4o, Claude 3.5 Sonnet) have been fine-tuned to output actions natively. They don't output "text"; they output a structured "Tool Call Object."
The Workflow:
get_stock tool."tool_call payload: name='get_stock', args={'symbol': 'AAPL'}.get_stock("AAPL"), and gets $200.$200 back to the LLM.from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o")
llm_with_tools = llm.bind_tools([search_google, get_weather])
response = llm_with_tools.invoke("What is the weather in Paris?")
# Content=" " (Empty content!)
# Tool_Calls=[{'name': 'get_weather', 'args': {'city': 'Paris'}}]
It eliminates "Syntax Errors." The model is constrained to generate valid JSON that matches your Pydantic schema. You are no longer parsing natural language; you are handling an event stream.
Function Calling turns the LLM into a Router. It treats your API tools as extensions of its own vocabulary.
Key Intuition: "The model doesn't run the code. It just pushes the button."