Published on

Agentic Pattern

Agentic Pattern

AI agent is a system designed to perceive its environment and take actions to achieve a specific goal.

  1. Get the mission
  2. Scan the scene
  3. Think it through
  4. Take action
  5. Learn and get better

Agent Levels

Level 0: The Core Reasoning Engine

While an LLM is not an agent in itself, it can serve as the reasoning core of a basic agentic system.

Level 1: The Connected Problem-Solver

This ability to interact with the outside world across multiple steps is the core capability of a Level 1 agent.

Level 2: The Strategic Problem-Solver

At this level, an agent's capabilities expand significantly, encompassing strategic planning, proactive assistance, and self-improvement, with prompt engineering and context engineering as core enabling skills.

Level 3: The Rise of Collaborative Multi-Agent Systems

The ability to automate entire business workflows from start to finish.

At its core, an agentic system is a computational entity designed to perceive its environment (both digital and potentially physical), make informed decisions based on those perceptions and a set of predefined or learned goals, and execute actions to achieve those goals autonomously.

Core Patterns

Prompt Chaining

The core idea is to break down the original, daunting problem into a sequence of smaller, more manageable sub-problems. Each sub-problem is addressed individually through a specifically designed prompt.

Each step in the chain can be meticulously crafted and optimized to focus on a specific aspect of the larger problem, leading to more accurate and focused outputs.

Each step is simpler and less ambiguous, which reduces the cognitive load on the model and leads to a more accurate and reliable final output.

To mitigate this, specifying a structured output format, such as JSON or XML, is crucial.

By deconstructing complex problems into a sequence of simpler, more manageable sub-tasks, prompt chaining provides a robust framework for guiding large language models.

Routing

  1. Analyze the user's query.
  2. Route the query based on its intent.

Use the Routing pattern when an agent must decide between multiple distinct workflows, tools, or sub-agents based on the user's input or the current state.

Parallelization

While these patterns are essential, many complex agentic tasks involve multiple sub-tasks that can be executed simultaneously rather than one after another. This is where the Parallelization pattern becomes crucial.

The parallelization pattern is a method for optimizing computational workflows by concurrently executing independent sub-tasks.

Reflection

The Reflection pattern involves an agent evaluating its own work, output, or internal state and using that evaluation to improve its performance or refine its response.

Reflection can occasionally be facilitated by a separate agent whose specific role is to analyze the output of an initial agent.

  1. The Producer Agent: This agent's primary responsibility is to perform the initial execution of the task. It focuses entirely on generating the content.
  2. The Critic Agent: This agent's sole purpose is to evaluate the output generated by the Producer.

A powerful implementation is the Producer-Critic model, where a separate agent (or prompted role) evaluates the initial output.

Tool Use

The Tool Use pattern, often implemented through a mechanism called Function Calling, enables an agent to interact with external APIs, databases, services, or even execute code.

Tool Use (Function Calling) allows agents to interact with external systems and access dynamic information.

Planning

Planning is the ability for an agent or a system of agents to formulate a sequence of actions to move from an initial state towards a goal state.

Advanced Patterns

Multi-Agent Collaboration

The Multi-Agent Collaboration pattern involves designing systems where multiple independent or semi-independent agents work together to achieve a common goal.

Memory Management

  1. Short-Term Memory (Contextual Memory)
  2. Long-Term Memory (Persistent Memory)

Data is typically stored outside the agent's immediate processing environment, often in databases, knowledge graphs, or vector databases.

Learning and Adaptation

  1. Reinforcement Learning
  2. Supervised Learning
  3. Unsupervised Learning

Human-in-the-Loop

The core principle of HITL is to ensure that AI operates within ethical boundaries, adheres to safety protocols, and achieves its objectives with optimal effectiveness.

One common approach involves humans acting as validators or reviewers, examining AI outputs to ensure accuracy and identify potential errors.

Despite its benefits, the HITL pattern has significant caveats, chief among them being a lack of scalability.

Chain of Thought

The Chain of Thought (CoT) prompting technique is a powerful method for improving the reasoning abilities of language models by explicitly prompting the model to generate intermediate reasoning steps before arriving at a final answer. Instead of just asking for the result, you instruct the model to "think step by step." This process mirrors how a human might break down a problem into smaller, more manageable parts and work through them sequentially.

CoT helps the LLM generate more accurate answers, particularly for tasks that require some form of calculation or logical deduction, where models might otherwise struggle and produce incorrect results. By generating these intermediate steps, the model is more likely to stay on track and perform the necessary operations correctly.

Summary

Chaining for sequential execution, Routing for dynamic path selection, and Parallelization for concurrent task execution.

THE END