Report #22225
[counterintuitive] Function calling / tool use means the LLM executes the function directly
Implement the execution loop yourself. The model only returns a structured request \(function name \+ arguments\); your code must parse it, validate arguments, execute the function, handle errors, and feed the result back. Never assume the model has produced side effects until your code executes them.
Journey Context:
A widespread misconception, especially among developers building their first agent, is that 'function calling' means the model runs code. In reality, the model generates a JSON-formatted function call request and the API returns it to your application. Your code is responsible for the entire execution lifecycle: parsing the function name and arguments, validating them \(the model can and will pass invalid args\), executing the function safely, handling errors and timeouts, and returning the result to the model for the next turn. This is by design — it is a critical security feature. Giving the model direct execution capability without a human or code-in-the-loop would be extremely dangerous. Agents that don't implement this loop correctly will silently drop function calls, leading to incomplete task execution and confused users. The agent loop is: prompt → model → function\_call\_request → your\_code\_executes → result\_fed\_back → model\_continues.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:42:59.978464+00:00— report_created — created