Agentic AI Cheat Sheet

🤖 Agentic AI Cheat Sheet

Complete guide to AI agents, frameworks, patterns, and implementation strategies

💡 What is Agentic AI?
🎯

Definition

Agentic AI refers to AI systems that can act autonomously, make decisions, and take actions to achieve specific goals without constant human intervention. These agents can plan, reason, and adapt their behavior based on their environment.

🧠

Key Characteristics

Autonomy: Can operate independently
Reasoning: Makes logical decisions
Goal-oriented: Works toward objectives
Adaptive: Learns from interactions
Tool usage: Leverages external resources

vs Traditional AI

Traditional AI: Responds to specific inputs with predefined outputs

Agentic AI: Plans sequences of actions, uses tools, and adapts strategies to accomplish complex, multi-step tasks autonomously.

🔧 Core Components
🎭

Agent Architecture

  • Perception: Process inputs from environment
  • Planning: Develop strategies to reach goals
  • Action: Execute decisions and use tools
  • Memory: Store and recall past experiences
  • Reflection: Learn from outcomes

🛠️

Tool Integration

Agents can use external tools and APIs:
• Web search and browsing
• Code execution environments
• Database queries
• File system operations
• API calls to external services
• Mathematical calculators

💭

Reasoning Patterns

Chain-of-Thought: Step-by-step reasoning
Tree-of-Thoughts: Multiple reasoning paths
ReAct: Reasoning + Acting interleaved
Plan-and-Execute: Strategic planning first
Self-Reflection: Critique own outputs

🚀 Popular Frameworks
🔗

LangChain

Most popular framework for building LLM applications with agents, chains, and tools integration.

from langchain.agents import initialize_agent, Tool
from langchain.llms import OpenAI

# Define tools
tools = [Tool(name=”Calculator”, func=calculator)]

# Create agent
agent = initialize_agent(tools, OpenAI(),
agent=”zero-shot-react-description”)

🦙

LlamaIndex

Specialized for RAG (Retrieval Augmented Generation) and data-aware agent applications.

from llama_index.agent import OpenAIAgent
from llama_index.tools import QueryEngineTool

# Create query tool
query_tool = QueryEngineTool.from_defaults(
query_engine, name=”documents”
)

agent = OpenAIAgent.from_tools([query_tool])

🎯

AutoGPT

Autonomous agent that can break down goals into sub-tasks and execute them independently.

# AutoGPT workflow
1. Set high-level goal
2. Agent breaks into sub-tasks
3. Executes tasks using tools
4. Self-evaluates progress
5. Adjusts strategy as needed

📋 Common Agent Patterns
🔄

ReAct Pattern

Reason → Act → Observe loop

Thought: I need to find the weather in Paris
Action: search_web(“weather Paris today”)
Observation: Current weather is 22°C, sunny
Thought: Now I have the information requested
Action: respond(“Weather in Paris: 22°C, sunny”)

📊

Multi-Agent System

Multiple specialized agents working together:
Planner Agent: Creates strategies
Executor Agent: Performs actions
Critic Agent: Evaluates results
Coordinator: Manages communication

🎪

Chain-of-Thought

Breaking complex problems into logical steps:

Problem: Calculate 15% tip on $47.50

Step 1: Convert percentage to decimal (15% = 0.15)
Step 2: Multiply: $47.50 × 0.15 = $7.125
Step 3: Round to nearest cent: $7.13
Answer: The tip should be $7.13

🛠️ Implementation Tools & APIs
🌟 OpenAI API

GPT-4, function calling, assistants API for agent development

🤗 Hugging Face

Open-source models, transformers library, agent toolkits

🔮 Anthropic Claude

Constitutional AI, tool use, long context windows

⚡ Cohere

Command models, retrieval-augmented generation

🧪 LangSmith

LLM application debugging, monitoring, and evaluation

📊 Weights & Biases

ML experiment tracking, agent performance monitoring

💼 Popular Use Cases
🎯

Business Automation

• Customer service chatbots
• Document processing and analysis
• Email management and responses
• Data entry and validation
• Report generation and insights

👨‍💻

Developer Assistance

• Code generation and debugging
• API documentation creation
• Test case generation
• Code review and optimization
• Architecture recommendations

🔬

Research & Analysis

• Literature reviews and summaries
• Data analysis and visualization
• Market research automation
• Scientific hypothesis generation
• Competitive intelligence gathering

✅ Best Practices
🎯

Agent Design

• Define clear goals and constraints
• Implement proper error handling
• Add human oversight for critical decisions
• Design for observability and debugging
• Start simple, iterate and improve

🔒

Safety & Security

• Validate all tool inputs and outputs
• Implement rate limiting and timeouts
• Use sandboxed execution environments
• Monitor for malicious behavior
• Regular security audits and testing

📊

Performance

• Cache frequently used results
• Optimize tool selection strategies
• Monitor token usage and costs
• Implement proper retry mechanisms
• Profile and optimize critical paths

⚡ Quick Start Example
🚀

Simple LangChain Agent

from langchain.agents import create_openai_tools_agent, AgentExecutor
from langchain.tools import DuckDuckGoSearchRun, Tool
from langchain_openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate

# Initialize LLM
llm = ChatOpenAI(model=”gpt-4″, temperature=0)

# Create tools
search = DuckDuckGoSearchRun()
tools = [
Tool(
name=”web_search”,
description=”Search the web for current information”,
func=search.run
)
]

# Create prompt template
prompt = ChatPromptTemplate.from_messages([
(“system”, “You are a helpful AI assistant with web search capabilities.”),
(“human”, “{input}”),
(“placeholder”, “{agent_scratchpad}”)
])

# Create and run agent
agent = create_openai_tools_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools)

# Use the agent
result = agent_executor.invoke({
“input”: “What’s the latest news about AI agents?”
})
print(result[“output”])