Laravel AI Agent Live Web Search with WebSearch Tool | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Give Your Laravel AI Agent Live Web Search with WebSearch Tool

   [Laravel](https://www.msaied.com/public/articles?category=laravel) [AI](https://www.msaied.com/public/articles?category=ai) 

 Give Your Laravel AI Agent Live Web Search with WebSearch Tool
===============================================================

 Learn how to equip a Laravel AI support agent with live web search using the SDK's built-in WebSearch provider tool, including domain allow-listing and result capping for safe, real-time answers.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 18 Jun 2026 · Updated 18 Jun 2026 · 3 min read

ShareCopy linkCopied

 ![Give Your Laravel AI Agent Live Web Search with WebSearch Tool](https://cdn.msaied.com/236/6b6b7526226d6643c3704b5bcce25801.png) 

  On this page +1. [Why Your AI Agent Needs Live Web Access](#why-your-ai-agent-needs-live-web-access)
2. [The Two Provider Tools: WebSearch and WebFetch](#the-two-provider-tools-websearch-and-webfetch)
3. [Adding WebSearch to the Support Agent](#adding-websearch-to-the-support-agent)
4. [Testing Real-World Queries](#testing-real-world-queries)
5. [The Agent's Full Tool Set (After Episode 8)](#the-agents-full-tool-set-after-episode-8)
6. [Key Takeaways](#key-takeaways)

 Why Your AI Agent Needs Live Web Access
---------------------------------------

A well-built Laravel AI support agent can query order history, search a knowledge base, and hold multi-turn conversations. But the moment a customer asks "Is FedEx experiencing delays right now?", a static knowledge base falls flat. Shipping carrier statuses, outage pages, and real-time availability change by the minute — and training data can be months stale.

Episode 8 of the *Ship AI with Laravel* series solves this by wiring the agent into the live web using the SDK's built-in provider tools.

The Two Provider Tools: WebSearch and WebFetch
----------------------------------------------

The Laravel AI SDK ships with two provider-level tools:

- **WebSearch** — queries the web and returns a ranked list of results.
- **WebFetch** — fetches and reads a specific URL's content.

> **Note:** WebFetch is currently supported on Anthropic and Gemini only. Because this series runs on OpenAI, WebSearch is the right choice and handles the use case well.

Adding WebSearch to the Support Agent
-------------------------------------

The integration involves three decisions:

1. **Cap the result count.** The example limits results to five to keep context concise and costs predictable.
2. **Define an allow list.** Restrict the domains the agent may search. Without this, the agent could browse anywhere on the internet and return unvetted content to customers.
3. **Update the system instructions.** Tell the agent to be transparent about the source of its answer — distinguishing between your official policy and something retrieved from the live web.

A simplified configuration looks like this:

```php
WebSearch::make()
    ->maxResults(5)
    ->allowedDomains([
        'fedex.com',
        'ups.com',
        'usps.com',
    ])

```

The provider handles the actual HTTP requests and ranking; your code only declares the constraints.

Testing Real-World Queries
--------------------------

With WebSearch active, the agent handles two scenarios that previously produced unhelpful responses:

- **FedEx delay check** — the agent queries both the order record and FedEx's live status page, then synthesises a single answer.
- **USPS Priority Mail transit time** — instead of guessing from potentially outdated training data, the agent returns the current published estimate.

You can also bias results by geographic region if your customer base is concentrated in a specific area, giving locally relevant answers without extra application logic.

The Agent's Full Tool Set (After Episode 8)
-------------------------------------------

At this point the support agent has five tools available:

- Order lookup
- Customer history
- Knowledge base search
- Document search
- Live web search

It can now answer from your database, your internal documentation, *and* the live web — covering the full spectrum from structured business data to real-time external information.

Key Takeaways
-------------

- Use the SDK's `WebSearch` provider tool to give a Laravel AI agent access to live web results.
- Always define an `allowedDomains` list — leaving it open lets the agent retrieve and surface arbitrary web content.
- Cap `maxResults` to control context size and inference cost.
- Update system instructions so the agent cites whether an answer comes from internal policy or a live web source.
- `WebFetch` (for reading a specific URL) is currently limited to Anthropic and Gemini; OpenAI users should rely on `WebSearch`.
- Location biasing is available when your users are concentrated in a specific region.

---

*Source: [Ship AI with Laravel: Give Your AI Agent Live Web Search](https://laravel-news.com/ship-ai-with-laravel-give-your-ai-agent-live-web-search) — Laravel News, June 18, 2026*

- [Laravel](https://www.msaied.com/public/articles?search=Laravel)
- [AI Agent](https://www.msaied.com/public/articles?search=AI%20Agent)
- [WebSearch](https://www.msaied.com/public/articles?search=WebSearch)
- [PHP](https://www.msaied.com/public/articles?search=PHP)
- [OpenAI](https://www.msaied.com/public/articles?search=OpenAI)
- [Support Bot](https://www.msaied.com/public/articles?search=Support%20Bot)

 Frequently asked questions 
---------------------------

  Why is the domain allow list required when using WebSearch in a Laravel AI agent?Without an allow list, the agent can browse any website and return unvetted content directly to customers. Restricting allowed domains ensures the agent only retrieves information from trusted sources, such as official carrier status pages.

   Can I use WebFetch instead of WebSearch with OpenAI in Laravel?No. WebFetch is currently supported only on Anthropic and Gemini providers. If your Laravel AI project runs on OpenAI, you should use WebSearch, which covers the same real-time lookup use case.

   How do I limit the number of web results returned by the WebSearch tool?Pass a maxResults value when configuring the tool — for example, setting it to 5. This keeps the context window concise and helps control inference costs.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com/public#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleFilament v4 Schema-Based Forms, Infolists, and the Unified Schema API](https://www.msaied.com/public/articles/filament-v4-schema-based-forms-infolists-and-the-unified-schema-api) [Next article'The Story of PHP' Documentary Teaser Is Out — Watch It Now](https://www.msaied.com/public/articles/the-story-of-php-documentary-teaser-is-out-watch-it-now)  

   On this page
-------------

1. [Why Your AI Agent Needs Live Web Access](#why-your-ai-agent-needs-live-web-access)
2. [The Two Provider Tools: WebSearch and WebFetch](#the-two-provider-tools-websearch-and-webfetch)
3. [Adding WebSearch to the Support Agent](#adding-websearch-to-the-support-agent)
4. [Testing Real-World Queries](#testing-real-world-queries)
5. [The Agent's Full Tool Set (After Episode 8)](#the-agents-full-tool-set-after-episode-8)
6. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
