Agents and tools Ai Questions
Master agents and tools ai interviews with our comprehensive collection of 5 questions and challenges.
Tool calling lets a model ask your app to run a function: you describe each tool with a name, a description and an input schema, and the model replies with a structured request (tool name plus JSON arguments) instead of plain text. The model never runs anything itself. Your code validates the arguments, runs the function, sends the result back, and the model uses it to continue; the exception is provider-executed tools like hosted web search, which run on the provider side.
An agent loop keeps calling the model, running the tools it asks for and feeding results back. It stops naturally when the model finishes without requesting a tool, when it calls a tool that has no server-side execute (so the client or a human must act), or when a call needs approval. On top of that you add hard limits: a maximum step count, a stop-on-specific-tool rule, and custom conditions such as a token budget, because the model deciding to stop is not a guarantee.
Render the assistant message as a list of parts, and give each tool part its own small component that switches on its state: input-streaming, input-available, approval-requested, output-available, output-error or output-denied. Show a short human label while the tool runs, the result in a compact card when it finishes, and a clear error or denial message when it fails. Announce changes politely to screen readers and keep raw JSON out of the main view.
Classify each tool by risk on the server, run safe reads automatically, and mark risky calls as needing user approval so the loop pauses and returns an approval request instead of running the tool. The UI shows exactly what will happen (amount, order, reason) with Approve and Deny buttons, sends the decision back, and the server only executes after an approved response, still re-checking permissions inside execute. Decide approval rules in server code from the tool input, never from the model or the browser alone.
Once a model can call tools, anything that can influence its input (a user message, a web page, an email, a document) can try to steer it into calling tools you did not intend, which is prompt injection turned into real actions. The main risks are excessive agency (too many tools, too much permission, too little oversight), data exfiltration through tool arguments, unvalidated input and output, and runaway cost. Reduce them with narrow tools, least-privilege credentials scoped to the current user, server-side authorisation in every tool, approval for high-impact actions, and limits and logs on every loop.