惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
B
Blog
博客园_首页
博客园 - 司徒正美
有赞技术团队
有赞技术团队
博客园 - 聂微东
I
InfoQ
美团技术团队
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
The TypeScript AI Agent Architecture I Would Use in 2026
Raju Dandiga · 2026-05-05 · via DEV Community

Most AI apps do not fail because the model is bad. They fail because the system surrounding the model lacks structure.

The first version usually starts the same way. A user sends input, the app calls an LLM, and the response is returned. That is enough for a demo, but the moment the system needs to do anything real, the design starts to break.

A real AI system does more than generate text. It may need to call APIs, use tools, remember context, validate outputs, retry on failures, ask for human approval, and explain what happened. At that point, you are not building a chatbot anymore. You are building a system.

In 2026, I would not start with prompts. I would start with architecture.

The model is not the architecture

One of the biggest mistakes I see is treating the LLM as the center of the system. The model can suggest what to do next, but it should not control everything. It should not decide which tools are safe, whether a user has permission, or whether a risky action should proceed.

The model should propose. The application should decide. This simple shift changes how you design everything.

Think in terms of a loop, not a prompt

An agent is not a better prompt. It is a loop. The system gives the model a goal and context. The model suggests the next step. The system validates that step, executes it if allowed, records the result, and continues until the task is completed or blocked. Without this structure, agents become unpredictable. They repeat steps, call the wrong tools, or silently fail. With structure, they become workflows you can reason about.

Start with a simple state model

Before anything else, define state.

type AgentState = {
  goal: string;
  steps: AgentStep[];
  status: "running" | "blocked" | "completed" | "failed";
};

type AgentStep = {
  name: string;
  input: unknown;
  output?: unknown;
};

Enter fullscreen mode Exit fullscreen mode

This small structure changes everything. The system is no longer a single request-response call. It becomes a stateful workflow. You can inspect it, debug it, resume it, and control it.

This is the simplest way to think about it. The model suggests. The runtime controls. The system decides what actually happens. I would keep the architecture simple and consistent.

The five layers that actually matter

  1. The API layer handles requests, users, and permissions.
  2. The runtime layer controls the loop, state, and execution.
  3. The model layer interacts with LLMs through a gateway.
  4. The tool layer defines what the agent is allowed to do.
  5. The control layer handles validation, memory, observability, and approvals.

That is enough for most real systems.

Tools should be contracts, not suggestions

Tools are what make agents useful, but they are also where risk enters the system. If a model can call tools, those tools need structure.

type Tool = {
  name: string;
  risk: "low" | "high";
  execute: (input: unknown) => Promise<unknown>;
};

Enter fullscreen mode Exit fullscreen mode

The key idea is simple.The model can request a tool. The system decides if that request is allowed. This is where most demos fall short. They give the model too much control.

Memory should be intentional

More context does not always mean better results. Instead of sending everything to the model, retrieve only what matters. Think of memory as useful signals, not a full transcript. Short-term memory belongs to the current task. Semantic memory stores reusable facts. Episodic memory stores past actions. The important part is not storing memory. It is retrieving the right memory at the right time.

This keeps the system focused, cheaper, and easier to debug.

Structured outputs make the system usable

Free text works for user responses. It does not work for system decisions. If the model is deciding what to do next, it should return structured data.

type Decision = {
  action: "call_tool" | "finish" | "ask_user";
  toolName?: string;
};

Enter fullscreen mode Exit fullscreen mode

This allows the system to validate behavior instead of guessing from text. The model suggests. The system verifies.

Observability is not optional

Agent systems are harder to debug because they are not deterministic. The same input may take a different path. If something goes wrong, you need to know:

  • What the model saw
  • What it decided
  • Which tool it called
  • What came back

Without this, debugging becomes guesswork. Even a simple step trace makes a big difference.

Where frameworks fit

Frameworks can help, but they do not replace architecture.

Tools like:

  • Vercel AI SDK
  • LangGraph
  • OpenAI Agents SDK
  • Model Context Protocol

are useful for building agent systems. But they do not define your boundaries.

You still need to decide how state works, how tools are exposed, how outputs are validated, and how failures are handled.

The architecture I would trust

The architecture I would use in 2026 is not the most complex one. It is the one that gives control back to the system.

  • A stateful workflow.
  • A controlled loop.
  • Typed tools.
  • Structured outputs.
  • Observable steps.
  • Clear boundaries between model decisions and system execution.

That is what turns an AI demo into something you can actually trust. Because in real systems, reliability matters more than clever prompts.