Course contentsShow
← AI Engineering
Lesson 631 of 1,88616. AI Agents - ImplementationFree lesson

Building the Decision Module

Use an LLM to determine the next action based on current state and observations.

Building the Decision Module

What you'll learn: How to implement the "brain" of your AI agent—the decision module that uses an LLM to choose the next action based on what the agent observes.

The Decision Module's Role

Think of the decision module as your agent's strategic command center. It receives the current state (what your agent knows) and fresh observations (what just happened), then consults an LLM to determine what action to take next. This is where your agent transforms from a passive system into an active problem-solver.

Core Components

Your decision module needs three inputs:

  1. Current state – The agent's context, history, and goals
  2. Recent observations – New information from the environment or previous actions
  3. Available actions – The tools or operations the agent can perform

The module then:

  • Formats this information into a clear prompt for the LLM
  • Calls the LLM with appropriate parameters
  • Parses the LLM's response to extract the chosen action
  • Returns a structured decision (which action + any parameters)

How It Works

Imagine a customer service agent. The state includes conversation history, the observation is "customer asks about refund policy," and available actions are search_knowledge_base, escalate_to_human, or provide_answer. The decision module prompts the LLM: "Given this context and question, what should you do next?" The LLM might respond with search_knowledge_base with parameter query: "refund policy".

This module sits between observation and action—it's the reasoning step in your perception-reasoning-action loop.

Key Takeaway: The decision module transforms observations and state into actionable decisions by leveraging an LLM's reasoning capabilities to select the most appropriate next action from available options.