<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg" -->

---
title: Building AI Agents from scratch - Part 2: Reflection and...
description: Learn about the Reflection pattern in AI agent systems, its relation to short-term memory, and how to implement an Agent class that utilizes Reflection to...
canonical: https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building AI Agents from scratch - Part 2: Reflection and Working Memory | daily.dev
og:description: Learn about the Reflection pattern in AI agent systems, its relation to short-term memory, and how to implement an Agent class that utilizes Reflection to...
og:url: https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg
og:image: https://api.daily.dev/og/posts/Cssxdh5KG.png
og:image:alt: Building AI Agents from scratch - Part 2: Reflection and Working Memory
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building AI Agents from scratch - Part 2: Reflection and Working Memory

**[SwirlAI](https://daily.dev/sources/swirlai)** · 16 min read · 12 upvotes · 0 comments

## Summary

Learn about the Reflection pattern in AI agent systems, its relation to short-term memory, and how to implement an Agent class that utilizes Reflection to improve performance. This guide offers code examples, explains pros and cons, and showcases the connection between agent memory and Reflection capabilities. The practical example includes revising an action plan generated by an AI agent to fix hallucinations and improve response accuracy.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.newsletter.swirlai.com/p/building-ai-agents-from-scratch-part-8ca>

---

Tags: [#ai](https://daily.dev/tags/ai), [#machine-learning](https://daily.dev/tags/machine-learning), [#genai](https://daily.dev/tags/genai), [#data-engineering](https://daily.dev/tags/data-engineering), [#mlops](https://daily.dev/tags/mlops)

[View this post on daily.dev](https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building AI Agents from scratch - Part 2: Reflection and Working Memory","url":"https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg"},"datePublished":"2025-01-04T08:27:02.193Z","dateModified":"2025-01-04T08:27:17.537Z","description":"Learn about the Reflection pattern in AI agent systems, its relation to short-term memory, and how to implement an Agent class that utilizes Reflection to...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c4f5c2cd69f7b80631952b284f8467ce?_a=AQAEuj9","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c4f5c2cd69f7b80631952b284f8467ce?_a=AQAEuj9","isAccessibleForFree":true,"articleSection":"SwirlAI","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SwirlAI","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/25542e29104c4f78b56442780718f69a","url":"https://daily.dev/sources/swirlai"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/building-ai-agents-from-scratch---part-2-reflection-and-working-memory-cssxdh5kg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":12},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai,machine-learning,genai,data-engineering,mlops","timeRequired":"PT16M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SwirlAI","item":"https://daily.dev/sources/swirlai"},{"@type":"ListItem","position":3,"name":"Building AI Agents from scratch - Part 2: Reflection and Working Memory"}]}
```

