Prompt, Context and Memory

Published on

I started using AI in my work as a software developer a little over 2 years ago. With ChatGPT and in a crude way, like most people, I imagine 😅

Throughout this time I refined my conversation with LLMs, started using code assistants (GitHub Copilot) and then assistants with agents (Cursor) and even developed agent systems with frameworks like CrewAI. But it wasn't until now that I clearly understood that any interaction with language models, no matter what tool we use, boils down to three fundamental points: prompt, context, and memory.

Prompt

Through the prompt, we create the expert we need for a specific task, we tell them what to do and also what not to do. It's the means we have to achieve the desired result.

To write the appropriate prompt for each task, we have prompt engineering. Knowing its main techniques is important, but what really makes us improve is continuous practice with LLMs, our conversation with AI.

Context

Large language models have vast knowledge, but for certain tasks this is not enough. Providing additional context becomes an unavoidable necessity.

To provide context, we have different approaches, from simply including relevant information in the prompt, to adding reference documents, to using MCPs that allow LLMs to access content from multiple platforms (Jira, Drive, etc.) and tools (Figma, Draw.io, etc.).

Memory

LLMs have the ability to remember our conversations, but this memory has a limit (context window limit). The more complex the task to be developed, the more likely we are to exceed this limit and the more necessary it becomes to extend the LLM's memory.

There are different techniques to expand LLMs' memory, some quite sophisticated like using classical and vector databases, but the simplest way to do it is by introducing extended context/memory strategies into our routines.

Frank and the robot talking

In perspective

Prompt, context, and memory. That is, the correct instructions to achieve the desired objective, the necessary information to understand the project and its objective, and the record of completed work (when, how, where, and why).

If you think about it for a moment, it's not very different from what humans need to develop any complex task. Really, every time we delve deeper into the use of AI, we encounter situations where we see a clear parallel between how LLMs work and how we do. Not in vain are we entering an era where we no longer "talk" to machines through code, but rather talk to machines naturally. Something that Frank already discovered more than 10 years ago 😎🤖.