Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstalliTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To give one PHP agent several tools, define each capability as a small, clearly described operation, expose only the set the current agent and user need, and run a bounded loop. The model requests a tool call, your PHP code validates and executes it, the result goes back to the model, and the cycle repeats until the model produces a final answer or a limit stops the run.
PHP is the host in this model. Your application owns and executes the tools it implements. Some tools may run elsewhere: provider-hosted capabilities execute on the provider’s side, and tools served by a remote MCP server execute on that server. The examples below use Laravel AI SDK and Laravel MCP as documented in the Laravel 13.x pages, and OpenAI’s tool guides, as checked in early October 2026. Package versions, PHP and Laravel requirements, and provider support change, so confirm them against the current documentation before you build.
What one orchestrated answer requires
A single user request can need several tool calls, and the model may need to read one result before it can ask for the next. Each turn follows the same cycle:
- Send the user request, the agent’s instructions, and the tool definitions the agent is allowed to use.
- Receive either a final response or one or more requested tool calls.
- Validate each call’s arguments and check permissions in PHP before anything runs.
- Execute the call or calls, and attach each result or error to the call that produced it.
- Send those results back so the model can request another tool or answer.
- Stop on a final answer, a refusal or error path, an approval pause, or a configured step limit.
One turn can span several provider requests. Laravel AI SDK stores the turn as ordered steps and links each result to its originating call, which is what makes the run inspectable later.
#1 Best Overall
How do I give one AI agent multiple tools in PHP?
In Laravel AI SDK, an agent is a dedicated PHP class that holds its instructions, context, tools, and an optional structured output schema. The tools it can use are returned from the agent’s tools() method. Each tool has a handle method that the agent invokes when the model requests that capability. The Laravel AI SDK documentation also describes provider-native tools, such as web search, which the provider supplies rather than your PHP code.
Make each tool one operation
Treat every tool as an interface contract. The model chooses among the capabilities you describe, so the name, description, and input schema are what it works from. Keep each tool to one operation, give it a precise input schema, and have it return a concise structured result.
OpenAI’s general guide to building agents, an older document that is not PHP-specific, sorts common tools into data retrieval, actions, and orchestration, and recommends standardized, reusable definitions. Well-documented tools are easier to discover and to version, and the same design logic applies in PHP.
Free tools Windows power users keep installed
One-click scans. No signup required.
Avoid a mega-tool whose description covers many unrelated actions. The model cannot choose reliably among them, and permissions cannot be scoped per action. Split read operations from writes when their permissions differ. Return the fields the next step needs rather than the whole record or document. For example, a support agent might have a read-only find_order tool that returns status, items, and ship date, a read-only refund-history tool, and a separate issue_refund write tool that is gated by approval, as shown later in this article.
Rank #2
Expose only what this agent needs
Apply least privilege to the tool list. Give each agent and each conversation only the functions the current task requires. The Laravel AI SDK documentation shows a filesystem tool collection being filtered to remove a delete operation; the same approach works for any sensitive operation you do not want an agent to reach.
How can a PHP agent use MCP tools?
The Model Context Protocol (MCP) lets tools come from a separate server. The Laravel MCP documentation shows an agent combining its local tools with tools loaded from local or remote MCP clients, and MCP tools are wrapped so the agent can call them like its own. Where an MCP tool runs depends on where its server runs. A server inside your Laravel application executes in PHP; a remote server executes wherever it is hosted, and your application receives only its results.
When the catalog grows, avoid advertising every definition on every turn. Sending many tool definitions consumes tokens and can reduce selection accuracy. The Laravel AI SDK documentation describes deferred ToolSearch for supported providers, and Laravel MCP offers searchable catalogs with search and execute operations, so the model can look up a tool and run it without every definition being advertised at once. The sources do not give a tool-count threshold at which this becomes necessary; decide from your own tool list size and from observed wrong-tool selections.
How do I chain tool calls in a Laravel AI agent?
The loop chains calls naturally. The model reads each result before it requests the next call, so an adaptive task does not need a hand-written sequence. When you already know the order, you can make that order explicit in code instead.
Dependent calls wait for their inputs
If call B needs an identifier returned by call A, B must wait. The loop enforces this because the model sees A’s result only after A has executed. In the support example, find_order returns an order identifier, and only then does the agent call the refund-history tool with that identifier.
Independent calls can run together, with conditions
When one model response requests several calls that do not depend on each other, your runtime may execute them concurrently, provided the provider and your application permit it. Parallel execution is not automatically faster or safe. Rate limits, shared state, write conflicts, ordering requirements, and provider support decide whether it is appropriate. Read-only tools with no shared state are the usual candidates; keep writes sequential unless you have verified that they are independent.
OpenAI’s Programmatic Tool Calling documentation describes a hosted capability in which the model writes and runs code that coordinates its tools. In its words: “Programmatic Tool Calling lets a model write and run JavaScript that coordinates its tools.” That is an OpenAI-hosted feature, not a PHP feature. In a PHP application, the equivalent is ordinary code you write and control. The same guidance favors programmatic coordination when the flow is predictable and code can filter, join, rank, deduplicate, aggregate, or validate several results into a smaller structured output. It favors direct calling for a single lookup or for an adaptive decision that needs fresh model judgment.
How do I stop an AI agent from calling tools forever?
An agent loop has no natural end if the model keeps requesting tools. Three controls keep it bounded: a step ceiling, timeouts, and output caps.
Rank #4
Cap the number of steps
Laravel AI SDK provides a MaxSteps attribute that sets how many steps an agent may take while using tools. The documentation does not give a universal number. Choose a value from the longest legitimate chain your workflow needs, add a margin, and test what happens when the ceiling is reached. Decide in advance how your application reports a run that hits the limit, and log it as a distinct outcome rather than as a generic error.
Add timeouts at two levels: one for each tool execution and one for each provider request. These are standard application controls; set the values from the latency your tools actually have.
Cap what goes back into context
Large results push out useful context and make later decisions worse. Summarize or filter results in deterministic PHP before returning them to the model. For example, return the five matching orders with their status fields rather than the full order history. Laravel MCP exposes a maximum number of tools that can run in one execute_tools call and a maximum response size. The MCP documentation does not recommend a universal value for either, so set them from the size of the payloads your tools produce.
Gate consequential actions behind approval
A write that issues a refund, sends an email to a customer, or deletes a record should not run the moment the model requests it. Laravel AI SDK’s approval flow pauses a turn before a tool executes and exposes the tool’s name, its arguments, and a reason. After a decision, the run resumes with the call approved, rejected, or edited.
- Authorize before resuming. A paused turn is matched to its conversation and its pending calls. Confirm that the current user owns that conversation before you resume it.
- Re-check an edited call. If a reviewer changes the arguments, treat the result as a new request and validate permissions again. This is an engineering recommendation, not a documented framework rule.
- Keep the gate on the write, not the whole agent. Reads such as
find_orderrarely need a pause; the refund write usually does.
Record the trace and recover from partial failure
What to record for each call
Persist the request and turn identifiers, step order, tool name, validated arguments with sensitive fields removed according to your privacy policy, outcome, duration, and error category. Laravel AI SDK’s conversation records expose steps, tool calls, provider calls, results, pending approvals, and a failed status, which gives you a base to build on.
How a partial failure behaves
A turn that fails partway through keeps the steps it completed. A call with no recorded result is treated as interrupted when the conversation continues. The framework cannot tell whether an external action happened before the failure, so an unresolved write is ambiguous: the refund may have been issued before the error was raised.
Recovery steps
- Inspect the trace for the turn and list the calls that have no recorded result.
- For read-only tools, retry with the same arguments if the failure was a timeout or other transient error.
- For writes, check the downstream system for the action before doing anything else.
- If you retry a write, do it only with an idempotency key or application-level deduplication, so a repeated request cannot repeat the action. This recommendation follows from the ambiguity above; the framework does not provide it automatically.
- Tell the user which actions succeeded and which did not, instead of silently starting the whole task again.
Choosing an orchestration model
Three approaches cover most PHP cases. The table compares them on the points that matter in production. Where the sources do not establish a behavior, the cell says so.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
| Approach | Who runs the loop | Sequencing | How tools are selected | Where tools execute | Approval and recovery |
|---|---|---|---|---|---|
| Direct model orchestration (Laravel AI SDK agent, or a direct OpenAI Responses API integration) | The framework in Laravel AI SDK; your integration in a direct API build | The model chooses each next call from the latest result | Configured definitions, or deferred ToolSearch where the provider supports it | PHP for your tools; the provider for provider-native tools | Laravel AI SDK documents an approval pause and conversation trace; for a hand-built direct integration, the sources do not state these features, so you build them |
| Predictable application-side coordination | Your PHP code | Fixed by code, with conditions, loops, and concurrency only where safe | Your code selects each call; no per-step model judgment | PHP application | Fully implemented by your code, which can check each result before the next step and log each call |
| MCP tool catalog | Laravel AI SDK loads MCP tools into the agent; the MCP server supplies them | Model-driven, as in direct orchestration | Searchable catalog with search and execute operations, so tools need not all be advertised | PHP for a local MCP server; the remote server’s host for a remote one | Output size and per-call tool count are configurable in Laravel MCP; the sources do not state whether the approval pause applies to MCP-wrapped tools, so confirm that in your version |
Decision guide
- Choose direct orchestration when each step needs fresh judgment and the tool set is modest.
- Choose application-side coordination when the sequence is known and you need to filter, join, rank, or validate results before the model sees them.
- Choose an MCP catalog when tools live in separate services, or when the catalog is large enough that advertising every definition costs tokens or accuracy.
Runtime choice changes the control boundary
OpenAI’s agents documentation distinguishes three options. The managed Agents API lets the provider run more of the harness. The Agents SDK runs in your application, so you control deployment, storage, approvals, and the runtime. A direct Responses API integration leaves more of the wiring to your application. These are architectural trade-offs, not a recommendation of any particular library. For PHP, Laravel AI SDK is the framework-specific option covered in this article, and its version, requirements, and provider support should be checked at implementation time.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

