🪟 Windows TippsModify Windows Support Phone Number with PowerShell(03.09.2026 um 00:00 Uhr)
🔧 AI Nachrichten Podcast: ChatGPT schwatzt Nutzern in Deutschland jetzt Werbung auf(28.08.2026 um 08:46 Uhr)
🪟 Windows TippsMicrosoft bringt Emoji 17.0 auf Windows 11(31.08.2026 um 08:16 Uhr)
🪟 Windows TippsModify Windows Support Phone Number with PowerShell(03.09.2026 um 00:00 Uhr)
🔧 AI Nachrichten Podcast: ChatGPT schwatzt Nutzern in Deutschland jetzt Werbung auf(28.08.2026 um 08:46 Uhr)
🪟 Windows TippsMicrosoft bringt Emoji 17.0 auf Windows 11(31.08.2026 um 08:16 Uhr)

🔧 Programmierung 🕛 vor 3 Monaten 20 Min Lesezeit
0

Building a ReAct Chat Agent with the Laravel AI SDK

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Building a ReAct Chat Agent with the Laravel AI SDK



This tutorial walks through how to build a streaming, chat assistant on top of

the Laravel AI SDK (laravel/ai).



Stack: PHP 8.5 · Laravel 13 · Livewire 4 · Laravel AI SDK







1. What is the ReAct pattern?



A plain language model is a "one-shot" text predictor: you give it a question, it

gives you an answer from what it already knows. That breaks down the moment the

question depends on something the model can't know — the current time, today's

exchange rate, an exact arithmetic result, or a fact that changed after training.



ReAct (short for Reasoning + Acting) fixes this by letting the model

work in a loop instead of answering in one go:





  1. Reason — the model thinks about what the question needs.


  2. Act — if it needs outside information, it calls a tool (a function you
    provide) instead of guessing.


  3. Observe — your tool runs and returns a result; that result is fed back to
    the model as a new observation.


  4. Repeat — the model reasons about the observation and either calls another
    tool or produces its final answer.



A worked example, "What time is it in Tokyo right now?":




CODE
User:    What time is it in Tokyo right now?

Reason: I don't actually know the current time. I should call a clock tool.
Act: current_datetime(timezone: "Asia/Tokyo")
Observe: Saturday, June 6, 2026 at 11:42 PM (Asia/Tokyo)
Reason: I now have the real local time. I can answer.
Answer: It's currently 11:42 PM on Saturday, June 6, 2026 in Tokyo.






The key idea: the model never fakes the time. It recognises the gap, reaches

for a tool, and reasons over the real result. That loop — reason, act, observe,

repeat — is the whole pattern.







2. What is the Laravel AI SDK?



The Laravel AI SDK (laravel/ai) is a unified, Laravel-flavoured API for talking

to AI providers (Anthropic, OpenAI, Gemini, Groq, Ollama, and more). Instead of

hand-rolling provider-specific HTTP calls, you describe an Agent as a PHP

class and the SDK handles the rest.



The four concepts you need for this tutorial:





  • Agent — a class that bundles a system prompt (instructions()), a model
    choice, and a set of tools. It is the thing you "prompt".


  • Tool — a small class implementing Laravel\Ai\Contracts\Tool that the
    model is allowed to call. Each tool advertises a name, a description, and a
    parameter schema, and exposes a handle() method that does the work.


  • Streaming — instead of waiting for the whole answer, you can iterate over
    the response as it is generated, receiving text fragments and tool-call events
    in real time.


  • Conversation memory — the SDK can automatically persist every turn to the
    database and replay history so the agent has context on the next message.



Crucially, the SDK runs the ReAct loop for you. You define the tools and a

step limit; the SDK handles asking the model what it wants to do, executing the

chosen tool, feeding the observation back, and looping until the model is done.





Built on Prism



The Laravel AI SDK isn't talking to providers entirely on its own — it's a

higher-level abstraction built on top of






Reference: files in this walkthrough





  • app/Ai/Agents/ChatAgent.php — the agent


  • app/Ai/Tools/CurrentDateTime.php, WikipediaLookup.php, Calculator.php — custom tools


  • resources/views/components/chat/⚡main.blade.php — chat UI + streaming


  • app/Models/User.php — conversation ownership


  • database/migrations/..._create_agent_conversations_table.php — persistence schema


  • config/ai.php — provider configuration


  • tests/Feature/ChatTest.php, tests/Unit/* — tests

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Modify Windows Support Phone Number with PowerShell
1 Quelle
Die Zukunft des Einkaufens: Warum wir ein neues Kapitel aufschlagen (und wie du es mitschreiben kannst)
1 Quelle
ZDE Podcast 251: Wie sieht digitales Instore Marketing 2026 aus, Amit Chatterjee?
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Building a ReAct Chat Agent with the Laravel AI SDK

Thematisch verwandte Begriffe: Building, ReAct, Chat, Agent · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...