Agent is like a personal assistant, you give them goals and they figure out the steps that are needed to achieve that goal. They can use multiple tools, functions etc to achieve the goal, they can adapt based on results.
On the other hand RAGs are like librarian, you ask a question and they find the relevant books for you based on the search they perform in their accessible library.
CORE COMPONENTS of AN AGENT :
Agent = Environment + Tools + Planner + Executor + Memory
- Environment : This is the world in which agents operate (databases, web, file systems etc.)
- Tools : These are the functions agent can call to achieve goals (search, calculate, API calls)
- Planner : Decides what to do next
- Memory : Remembers what happened
Environment : The environment defines what's possible for the agent to perceive and what actions it can take.
Example of environment can be a code repository where agent can perceive of
- File structure
- Code contents
- Git history
- Test results
- Linter outputs
What agent can do within the environment ? :
- Read files
- Write files
- Run tests
- Create pull requests
- Search code
Why environment matters ? - If your agent environment is "chess game" then it can execute chess moves, if you try to send emails then it fails.
Tools : Tools are functions the agent can invoke to accomplish tasks.
INItools = [
{
"name": "search_knowledge_base",
"description": "Search internal documentation and FAQs",
"parameters": {
"query": "string - search query",
"category": "string - optional category filter"
}
},
{
"name": "get_order_status",
"description": "Get status of a customer order",
"parameters": {
"order_id": "string - order identifier"
}
},
{
"name": "process_refund",
"description": "Process a refund for an order",
"parameters": {
"order_id": "string",
"amount": "float",
"reason": "string"
}
},
{
"name": "escalate_to_human",
"description": "Escalate issue to human agent",
"parameters": {
"priority": "string - low/medium/high",
"summary": "string - issue summary"
}
}
]
Planning : Complex tasks require multiple steps in the right order, planning helps to achieve that.
MARKDOWNExample Task: "Analyze our Q3 sales and create a presentation for the board meeting"
This requires:
1. Query sales database for Q3 data
2. Analyze trends (YoY growth, top products, regional performance)
3. Create visualizations (charts, graphs)
4. Generate insights and recommendations
5. Create PowerPoint slides
6. Format presentation
Planning Approaches:
Approach 1: ReAct (Reasoning + Acting) - The pattern - Thought → Action → Observation → Thought → Action → ...
VBNETTask: "What's the average price of laptops sold last month that cost over $1000?"
Thought 1: I need to find laptops sold last month with price > $1000,
then calculate the average. First, I should query the sales database.
Action 1: sql_query(
query="SELECT price FROM sales
WHERE product_type='laptop'
AND sale_date >= '2024-01-01'
AND sale_date < '2024-02-01'
AND price > 1000"
)
Observation 1: Error - column 'sale_date' doesn't exist.
Available columns: product_id, product_type, price, transaction_date
Thought 2: I made an error - the column is called 'transaction_date',
not 'sale_date'. Let me correct the query.
Action 2: sql_query(
query="SELECT price FROM sales
WHERE product_type='laptop'
AND transaction_date >= '2024-01-01'
AND transaction_date < '2024-02-01'
AND price > 1000"
)
Observation 2: Results: [1299.99, 1499.99, 1899.99, 1349.99, 2199.99]
Thought 3: Good, I have 5 laptops that meet the criteria. Now I need
to calculate the average of these prices.
Action 3: calculate(
expression="(1299.99 + 1499.99 + 1899.99 + 1349.99 + 2199.99) / 5"
)
Observation 3: Result: 1649.99
Thought 4: I have the answer. The average price is $1649.99.
Final Answer: The average price of laptops sold last month
that cost over $1000 was $1,649.99. This is based on 5 qualifying
sales.
Why ReAct Works:
- Agent can recover from errors (Thought 2 corrected Thought 1's mistake)
- Agent shows reasoning (transparent decision-making)
- Agent adapts based on observations
Approach 2: Plan-then-Execute
- Generate complete plan upfront
- Validate plan
- Execute plan step-by-step
- If plan fails, regenerate
INIReal Example:
Task: "Book a conference room for our team meeting next Tuesday at 2 PM, invite all engineering team members, and order lunch"
Planning Phase:
Generated Plan:
──────────────
1. get_available_rooms(date="2024-02-13", time="14:00", duration=60)
2. get_team_members(team="engineering")
3. book_room(room_id=<from step 1>, date="2024-02-13", time="14:00")
4. send_calendar_invites(attendees=<from step 2>, room=<from step 3>)
5. order_catering(date="2024-02-13", time="14:00", headcount=<from step 2>)
Validation Phase:
Validator checks:
✓ All required parameters can be obtained from previous steps
✓ Tools exist and are accessible
✓ Dependencies are in correct order (can't book before finding rooms)
✗ Error: order_catering requires budget approval
Plan status: Invalid
Regenerate plan:
───────────────
1. get_available_rooms(date="2024-02-13", time="14:00", duration=60)
2. get_team_members(team="engineering")
3. check_budget(amount=<estimated cost>, category="catering")
4. IF budget approved:
book_room(room_id=<from step 1>, date="2024-02-13", time="14:00")
send_calendar_invites(attendees=<from step 2>, room=<from step 4>)
order_catering(date="2024-02-13", time="14:00", headcount=<from step 2>)
ELSE:
book_room(room_id=<from step 1>, date="2024-02-13", time="14:00")
send_calendar_invites(attendees=<from step 2>, room=<from step 4>,
note="Please bring your own lunch")
Execution Phase:
Executing step 1: get_available_rooms(...)
Result: [Room A, Room B, Room C]
Executing step 2: get_team_members(...)
Result: 12 members
Executing step 3: check_budget(amount=180, category="catering")
Result: Approved
Executing step 4a: book_room(room_id="Room A", ...)
Result: Success, booking ID: BK-789
Executing step 4b: send_calendar_invites(...)
Result: 12 invites sent
Executing step 4c: order_catering(headcount=12)
Result: Order confirmed, delivery at 1:45 PM
Task completed successfully!
| Aspect | ReAct | Plan-then-Execute |
|---|---|---|
| Planning style | Incremental | Upfront |
| Adaptability | High (replans every step) | Medium (replans on failure) |
| Efficiency | Lower (more LLM calls) | Higher (fewer LLM calls) |
| Transparency | Very high (shows reasoning) | Medium (shows plan only) |
| Best for | Exploratory tasks, uncertain environments | Well-defined tasks, known environments |
| Example use case | Research, debugging | Workflow automation, booking systems |
Memory :
VBNETThe Three Types:
1. Internal Knowledge (Training Data)
What it is: Knowledge baked into the model during training
Example: "Python is a programming language"
Persistence: Permanent (unless model retrained)
Updates: Only through retraining
Limitations: Knowledge cutoff date, can't include private data
2. Short-Term Memory (Context Window)
What it is: Information in the current conversation
Example:
User: "My order number is 12345"
Agent remembers "12345" for this conversation
Persistence: Only during current session
Capacity: Limited by context window (e.g., 128K tokens)
Updates: Automatic (each message added)
3. Long-Term Memory (External Storage)
What it is: Information persisted across conversations
Example: User preferences, conversation history, learned patterns
Persistence: Permanent (stored in database)
Capacity: Unlimited (external storage)
Updates: Explicit write operations
That's how I wrap my head around agent and the components forming the agent architecture, these examples help me correlate this in real world and how agentic applications can be approached, to solve user problems
