{"slug": "ai-agents-tool-calling", "title": "AI Agents - Tool Calling", "summary": "A developer explains how AI agents use tool calling to let large language models access external functions, such as fetching weather or stock data, by analyzing queries and suggesting appropriate tools with parameters. The post emphasizes the importance of clear tool descriptions for accurate semantic matching and provides an example docstring for an addition function.", "body_md": "When a user asks the LLM to perform an action, e.g., get the current weather or current stock market details, the LLM cannot get this information on its own. It needs some functionality or tools along with a description of when to call these tools/functionality.\n\nThe LLM analyzes the query to find out whether it is related to any of the tools and their descriptions.\n\nIf so, the LLM will suggest the tool along with the parameters to the agent/external logic. The external logic will perform the action and send the result back to the LLM.\n\nThe LLM reads the result and generates the structured output.\n\nSuppose the tool call is not matched; the LLM will derive the answer from its own knowledge. If we give an ambiguous description, the LLM may not generate the output properly.\n\nThe description for the tool calls must be proper so that the LLM can semantically identify the tool and match the arguments.\n\nexample description\n\n```\n\"\"\"\nAdd up two integer numbers.\n\nThis function simply wraps the `+` operator, and does not\ndo anything interesting, except for illustrating what is\nthe docstring of a very simple function.\n\nParameters\n----------\nnum1 : int\n    First number to add\nnum2 : int\n    Second number to add\n\nReturns\n-------\nint\n    The sum of `num1` and `num2`\n\nSee Also\n--------\nsubtract : Subtract one integer from another\n\nExamples\n--------\n>>> add(2, 2)\n4\n>>> add(25, 0)\n25\n>>> add(10, -10)\n0\n\"\"\"\n```\n\n", "url": "https://wpnews.pro/news/ai-agents-tool-calling", "canonical_source": "https://dev.to/ramya_perumal/ai-agents-tool-calling-cie", "published_at": "2026-09-09 00:13:59+00:00", "updated_at": "2026-09-09 00:45:24.378980+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "ai-agents", "developer-tools"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/ai-agents-tool-calling", "markdown": "https://wpnews.pro/news/ai-agents-tool-calling.md", "text": "https://wpnews.pro/news/ai-agents-tool-calling.txt", "jsonld": "https://wpnews.pro/news/ai-agents-tool-calling.jsonld"}}