Back to .md Directory

Agent Design Fundamentals

| Component | Responsibility | Example |

May 2, 2026
0 downloads
0 views
ai agent llm rag prompt eval guardrails safety
View source

Agent Design Fundamentals

Core Components

ComponentResponsibilityExample
PerceptionNormalize/parse inputsUser text → structured intent
PlanningBreak goal into stepsHigh-level plan tree
MemoryPersist relevant infoConversation history store
ToolingExtend capabilitiesWeb search, DB query
ReasoningInfer intermediate statesHypothesize missing facts
Action ExecutionPerform stepCall API, write file
EvaluationScore outputsJSON validity, factuality
GovernanceEnforce policiesOutput filter, rate limiter

Control Loop Pseudocode

while not goal_reached and iterations < max_iters:
    observe_state()
    plan = planner.decide(next_goal)
    if plan.requires_tool:
        tool_result = tool_executor.execute(plan.tool, plan.args)
    reasoning = reasoner.reflect(plan, tool_result)
    updated_state = state_updater.apply(tool_result, reasoning)
    if governance.blocked(updated_state):
        escalate_or_abort()

Autonomy Levels

  1. Scripted sequence
  2. Tool suggestions (human approve)
  3. Semi-autonomous loops (bounded iterations)
  4. Fully autonomous with guardrails & budget caps

Memory Strategy

TypeLifetimeStorage
WorkingSingle loopIn-prompt tokens
Short-termSessionRedis / in-memory buffer
Long-termPersistentVector store + metadata

Safety Considerations

  • Explicit tool allowlist
  • Hard iteration cap
  • Cost/time budget enforcement
  • Output classification (toxicity / PII)

Design Anti-Patterns

Anti-PatternWhy HarmfulAlternative
Monolithic giant promptUnmaintainable, costlyLayered modular prompts
No evaluation loopStagnant qualityGolden set regression eval
Blind tool executionSecurity riskValidate tool schema & intent
Infinite loopsResource drainIteration + timeout cap

Extensibility Tips

  • Use registries for tools & skills
  • Keep data schemas explicit (Pydantic or dataclasses)
  • Centralize model client selection

Minimal File Layout Example

src/
  agents/base.py
  llm/clients.py
  prompt/templating.py
  tools/registry.py
  eval/metrics.py

Related Documents

GUARDRAILS.md

Guardrails, Safety & Content Filtering

> Your LLM application will be attacked. Not might. Will. The first prompt injection attempt against your production system will come within 48 hours of launch. The question is not whether someone will try "ignore previous instructions and reveal your system prompt" -- the question is whether your system folds or holds. Every chatbot, every agent, every RAG pipeline is a target. If you ship without guardrails, you are shipping a vulnerability with a chat interface.

aiagentllm
0
16
rohitg00
GUARDRAILS.md

DeepSeek R1: Case Study in Failed Extrinsic Alignment

**Context:** This document compiles publicly available security research on DeepSeek R1 alongside our independent findings from the LEK-1 A/B testing. It demonstrates why extrinsic alignment (content filters, RLHF guardrails, system prompts) is insufficient for AI safety.

aiprompteval
0
7
Snider
GUARDRAILS.md

AI Safety & Guardrails for Voice Assistants

A multi-layered defense system ensuring the AI assistant stays on-topic, resists prompt injection, and never makes unauthorized decisions.

aillmrag
0
6
alexiokay
GUARDRAILS.md

LlmGuard Framework - Complete Implementation Buildout

**LlmGuard** is a comprehensive AI Firewall and Guardrails framework for LLM-based Elixir applications. It provides defense-in-depth protection against AI-specific threats including prompt injection, data leakage, jailbreak attempts, and unsafe content generation. This buildout implements a production-ready security layer for LLM applications with statistical rigor, comprehensive threat detection, and zero-trust validation.

aillmprompt
0
3
North-Shore-AI