DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk9 min

Multi-Tool Orchestration in PHP: One Agent, Many Tools, One Answer

A practical guide to letting one PHP or Laravel agent call several tools: the orchestration loop, dependent and independent calls, step limits, approvals, traces, and MCP catalogs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

One PHP agent can answer a question using several tools by letting the model request calls, having your application execute each one, returning the results, and repeating until the model writes a final answer or a stop condition fires. In this design PHP is the host runtime: your code validates each request, runs the functions, and decides what the model sees. Some capabilities run outside your process. Provider-hosted tools execute on the provider’s side, and MCP servers may run elsewhere.

How do I give one AI agent multiple tools in PHP?

In the Laravel AI SDK, an agent is a dedicated PHP class that holds its instructions, context, tools, and an optional structured output schema, as described in the Laravel AI SDK documentation (13.x). Each tool provides a handle method that the agent invokes when it is needed. Treat the tool set as an interface contract: the model chooses among the capabilities you configure, and your PHP code implements them.

As an Amazon Associate I earn from qualifying purchases.

The loop, step by step

  1. Send the user request, the instructions, and the tool definitions this agent is allowed to use.
  2. Receive either a final answer or one or more requested tool calls. A single user turn can span several provider requests.
  3. Validate each call’s arguments and permissions in PHP before anything executes.
  4. Execute the call or calls, collect each result or error, and attach it to the call that produced it.
  5. Send the results back so the model can request another call or answer.
  6. Stop on a final answer, a refused or failed call handled by your error path, an approval pause, or the configured step limit.

OpenAI’s tools guide describes the same request, execute, continue shape in its Agents API loop.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Define each tool as one small capability

Start with a narrow set of tools. Each one should perform a single operation, accept a precise input schema, and return a concise structured result. An older OpenAI general guide, A practical guide to building agents, sorts tools into data retrieval, actions, and orchestration, and recommends standardized, reusable definitions because well-documented tools are easier to discover and to version. It is not PHP-specific, so use it for design principles rather than API details.

  • One operation per tool. Avoid a single tool whose description covers many unrelated actions, because the model cannot select it reliably and you cannot authorize it precisely.
  • Separate reads from writes when their permissions differ. A read tool can usually be exposed more widely than a write tool.
  • Return what the next step needs. Return the identifier the next tool will require, not a whole record, document, or table, which wastes context.
  • Make failures distinguishable. “Not found,” “permission denied,” and “temporarily unavailable” call for different next steps, so return them as distinct error values.

Which tools should an agent see on each turn?

Expose only the functions the current agent needs for the current user. The Laravel AI SDK documentation shows a filtering example in which a delete operation is removed from a broader filesystem tool collection (Laravel AI SDK documentation). Filter the list per agent and per user before the request is sent, and treat the model’s choice as a suggestion that PHP checks again at execution time.

Small catalogs: a fixed tools() list

For a handful of tools, the agent’s tools() method returns the application tools available on every turn. If the application also uses Laravel MCP, combining those tools with MCP-hosted ones is covered in the MCP section below.

Large catalogs: deferred search

The Laravel AI SDK documentation warns that sending many tool definitions costs tokens and may reduce selection accuracy. For supported providers, it documents deferred ToolSearch as an alternative to sending everything at once. Confirm that your provider and model support it before you design around it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I chain tool calls in a Laravel AI agent?

You do not write the chain as a fixed sequence of calls. The loop produces it: the model sees the result of one call before it chooses the next, so a dependent call is only requested once its input exists. Your job is to make each tool’s output usable as the next tool’s input, and to keep the loop bounded.

Dependent calls wait for their inputs

When call B needs a value returned by call A, B must wait. For example, an agent answering “When is the next delivery for my latest order?” might first call a tool that returns the latest order identifier, then call a tool that returns the delivery schedule for that identifier. Design the first tool’s result so it includes the identifier, not only a status message.

Independent calls may run concurrently

When the model requests calls that do not depend on each other, the runtime can execute them concurrently, provided the provider and your application allow it. Do not assume concurrency is automatically faster or safer. Rate limits, shared state, write conflicts, provider support, and ordering requirements decide whether calls can overlap, and those depend on your actual tool implementations. Keep writes that touch the same record sequential unless you have verified they cannot conflict.

How do I stop an AI agent from calling tools forever?

A loop has no natural end if the model keeps requesting work. Put three ceilings in place, for steps, time, and output size, and decide in advance what the user sees when each one is reached.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cap the number of steps

Laravel exposes a MaxSteps attribute that sets how many steps an agent may take while using tools (Laravel AI SDK documentation). No universal number is established. Base the ceiling on the longest legitimate workflow you have tested, and keep it low enough that a looping model cannot run up cost or hold a request open.

Set time limits

  • Per-tool execution timeout, so one slow external API cannot hold the whole turn.
  • Provider request timeout, so a stalled model call does not block the loop indefinitely.

Limit what goes back to the model

Filter, rank, or aggregate large results in deterministic PHP before anything is returned. For example, a search tool can return the top ten matching rows with a total count and a truncation flag, rather than the full result set. Whether to do this in application code or let the model work through raw results is an orchestration choice, covered in the final section.

Pausing for approval before sensitive actions

Make approval an explicit state rather than an assumption. Laravel’s approval flow can pause a turn before a tool executes, expose the tool’s name, arguments, and reason, and resume after a decision to approve, reject, or edit the arguments (Laravel AI SDK documentation). Paused turns are matched to a conversation and its pending calls, so authorize the requesting user against that conversation before you resume.

  • Gate every action that writes, deletes, sends, charges, or changes permissions.
  • Show the exact arguments to the approver, not a paraphrase generated by the model.
  • Validate edited arguments again in PHP. An edit is new input, not a trusted correction.
  • Use idempotency keys for any action that might be retried. This is an engineering recommendation based on the partial-failure behavior described below.

Recording calls and recovering from partial failures

What to record

Laravel stores a turn as ordered steps. Its conversation records expose steps, tool calls, provider calls, results, pending approvals, and failed status (Laravel AI SDK documentation). Add the details the framework cannot know about your business:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Request and turn identifiers
  • Step order
  • Tool name
  • Validated arguments, with fields you do not need for debugging redacted or hashed
  • Outcome, duration, and error category

Keep the trace within your privacy policy. Tool arguments often contain personal data.

When a turn fails partway

A turn that fails midway keeps the steps it completed. A call that has no result is treated as interrupted when the turn continues. For writes this is ambiguous, because the framework cannot tell whether the external action happened. Recover in this order:

  1. Load the turn and list each step with its status.
  2. Classify each unresolved call as read-only or as a write.
  3. Reuse the results of completed calls. Do not run them again.
  4. For an unresolved write, check the downstream system for the action, using your idempotency key or another reference, before any retry.
  5. For an unresolved read-only call, retry within the step ceiling.
  6. Tell the user which actions completed and which did not, in plain language, and offer the next step.

How can a PHP agent use MCP tools?

The Model Context Protocol (MCP) lets a server expose tools that a client can discover and call. Laravel’s MCP documentation covers both the server and client functions, and how an application’s agent can use tools loaded from MCP clients (Laravel MCP documentation (13.x)). Three points matter for an agent:

  • MCP tools are wrapped for agent use, so the agent can call them alongside local tools.
  • Searchable catalogs provide search and execute operations for tools that are not advertised all at once.
  • Limits are configurable. The package documents a maximum number of tools in one execute_tools call and a maximum response size. The documentation gives no universal numeric recommendation, so set both from your real payload sizes and test what the agent does when a limit is hit.

Location changes responsibility. A local tool runs inside your PHP process. A remote MCP server runs wherever it is hosted, and a provider-hosted tool runs on the provider’s infrastructure. Each location changes who controls logging, timeouts, and credentials, so review those separately for every tool.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing an orchestration model

Three approaches cover most designs. The decision turns on who chooses the next call and how predictable the flow is.

Approach Who chooses the next call Where tools run How tools are exposed Best fit
Direct model orchestration The model, after each result Your PHP application, or a provider-hosted tool The agent’s tools() list, with deferred search where supported Adaptive tasks where each result needs fresh model judgment
Application-side coordination Your PHP code, following a fixed graph Your PHP application, which makes the internal calls itself Usually one wrapper tool the model can call, or internal steps the model never sees Predictable flows where code filters, joins, ranks, or validates results before the model continues
MCP tool catalog The model, using search and then execute A local or remote MCP server Searchable catalog with search and execute operations, bounded by configured limits Large or shared tool sets used by several clients

OpenAI’s Programmatic Tool Calling documentation describes a hosted capability: “Programmatic Tool Calling lets a model write and run JavaScript that coordinates its tools.” That is a feature of OpenAI’s platform, not of PHP. In a PHP application, the equivalent is code you write, review, and test yourself. The same documentation favors programmatic coordination when the flow is predictable and outputs can be reduced to a smaller structured result, and favors direct calling for a single lookup or an adaptive decision that needs fresh model judgment.

Managed API, application SDK, or direct API

OpenAI’s Agents documentation separates three execution models. The practical question is how much of the harness you want the provider to run and how much your application must own.

Execution model Responsibility split, as documented
Managed Agents API The API manages more of the harness.
Agents SDK running in your application Your application controls deployment, storage, approvals, and the runtime.
Direct Responses API integration More of the wiring is left to your application.

The OpenAI Agents SDK is not presented here as a PHP option. For a PHP application, the Laravel AI SDK is a framework-specific option in its own documentation, and choosing between it and direct API calls is an architecture decision for your team.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before you build

The Laravel AI SDK and MCP pages referenced here are the 13.x documentation, checked in October 2026. Before implementation, confirm package versions, PHP and Laravel requirements, provider support for deferred search and provider-hosted tools, model eligibility, and deployment limits, because these change.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.