ReAct: Schlussfolgern und mit Tools handeln
Lernen Sie das ReAct-Pattern kennen, bei dem das Modell Denkschritte mit Tool-Aktionen verknüpft, um Aufgaben zu lösen, die es nicht allein aus seinem Speicher beantworten kann
ReAct: Schlussfolgern und mit Tools handeln ist eine kostenlose Prompt Engineering & LLM Optimization for Developers-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Prompt Engineering & LLM Optimization for Developers-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Prompt Engineering & LLM Optimization for Developers-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
When Thinking Is Not Enough
Chain-of-thought helps a model reason, but reasoning alone cannot fetch live data or run code. The ReAct pattern combines Reasoning with Acting so the model can use tools mid-task.
The ReAct Loop
ReAct alternates three roles in a loop:
- Thought: reason about what to do next.
- Action: call a tool with an input.
- Observation: read the tool's result.
Repeat until the answer is ready.
A ReAct Trace
A typical trace looks like this. The model emits a thought, an action, then waits for an observation injected back into the prompt.
Thought: I need today's weather in Paris.
Action: get_weather("Paris")
Observation: 18C, light rain
Thought: I can now answer.
Answer: It is 18C with light rain in Paris.Defining the Tools
You describe the available tools in the prompt: their names, what they do, and the input format. The model picks among them.
Tools:
- search(query): web search
- calc(expr): evaluate math
- get_weather(city): current weatherStopping at the Action
In practice your code stops generation when it sees an Action, executes the real tool, then appends the Observation and resumes the model. The model never invents tool results itself.
Why It Reduces Hallucination
Because the model grounds each step in real observations, ReAct cuts hallucination on factual or computational tasks. The reasoning explains why each tool was called, aiding debugging.
Multi-Step Problems
ReAct shines on tasks needing several lookups: find a company, then its founder, then that person's birth year. Each step's observation feeds the next thought.
Limiting the Loop
Always cap the number of iterations. Without a limit, a confused model can loop forever calling tools. Add a max-step budget and a fallback answer.
for step in range(MAX_STEPS):
out = model(prompt)
if is_answer(out): break
obs = run_tool(parse_action(out))
prompt += observation(obs)Handling Tool Errors
Tools fail: timeouts, bad inputs, empty results. Feed the error back as an observation so the model can retry differently rather than crashing the loop.
Observation: ERROR: city not found.
Thought: I should try the full country name.ReAct vs Plain Chain-of-Thought
- CoT: reasons internally, no external data.
- ReAct: reasons AND acts on the world via tools.
Use ReAct whenever the answer depends on information the model cannot already know.
Foundation for Agents
ReAct is the backbone of modern LLM agents. Frameworks like LangChain implement this thought-action-observation loop under the hood to build autonomous tool-using assistants.
Quick Check
Test your understanding of ReAct.
Recap
ReAct interleaves Thought, Action, and Observation so the model reasons and uses real tools. It grounds answers, reduces hallucination, needs a step limit and error handling, and underpins modern LLM agents.
Lerne Prompt Engineering & LLM Optimization for Developers mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 12
- Lektionen
- 48
Häufig gestellte Fragen
Ist die Lektion „ReAct: Schlussfolgern und mit Tools handeln“ kostenlos?
Ja — der vollständige Text von „ReAct: Schlussfolgern und mit Tools handeln“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Prompt Engineering & LLM Optimization for Developers-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Prompt Engineering & LLM Optimization for Developers-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „ReAct: Schlussfolgern und mit Tools handeln“?
Lernen Sie das ReAct-Pattern kennen, bei dem das Modell Denkschritte mit Tool-Aktionen verknüpft, um Aufgaben zu lösen, die es nicht allein aus seinem Speicher beantworten kann Du übst Prompt Engineering & LLM Optimization for Developers mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Prompt Engineering & LLM Optimization for Developers zu starten?
Keine Vorkenntnisse erforderlich. Prompt Engineering & LLM Optimization for Developers auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „ReAct: Schlussfolgern und mit Tools handeln“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Prompt Engineering & LLM Optimization for Developers-Lektion Code schreiben und ausführen?
Ja. Jede Prompt Engineering & LLM Optimization for Developers-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Chain-of-Thought-Prompting
- Selbstkonsistenz und generiertes Wissen
- Tree-of-Thought- und Graph-Prompts
- ReAct: Schlussfolgern und mit Tools handeln