Concept #94Mediumextended-ai-concepts

What is PBA in AI (Perception, Brain, Action)?

#gen-ai#agents

Answer

PBA in AI (Perception, Brain, Action)

PBA (Perception-Brain-Action) is a framework for understanding how AI agents are structured, analogous to the human cognitive loop.

The PBA Framework

text
Environment
[PERCEPTION] — senses the environment
[BRAIN]      — processes, reasons, decides
[ACTION]     — acts on the environment
     └────────────── feedback loop

Each Component Explained

ComponentIn HumansIn AI Agents
PerceptionEyes, ears, skinInput processing (text, images, sensor data)
BrainNeocortex — reasoningLLM — language model that reasons
ActionHands, voice, movementTool calls, API calls, file writes, messages

PBA in AI Agent Architecture

python
class AIAgent:
    def __init__(self, llm, tools, memory):
        self.llm = llm          # Brain
        self.tools = tools      # Action mechanisms
        self.memory = memory    # Part of Brain (long-term storage)

    def perceive(self, environment_input):
        '''PERCEPTION: Process raw input into structured context'''
        return {
            "raw_input": environment_input,
            "retrieved_memory": self.memory.search(environment_input),
            "context": self.process_input(environment_input)
        }

    def think(self, perception: dict) -> str:
        '''BRAIN: Reason and decide next action'''
        prompt = f'''
        Context: {perception['context']}
        Memory: {perception['retrieved_memory']}
        Task: {perception['raw_input']}

        What should I do next? Choose a tool or respond directly.
        '''
        return self.llm.invoke(prompt)

    def act(self, decision: str):
        '''ACTION: Execute the decided action'''
        tool_name, tool_args = self.parse_decision(decision)
        if tool_name in self.tools:
            result = self.tools[tool_name](**tool_args)
            self.memory.store(result)  # Update memory
            return result
        return decision  # Direct response

    def run(self, task: str):
        '''Full PBA loop'''
        while True:
            perception = self.perceive(task)
            decision = self.think(perception)
            result = self.act(decision)
            if self.is_complete(result):
                return result
            task = f"Previous result: {result}. Continue..."

PBA Mapping to Modern AI Systems

SystemPerceptionBrainAction
ChatGPTText inputGPT-4oText output only
Claude CodeFiles + terminalClaudeFile edits, shell commands
AutoGPTWeb + filesGPT-4Web search, file I/O
Robot AICamera, LIDARNeural netMotor commands
Self-drivingCameras, radarPerception + decision modelSteering, braking

Expanded PBA: Adding Memory

Modern agent frameworks extend PBA with memory layers:

text
PERCEPTION → Working Memory (context window)
              BRAIN (LLM reasoning)
              Long-term Memory (vector DB)
ACTION ← Decision ← Reasoning

Why PBA Matters for Gen AI Engineers

Understanding PBA helps you design better agents:

  • Perception — what data should the agent receive? How to preprocess it?
  • Brain — which LLM? How to structure reasoning prompts?
  • Action — what tools does the agent need? How to handle failures?
  • Feedback — how does the agent learn from action results?

Every AI agent framework (LangGraph, AutoGen, CrewAI) implements some version of this PBA loop.