Type: url
Original: https://martinfowler.com/articles/function-call-LLM.html
Status: generated
Summary
In this May 2025 article, Kiran Prakash explains function calling — an LLM analysing a natural-language request and returning a structured description of a function call, with its arguments, for a separate program to execute — by building a Python shopping agent on OpenAI’s Chat Completions API. The walkthrough covers unit tests, the system prompt and function schemas, restricting the agent’s action space with explicit conditional logic, denylist- and LLM-based guardrails against prompt injection, action classes that translate the LLM’s decision into API calls, and using the instructor library with Pydantic to reduce boilerplate. It also discusses whether the pattern could replace rules engines, distinguishes function calling from the broader term tool calling, relates it to the Model Context Protocol’s dynamic tool discovery, and recommends starting with low-risk operations.