<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Diego Maye on Medium]]></title>
        <description><![CDATA[Stories by Diego Maye on Medium]]></description>
        <link>https://medium.com/@diegomaye_30175?source=rss-ce32ff0c61a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KRZ_jVKGmGjqDt7w</url>
            <title>Stories by Diego Maye on Medium</title>
            <link>https://medium.com/@diegomaye_30175?source=rss-ce32ff0c61a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 06:02:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@diegomaye_30175/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Anatomy of an AI Agent]]></title>
            <link>https://medium.com/@diegomaye_30175/anatomy-of-an-ai-agent-84b5b330cf3b?source=rss-ce32ff0c61a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/84b5b330cf3b</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ai-agent-development]]></category>
            <dc:creator><![CDATA[Diego Maye]]></dc:creator>
            <pubDate>Fri, 25 Apr 2025 10:34:10 GMT</pubDate>
            <atom:updated>2026-09-14T18:27:16.198Z</atom:updated>
            <content:encoded><![CDATA[<p>In recent years, we’ve shifted from thinking of artificial intelligence as an isolated model that generates text to witnessing the rise of true intelligent agents — digital entities that reason, act, remember, and collaborate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*SpUmTnBY1mI2xg3OSWx4VQ.png" /></figure><p>But what exactly is an AI agent? And how do you build one today using tools like LangGraph, LangFlow, n8n, or AWS Bedrock? In this article, we dissect the functional anatomy of an AI agent, exploring its essential components and how they integrate into intelligent workflows.</p><h3>Model vs Agent</h3><p>A model like GPT is a neural network trained to predict text: it takes input and returns output — without memory or action capability. An agent, on the other hand, is a system that uses one or more models to reason, decide, and act. While the model is passive, the agent is active: it has goals, accesses tools, queries knowledge bases, calls APIs, records memory, and solves tasks autonomously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*pION8_EDVefVIceJOQq47g.png" /></figure><h3>A Brief Introduction to Models, Language Models, and Multimodal Models</h3><p>Transformers are a type of neural network, it were developed by <a href="https://medium.com/u/be36e94a7e47">Google</a> in 2017. Models like GPT are called <strong>Generative Pre-trained Transformers</strong>, trained with massive datasets.</p><p>Besides GPT, there are other <strong>foundation models</strong> like BERT and T5. They are called “foundational” because they are trained on a specific architecture/corpus combination. Today’s models may or may not be foundational depending on whether they use such a pairing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*KvOQ-vXo2WfAqmSDRLVIng.png" /></figure><p>In daily use, we refer to all of them as <strong>LLMs</strong> (Large Language Models), such as GPT-3, GPT-4o, or Claude Sonnet. Not all are <strong>multimodal</strong>, meaning capable of processing and generating various data types like text, images, audio, and even video.</p><h3>Prompt</h3><h4>Definition</h4><p>A prompt is an input text designed to guide the model’s output. In agent engineering, prompts can be injected by algorithms or introduced via libraries within the agent.</p><h4>System Prompt: the Agent’s Intent</h4><p>The starting point of any agent is the <strong>System Prompt</strong>: a set of rules defining its personality, goals, and expected behavior.</p><h4>System Prompt vs Prompt</h4><p>In AI agents, the system prompt is a special prompt at the start that defines the agent’s base behavior: how it should act, its role, available tools, etc.</p><h4>Types</h4><p>Beyond the typical “pretend you are…”, today’s prompts are:</p><ul><li><strong>Modular</strong> (divided into blocks: instructions, context, examples)</li><li><strong>Dynamic</strong> (injected with user or real-time info)</li><li><strong>Programmable</strong> (with conditional or adaptive logic)</li></ul><p>Good prompt engineering enables greater precision, robustness, and alignment with the agent’s function.</p><h3>LLMs: the Reasoning Engine</h3><p>LLMs like GPT, Claude, Mistral, or AWS Bedrock models are the cognitive core of the agent. They don’t just generate text — they evaluate scenarios, plan steps, and solve problems.</p><p><strong>Key techniques:</strong></p><ul><li><strong>Chain of Thought</strong>: step-by-step reasoning</li><li><strong>ReAct</strong>: combines reflection and action — ideal for agents with tools</li><li><strong>Tree of Thought</strong>: branches hypotheses and compares them</li></ul><p>Within the agent, the LLM becomes part of the <strong>strategic reasoner</strong> — not just a chatbot.</p><h3>Context: the Agent’s Operating Ground</h3><p>Context in large language models (LLMs) and AI agents is the information available to the system when processing requests or making decisions. It acts as the system’s “working memory” and includes:</p><ul><li>The user’s current query or instruction</li><li>Conversation history from previous exchanges</li><li>External knowledge retrieved from databases or documents</li><li>System instructions that guide the AI’s behavior</li><li>Information gathered from tools or APIs</li></ul><p>Context allows AI systems to maintain coherent conversations, reference previously discussed information, and provide relevant responses based on the full situational understanding rather than just the immediate input. The management of this context — including what information to keep, discard, or retrieve — is a critical aspect of creating effective AI systems.</p><p>Agents need <strong>context</strong> to make decisions. This can be:</p><ul><li><strong>Conversational</strong> (dialogue history)</li><li><strong>Environmental</strong> (system state, time, location)</li><li><strong>Transactional</strong> (user data, CRM, APIs)</li></ul><p>In terms of LLM context windows changes depending on the Foundational model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*M_EHtQXMuFmm6mT8kc98iw.png" /><figcaption>Modelos Ventana de contexto maxima por cada modelo de lenguaje</figcaption></figure><h3>Tools: Real-World Actions</h3><p>An agent that only talks is limited. Its true value lies in its ability to use <strong>tools</strong> such as APIs, databases, scripts, or automation flows.</p><p>These tools are:</p><ul><li>Invoked by the LLM via <strong>Function Calling</strong></li><li>Orchestrated via frameworks like <strong>LangChain</strong>, <strong>LangGraph</strong>, or <strong>n8n</strong></li><li>Extended with plugins, connectors, or cloud integrations</li></ul><p>Example: if a user asks “What tasks do I have today?”, the LLM may invoke a tool that accesses Google Calendar or a CRM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*3sz6giQYCNmjRz8E2uegPw.png" /></figure><h3>Guardrails: Ethics and Hallucinations</h3><p>Without limits, an agent can be risky. <strong>Guardrails</strong> make it safe and reliable by setting ethical, technical, and legal boundaries.</p><p>Guardrails help:</p><ul><li>Avoid bias by identifying/correcting unfair data</li><li>Reduce hallucinations by verifying model output</li><li>Protect privacy by complying with regulations and securing data</li></ul><p>Example: if an assistant provides unsupported medical advice, guardrails filter or correct the response before delivery.</p><h3>Knowledge Base: Structured Knowledge Access</h3><p>Agents can connect to <strong>external knowledge bases</strong> not stored in the model but accessible during reasoning.</p><p>Common implementations include:</p><ul><li><strong>Semantic embeddings</strong> an embedding is a vector that captures content meaning; closeness shows similarity and enables smart search.</li><li><strong>Vector DBs</strong> two types: Dedicated vector stores excel at quick similarity search on embeddings and traditional databases bolt on vector search, sacrificing some speed for simplicity.</li><li><strong>RAG</strong> (Retrieval-Augmented Generation) to retrieve from vector database before generating</li></ul><p>This enables accurate, up-to-date responses aligned with proprietary or user-specific data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*saQ1ffBDvHEmSZ4mDzCpUA.png" /><figcaption>Vector databases in the market</figcaption></figure><h3>Memory: Short and Long Term</h3><p>An agent without memory is just a fancy repeater. Memory gives continuity, personalization, progressive learning, and persistent context — key to evolving from chatbot to intelligent agent.</p><h4>Short-Term Memory</h4><p>Maintains immediate conversation or task context, like a sliding window over recent interactions. Keeps the model aware without overloading the prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*W15o8K3tJUWeEXkI2ILE9g.png" /></figure><p><strong>Techniques:</strong></p><ul><li>Direct conversational history in the prompt</li><li>Dynamic summarization</li><li>Sliding windows (interaction/token limits)</li></ul><p>Managed with <strong>LangChain</strong>, <strong>LangGraph</strong>, or <strong>LlamaIndex</strong>, using buffers, summaries, and hybrid strategies.</p><h4>Long-Term Memory</h4><p>Allows agents to remember facts, habits, and events over time — even across sessions. This helps the agent <strong>grow and adapt</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYoMRfhUrWsG8OdjAl2FDg.png" /></figure><h4>Technical Implementation</h4><p>Modern agents move far beyond a single static prompt — they maintain <strong>dynamic memory layers</strong> that are written, queried, and trimmed on every turn so the system can reason coherently over hours, days, or months of interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Ulkwte8rSVOsN-JNViWi7A.png" /></figure><h4>Typical Pipeline</h4><ol><li><strong>Receive message</strong> → enqueue event (Kafka/RabbitMQ).</li><li><strong>Enrich &amp; vectorize</strong> → generate embedding + metadata.</li><li><strong>Persist</strong> → write to vector DB, SQL row, or both.</li><li><strong>Route query</strong> → a router agent (LangGraph) selects short-term buffer, long-term store, or external knowledge.</li><li><strong>Generate</strong> → LLM produces answer, citing retrieved context.</li><li><strong>Update memory</strong> → store new message, rating, or summary back into the appropriate layer.</li></ol><blockquote><strong><em>Production tip:</em></strong><em> keep memory storage </em><strong><em>decoupled</em></strong><em> from the LLM. Version or re-embed vectors in the background, then flip a feature flag to switch indices with zero downtime.</em></blockquote><p>With this architecture an agent can <strong>learn user habits</strong>, <strong>remember cross-session events</strong>, and <strong>trigger actions</strong> based on persistent knowledge — all while scaling cleanly and staying maintainable.</p><h3>Orchestration: The Agent’s Soul</h3><p>Beyond the LLM, the agent is a living system. Tools like <strong>LangGraph</strong>, <strong>n8n</strong>, <strong>AWS Step Functions</strong>, or <strong>Bedrock Agents</strong> define the logical flow: what steps to follow, when to call a tool, query a DB, or talk to another agent.</p><p>A good agent is <strong>modular, auditable, and expandable</strong>, made possible by this programmable orchestration layer.</p><h3>Multi-Agent Systems: Cognitive Collaboration</h3><p>Multi-agent systems mark a significant evolution — multiple specialized agents collaborate to perform complex tasks more efficiently than a single one.</p><p>Each agent takes a specific role (planner, executor, critic, researcher), distributing cognitive load and optimizing workflows.</p><p><strong>LangGraph</strong> enables orchestration via graph-based architecture, where:</p><ul><li>Each agent is a <strong>node</strong></li><li>Connections (edges) define flow/control/communication</li><li><strong>Shared state</strong> is automatically managed across agents</li></ul><p><strong>Benefits:</strong></p><ul><li><strong>Modularity</strong>: easier development and maintenance</li><li><strong>Specialization</strong>: agents focus on specific tasks</li><li><strong>Control</strong>: structured flow between agents</li></ul><p>This approach is used in <strong>research assistants</strong>, where agents for search, planning, and writing collaborate to generate detailed reports.</p><h3>MCP: Model Context Protocol</h3><p><strong>MCP (Model Context Protocol)</strong> is an open standard by Anthropic (Nov 2024), designed to standardize how AI applications — especially LLM-based — interact with data sources and external tools.</p><h4>Main Components:</h4><ul><li><strong>MCP Host</strong>: AI apps (chat clients, IDEs) accessing data via MCP</li><li><strong>MCP Client</strong>: interfaces maintaining connections with MCP servers</li><li><strong>MCP Server</strong>: provides standardized services/functions to MCP clients</li><li><strong>Local Data Sources</strong>: databases, files, local services</li><li><strong>Remote Services</strong>: APIs or external services integrated via MCP</li></ul><p>This modular design allows scalable integration between AI and external tools/data.</p><h4>Core Primitives:</h4><ul><li><strong>Resources</strong>: referenceable and retrievable data (documents, images, DB schemas)</li><li><strong>Prompts</strong>: templates for effective LLM interaction</li><li><strong>Tools</strong>: functions executed by the LLM (querying DBs, calling APIs, processing data)</li></ul><p>These primitives streamline structured, efficient interaction between models and external sources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84b5b330cf3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>