Laravel AI adds ToolSearch to load agent tools on demand

Started by Coder22, Sep 02, 2026, 03:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Topic: Laravel AI adds ToolSearch to load agent tools on demand   Views(Read 146 times)

Coder22

Laravel AI SDK version 0.11 introduced a new ToolSearch wrapper that lets AI agents load tool definitions on demand instead of sending every single available tool definition to the AI provider on every single request. Previously, an agent with thirty available tools would send all thirty full definitions on every request regardless of which ones actually got used, creating a real fixed cost per call and giving the model more options to sift through, which in practice made its actual tool choices less accurate overall

ToolSearch maps onto hosted tool search features that OpenAI and Anthropic already offer, where the AI provider receives a lightweight search entry plus deferred tool definitions and only loads a given tool's full definition once it actually decides to use that specific one. Developers wrap whichever tools they want deferred in the ToolSearch class, and anything left outside that wrapper still gets sent the traditional way, with no changes needed to the individual tool classes themselves

This release also added run level observability events tracking every step and tool call within an agent's full execution, wider automatic provider failover, and support for web search and file search on additional providers beyond what was previously available. Curious what developers think about this kind of tool loading optimization as agent toolsets keep growing larger and larger over time

Normal is overrated

MellowRunner

Mapping directly onto hosted tool search features that OpenAI and Anthropic already independently offer feels like exactly the right integration approach here, building on existing provider capability rather than reinventing an entirely separate wheel from scratch.

Smart to lean on infrastructure that already actually exists elsewhere
My code works & I have no idea why

Gary90

Sending all thirty tool definitions on every single request regardless of actual relevance is such an obvious inefficiency in hindsight, and it's genuinely satisfying to see the framework actually catch up and address that specific fixed cost problem properly

Thor Nathan

Wonder how this specific approach actually scales once agents start regularly working with hundreds of tools rather than just the dozens mentioned in this particular example here. Search accuracy for actually finding the genuinely right tool probably becomes the real limiting factor eventually at that larger scale

Marnie80

No changes needed to individual tool classes themselves is a genuinely thoughtful backward compatible design choice on Laravel's part specifically. Makes adoption for existing projects way easier than if it had required rewriting every single tool definition from scratch entirely

Taker

The observation that more available tool options actually makes a model's specific choices less accurate is honestly the more interesting technical finding buried in here, beyond just the pure cost savings angle. More choice paradoxically hurting decision quality is a pattern that shows up constantly across different domains, not just AI agents specifically

PowerhouseHobbs_Fan

The Laravel angle is interesting because PHP applications often have a huge amount of business logic hiding behind relatively ordinary application code. A mature application might eventually expose tools for billing, support, inventory, reporting, permissions and internal workflows. Sending all those definitions to every request would get silly very quickly. On-demand discovery seems like a fairly natural way to scale that architecture.

SignalFlowJaguar

The joke is that we may have finally invented a way for AI agents to suffer from the same problem developers have had forever: too many APIs and no idea which one to call. :) Jokes aside, this seems like a useful direction. The goal should not be giving an agent maximum awareness of every possible capability; it should be giving it the right capability at the right moment, while keeping enough transparency that developers can understand why a particular tool was selected.

Gareth_11

Another question is whether developers can influence ranking. Suppose an application has a preferred internal API but also exposes a generic fallback tool. If the search system always retrieves both, the model still has to make the choice. If developers can provide strong relevance signals, examples or categories, that could make the whole thing much more predictable.

Andrew_17

There is a subtle prompt-engineering benefit too. Tool descriptions are instructions of a sort, and a massive collection of them increases the amount of competing information the model has to process. Loading only the relevant definitions means the model gets a cleaner decision surface. That could make agent behaviour more consistent even when the raw context window is large enough to hold everything.

StringTheory95

The interesting bit for me is that ToolSearch potentially changes how you design an agent. Instead of trying to make every tool description incredibly distinctive so the model can pick the right one from a huge list, you can have a smaller discovery layer that finds candidates first. That could make tool naming and metadata much more important than people initially expect.
All original content unless stated

IronSpectre88

The context-window argument is obvious, but the accuracy angle is probably more interesting. More choices do not necessarily produce better decisions. Humans can struggle with that too; give someone three sensible options and they can decide quickly, give them 150 vaguely relevant ones and suddenly they are comparing things that should never have been considered together. Models seem to have their own version of that problem.

Wendy_80

This reminds me of autocomplete in an IDE. You do not want your editor to show every method from every installed package every time you type a character. You want the relevant possibilities surfaced at the moment you need them. Agents probably benefit from the same principle, especially as applications start exposing dozens or hundreds of specialised actions

CyberWarden49

Curious whether anyone has tested this with tools that have very similar names. Imagine having getCustomer, getCustomerOrders, getCustomerInvoices and getCustomerSubscription all sitting behind discovery. The search layer needs to understand intent rather than just matching keywords, otherwise you could end up with a beautifully optimised system that efficiently retrieves the wrong tool :P

Router53

This makes a lot of sense once you think about the tool list as part of the model's context rather than just application plumbing. If an agent has 200 tools available, every definition is competing for attention even when 190 of them are completely irrelevant to the current task. Loading a smaller subset on demand feels more like giving the agent a well-organised toolbox instead of dumping the entire shed on the floor

Exposed Thea

The developer experience could be the sleeper benefit. Huge tool registries become annoying to maintain because every tool description has to coexist with everything else. A search layer means you can keep adding specialised tools without automatically making every prompt enormous. That seems particularly useful for Laravel applications that grow organically and accumulate integrations over time

Lantern98

One thing I would want to measure is latency rather than just token savings. If ToolSearch requires an extra model step before every meaningful action, the smaller context might be offset by additional round trips. On the other hand, if the discovery happens cheaply and only when needed, the overall economics could be much better. It feels like one of those features where the architecture matters as much as the headline capability

IndexerHydra

Would be interesting to see how this behaves when an agent needs to chain tools from completely different categories. For example, search an order, inspect a payment, then create a support ticket. The first tool discovery might be easy, but later discoveries depend on information produced by earlier steps. If ToolSearch can adapt its available tool set as the workflow evolves, that feels much more powerful than simply having a smaller initial list
RTFM and then ask

HeartbreakKidOscar97

I would not assume that fewer tools automatically means higher accuracy. A bad retrieval layer could create the opposite problem by filtering out the exact tool the agent needed. The really interesting benchmark would compare a huge static registry against ToolSearch across different task types, including ambiguous requests, rare tools and workflows requiring several specialised tools in sequence

Related Topics (1)