AI 资讯
Beyond the Prompt: Building Unhackable AI Agents — Lessons from GitHub's Top Security & Gateway Repos
Originally published on tamiz.pro . The AI agent is no longer a chatbot that reads and writes. It connects to APIs, executes code, accesses databases, and makes decisions on behalf of users. That capability is also its vulnerability surface—and attackers are already weaponizing it. Prompt injection, tool-use exploitation, and supply-chain poisoning are no longer theoretical risks. They are happening in production today. This article doesn't rehash the high-level warnings. It draws concrete architectural lessons from GitHub's most popular open-source security and gateway repositories—tools like NVIDIA NeMo Guardrails , LangChain's security contributions , Guardrails AI , Ollama's gateway patterns , and Microsoft's guidance on LLM security —and translates them into a practical blueprint for building AI agents that survive deliberate adversarial attacks. The central thesis: prompt injection is not a prompt-engineering problem. It is an input-validation and system-architecture problem. The fixes are structural, not rhetorical. Table of Contents 1. The Threat Model: Why AI Agents Are Fundamentally Different 2. The Layered Defense Architecture 3. Guardrails: Input Validation That Actually Works 4. Tool-Use Hardening: The Hidden Attack Surface 5. Gateway Patterns: Routing, Rate-Limiting, and Sandboxing 6. Supply-Chain and Model-Level Threats 7. Observability and Incident Response 8. A Minimal Production-Ready Agent Skeleton 9. When Your Defenses Fail Frequently Asked Questions 1. The Threat Model: Why AI Agents Are Fundamentally Different Traditional software attacks target inputs at the network boundary. AI agents change the boundary. The user's prompt is no longer just data—it is often executable context . When an agent interprets a prompt as instructions, the prompt becomes a vector for command injection, data exfiltration, and privilege escalation. Consider the attack surface: Direct prompt injection : The user provides a malicious prompt like "Ignore previous instruct
AI 资讯
Beyond the Black Box: Reclaiming Developer Agency in an Era of AI-Assisted Coding
Originally published on tamiz.pro . The promise of AI-assisted coding is seductive: velocity, reduced boilerplate, and the elimination of context-switching fatigue. Tools like GitHub Copilot, Cursor, and various IDE plugins have transitioned from novelty to necessity in many modern codebases. However, a subtle but dangerous drift is occurring in our development practices. We are witnessing a shift from "writing code" to "reviewing AI output," and in doing so, we are ceding our most valuable asset as engineers: agency. When we stop asking how a system works and start accepting what the machine says it does, we degrade our ability to debug, architect, and innovate. This article argues that maintaining developer agency in the age of automation is not just a philosophical stance, but a critical engineering requirement for building robust, secure, and maintainable systems. The Illusion of Competence The primary threat to developer agency is the illusion of competence. When an AI generates a complex React component, a sophisticated regex, or a multi-join SQL query in seconds, it creates a cognitive shortcut. The human mind, prone to efficiency, often skips the deep verification step because the output "looks right." This is known in psychology as the fluency heuristic—the ease with which information is processed is mistaken for its truthfulness. Consider the following scenario. You are tasked with implementing a rate-limiting middleware for an API endpoint. Instead of reviewing the existing express-rate-limit library or writing a simple in-memory counter, you ask your AI assistant to "create a custom rate limiter using Redis." It provides a snippet using ioredis with a sliding window algorithm. The code compiles. It runs in your local environment. You merge the PR. Three months later, under load, your Redis connection pool exhausts. The AI-generated code did not handle connection errors gracefully, nor did it account for the latency spikes introduced by the network round-
AI 资讯
Beyond Prompt Guessing: Why LSP Integration is the Missing Protocol for Reliable AI Coding Agents
Originally published on tamiz.pro . The current generation of AI coding assistants operates on a fundamental paradox: they are trained on the entirety of public code, yet they struggle to understand the specific codebase they are embedded in. For years, the industry has relied on prompt guessing —feeding the LLM a ragged collection of nearby code lines, hoping the semantic context is implicit. This approach is brittle. It fails when symbols are imported, when types are inferred, or when the logic spans multiple files.\n\nThe solution isn't a bigger model; it's a better protocol. The Language Server Protocol (LSP) is the missing link between static analysis and generative AI. By integrating LSP into AI agents, we move from probabilistic guessing to deterministic understanding. This article explores why LSP is critical for reliable coding agents, how to architect an LSP-augmented agent, and the technical pitfalls of this integration.\n\n## The Semantic Gap: Why Prompts Aren't Enough\n\nTo understand why LSP is necessary, we must first diagnose the failure modes of prompt-only AI coding agents. An LLM is a probabilistic next-token predictor. It does not "know" your code; it has seen patterns similar to your code in its training data. When you ask an AI agent to \"refactor this function,\" it relies on the context window to provide relevant information.\n\n### The Context Window Bottleneck\n\nThe primary limitation is the context window. Even with 128k tokens, you cannot fit an entire modern codebase. Agents must select a subset of files to include. Without explicit semantic queries, this selection is often heuristic-based (e.g., \"include the last 50 lines\") or simple semantic similarity (vector search). Both approaches miss critical structural relationships.\n\nConsider this example:\n\n python\n# file: user_service.py\nclass UserService:\n def get_user(self, user_id: int):\n # ... logic ...\n return db.query(User).filter(id=user_id)\n\n# file: controllers.py\ndef ha