<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Vonta Johnson</title>
    <description>The latest articles on Forem by Vonta Johnson (@vontajohnson).</description>
    <link>https://forem.com/vontajohnson</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3403445%2F9ad0d759-9b2a-40e0-a59d-9bfc8f125888.jpeg</url>
      <title>Forem: Vonta Johnson</title>
      <link>https://forem.com/vontajohnson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vontajohnson"/>
    <language>en</language>
    <item>
      <title>Context Engineering: Building Better AI Agents</title>
      <dc:creator>Vonta Johnson</dc:creator>
      <pubDate>Sun, 03 Aug 2025 22:26:29 +0000</pubDate>
      <link>https://forem.com/vontajohnson/context-engineering-building-better-ai-agents-4a5k</link>
      <guid>https://forem.com/vontajohnson/context-engineering-building-better-ai-agents-4a5k</guid>
      <description>&lt;p&gt;If you've been building with LLMs for a while, you've probably experienced that moment when the model feels like it's more of a hindrance than a help. Worsening quality of answers, constant reminders to start a new chat window, and constraints that continually get forgotten. These are all symptoms of what happens when the models context starts to get too polluted. When building ai agents these problems can be the difference between having a reliable production ready agent and having a system that works great in your local tests but breaks in production.&lt;/p&gt;

&lt;p&gt;To bridge this gap and have a consistently reliable agentic system, you need to know how to effectively manage context. This is where context engineering comes into play and is essential for reliable agent building at scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Context in LLMs
&lt;/h2&gt;

&lt;p&gt;Before we dive into context engineering, let's clarify what we mean by "context" in the world of large language models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt; is everything the LLM can see and process when handling a task. This is essentially all the data The model has access to and can reference in order to fulfill the request. This includes things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your prompts and system instructions&lt;/li&gt;
&lt;li&gt;Previous messages in the conversation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/what-is/retrieval-augmented-generation/" rel="noopener noreferrer"&gt;RAG&lt;/a&gt; documents and retrieved information&lt;/li&gt;
&lt;li&gt;Tool call results and responses&lt;/li&gt;
&lt;li&gt;Multimodal inputs like images, audio, or documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every LLM has a &lt;strong&gt;context window&lt;/strong&gt;. A &lt;strong&gt;context window&lt;/strong&gt; is a hard limit on how much information (measured in tokens) the model can access and reference within a single session. When you exceed this limit, the model either truncates information or refuses to process the request entirely. The limit can range from hundreds of thousands of tokens to millions. The type of input provided to the llm (text vs image etc.) also has a significant impact on token usage.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Context Engineering?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Context engineering&lt;/strong&gt; &lt;a href="https://x.com/karpathy/status/1937902205765607626" rel="noopener noreferrer"&gt;as described by Andrej Karpathy&lt;/a&gt;, former director of AI @ Tesla is: &lt;em&gt;the delicate art and science of filling the context window with just the right information for the next step&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This goes beyond the prompt provided and manages the entire system your agent or llm can access. Think of it as fine tuning the brain of the agent. When a person needs to solve a problem, there are various inputs and reference points we use to discern the right solution. Managing this for an agent is the essential nature of context engineering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context Engineering vs. Prompt Engineering
&lt;/h2&gt;

&lt;p&gt;You may already be familiar with the term &lt;a href="https://www.mckinsey.com/featured-insights/mckinsey-explainers/what-is-prompt-engineering" rel="noopener noreferrer"&gt;prompt engineering&lt;/a&gt;, but that is just one piece of building reliable AI systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt Engineering&lt;/strong&gt; focuses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Writing clear, specific instructions&lt;/li&gt;
&lt;li&gt;Using effective prompt templates and formats&lt;/li&gt;
&lt;li&gt;Crafting examples and demonstrations&lt;/li&gt;
&lt;li&gt;Optimizing the immediate request to the model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Context Engineering&lt;/strong&gt; focuses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Managing the entire information environment over time&lt;/li&gt;
&lt;li&gt;Deciding what information to include or exclude across multiple interactions&lt;/li&gt;
&lt;li&gt;Handling long-running conversations and sessions&lt;/li&gt;
&lt;li&gt;Optimizing for reliability and consistency at scale&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it this way: prompt engineering is like perfecting one song on an album. Context engineering is managing the entire tracklist and production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters Building Agents
&lt;/h2&gt;

&lt;p&gt;When trying to build scalable agents, there are a number of factors to consider. Typically an agent must do all of these things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintain long conversations&lt;/li&gt;
&lt;li&gt;Access multiple data sources&lt;/li&gt;
&lt;li&gt;Use various tools&lt;/li&gt;
&lt;li&gt;Remember past decisions&lt;/li&gt;
&lt;li&gt;Handle complex, multi-step tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without effective context engineering you can quickly hit the wall on expected performance and have inefficient token usage which directly translates to increased costs. Writing better prompts will not solve this issue.&lt;/p&gt;

&lt;p&gt;Poor context management can lead to these 4 common context failures:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Context Poisoning&lt;/strong&gt; - Incorrect or hallucinated responses interfering with the context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Clashes&lt;/strong&gt; - Conflicting information causing inconsistent outputs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Confusion&lt;/strong&gt; - Irrelevant data in the context influencing the output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Distraction&lt;/strong&gt; - The context overwhelming the models training.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can read more about each of these failures &lt;a href="https://www.dbreunig.com/2025/06/22/how-contexts-fail-and-how-to-fix-them.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Four Pillars of Context Engineering
&lt;/h2&gt;

&lt;p&gt;To avoid common context failures, these four key principles will help you to build more robust and production ready systems.  While none of these techniques are foolproof, they each give us greater control over our context than without.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Write Context&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Storing information outside of the context window for later retrieval and usage.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is about creating persistent memory systems that can maintain important information across sessions and interactions. This can be done in a file that the llm can read from or directly in the state that is managed by the agent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key strategies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use file-based memory systems (like Claude.md files or rules files in cursor)&lt;/li&gt;
&lt;li&gt;Implement embedded document stores for large collections of facts&lt;/li&gt;
&lt;li&gt;Build autonomous memory creation based on user feedback and interactions&lt;/li&gt;
&lt;li&gt;Store structured information that can't fit in context windows&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Select Context&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Selecting only the relevant information needed for the context to accomplish the task at hand.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Smart retrieval ensures you're including the right information while excluding the noise that degrades performance. Only selecting the necessary information gives more accurate context to solve the problem and reduces token usage which saves money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key strategies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement semantic similarity scoring for document retrieval&lt;/li&gt;
&lt;li&gt;Use relevance thresholds to filter out low-quality matches&lt;/li&gt;
&lt;li&gt;Create retrieval mechanisms that consider recency, importance, and similarity&lt;/li&gt;
&lt;li&gt;Build fallback strategies when no highly relevant information is found&lt;/li&gt;
&lt;li&gt;Design retrieval that adapts to the specific task requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Compress Histories&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Distilling down to only the required tokens to complete a task.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As conversations and agent trajectories get longer, intelligent compression can help with maintaining performance. This involves summarizing information &lt;em&gt;and/or&lt;/em&gt; removing information where necessary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key strategies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement context summarization at natural boundaries (completed phases, tool calls)&lt;/li&gt;
&lt;li&gt;Summarize token-heavy tool call feedback while preserving key insights&lt;/li&gt;
&lt;li&gt;Create checkpoints for important conversation milestones&lt;/li&gt;
&lt;li&gt;Apply auto-compaction when approaching context limits&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Isolate Contexts&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Splitting up the context between multiple windows or agents to break down the task.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Sometimes the best context management is context separation, allowing different components to focus on specific aspects.&lt;/p&gt;

&lt;p&gt;This principle is demonstrated in &lt;a href="https://www.anthropic.com/engineering/built-multi-agent-research-system" rel="noopener noreferrer"&gt;Anthropic's multi-agent research system&lt;/a&gt;. Instead of cramming everything into one massive context, they use specialized subagents that each operate with their own focused context windows. This allows them to scale beyond what any single agent could handle while maintaining clarity and focus.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key strategies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use multiple specialized agents instead of one overpowered agent&lt;/li&gt;
&lt;li&gt;Create sandbox environments that isolate objects from the main context&lt;/li&gt;
&lt;li&gt;Design multi-agent systems for easily parallelizable tasks&lt;/li&gt;
&lt;li&gt;Separate concerns across different context windows with clear boundaries&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;p&gt;To wrap up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Context engineering is distinct from prompt engineering and focuses on managing the entire information environment.&lt;/li&gt;
&lt;li&gt;The four main problems (poisoning, clashing, confusion, distraction) can break even well-designed systems.&lt;/li&gt;
&lt;li&gt;The four pillars (write, select, compress, isolate) provide a framework for systematic improvement.&lt;/li&gt;
&lt;li&gt;Better context management directly translates to lower costs, higher reliability, and better user experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Context engineering is still an evolving field, and best practices are still being discovered through real-world experimentation. The more we share what works (and what doesn't), the faster we'll all build better AI systems.&lt;/p&gt;

&lt;p&gt;What context engineering techniques have you tried? What worked, and what didn't? Let me know your experience with this new concept!&lt;/p&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>Write Code Like Sherlock Holmes: The Art of Deductive Development 🔍</title>
      <dc:creator>Vonta Johnson</dc:creator>
      <pubDate>Thu, 31 Jul 2025 14:48:50 +0000</pubDate>
      <link>https://forem.com/vontajohnson/write-code-like-sherlock-holmes-the-art-of-deductive-development-3ghp</link>
      <guid>https://forem.com/vontajohnson/write-code-like-sherlock-holmes-the-art-of-deductive-development-3ghp</guid>
      <description>&lt;p&gt;I've always found Sherlock Holmes to be an interesting character in stories. Ever since that first story I've been fascinated by the detective and can't get enough of reading his stories as told by Dr. Watson. So much so, that I've come up with a few principles to take from the great detective that I apply when it comes to software engineering.&lt;/p&gt;

&lt;p&gt;Both Holmes and great developers solve complex problems by gathering comprehensive information, forming theories based on evidence rather than assumptions, tracing issues to their source, and collaborating to validate their reasoning.&lt;/p&gt;

&lt;p&gt;Whether you're planning a new feature, debugging a production issue, or architecting a system, here are a few ways to apply the skills of the detective to your next goal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gather All the Facts First
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"Before I can judge what is or is not relevant, I must know all the facts."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first thing Holmes does when it comes to solving a case (often before he decides if he will take a case) is to ask questions. Lots of them. Questions that often would lead to the potential client asking "Why are you asking me this?". This very thorough initial inquisition would lay the groundwork for everything about the case that was to follow. In development, this means exhaustive questioning during planning, before you write any code.&lt;/p&gt;

&lt;p&gt;I'm often cited for asking great questions both before and during a new implementation. Questions like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About Users:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Who exactly will use this?&lt;/li&gt;
&lt;li&gt;What device will this primarily be used on?&lt;/li&gt;
&lt;li&gt;What is the foundational problem that we want to solve?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;About Constraints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What type of performance is expected?&lt;/li&gt;
&lt;li&gt;Are there any compliance requirements? (HIPAA, GDPR, SOX)&lt;/li&gt;
&lt;li&gt;What data do we need to implement this and who owns it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;About Our Product:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this something new or something we are expanding on?&lt;/li&gt;
&lt;li&gt;Will we need to integrate any new technology to implement this?&lt;/li&gt;
&lt;li&gt;What failure mechanisms should we have in place if &lt;em&gt;x&lt;/em&gt; assumed service stops working?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These types of questions can reveal crucial constraints and expectations. Ask as many as you can think of. Not just to figure out what you &lt;em&gt;do&lt;/em&gt; need, but sometimes more importantly what you &lt;em&gt;do not&lt;/em&gt;. Just as Holmes investigating a victim's family history might reveal a crucial detail that helps solve the current case, thorough questioning helps to get to the right answers that can get rid of problems before they occur during development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let Facts Shape Your Theory, Not the Other Way Around
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"It is a capital mistake to theorize before one has data. Insensibly one begins to twist facts to suit theories, instead of theories to suit facts."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Holmes never formed theories before gathering evidence. He invariably gathered facts as a case went on and never preemptively formed a thesis beforehand. In development, this means avoiding over-engineering and abstractions before they are necessary.&lt;/p&gt;

&lt;p&gt;Sometimes we as developers have a bad habit of over-engineering a service in the name of "scale". Let's say you have a need to implement a queue into your application. You first impulse should not be to look towards a third party library, or an entirely new service to bring into your app. For me it would be to implement your own simple queue. The answer will depend on the number of users and how large you expect this queue to get, but that should be determined in the planning phase. If a simple queue will be enough to satisfy your current use-case, start there. Iterate on your solution and let the more complex solutions only be brought in as necessary. Every new service you bring into the app is a new tool the team must learn and a new tool that you are the mercy of if they decide to update or change any of their feature-set.&lt;/p&gt;

&lt;p&gt;I also apply this to creating abstractions. I favor localization and keep functionality close to where it's needed. If error handling logic is only used in one component, it doesn't need to be abstracted into five different files. If a utility function serves only the user profile page, keep it in that module until you need it elsewhere.&lt;/p&gt;

&lt;p&gt;This approach prevents the classic developer trap of building elaborate solutions to problems you don't actually have. Start simple, add complexity only when the facts demand it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start at the Source
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"When you have eliminated the impossible, whatever remains, however improbable, must be the truth."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Holmes liked to find out what the motivation for a criminal would be. Asking questions and investigating to get to the initial driving factor that would lead to whatever crime there's been. Similarly, when debugging, I like to start at the data source, not where the error appears.&lt;/p&gt;

&lt;p&gt;Here's a real scenario: users report that their dashboard shows yesterday's sales figures instead of today's. The UI may indeed be  displaying the wrong data, but debugging the UI first is like arresting the first person at a crime scene.&lt;/p&gt;

&lt;p&gt;Instead, I like to trace starting from the source. Especially if it's a part of the application you're not as familiar with. It can look something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Database&lt;/strong&gt;: Run the query manually. Does it return today's data?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API&lt;/strong&gt;: Hit the endpoint directly. Is the backend serving correct data?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Communication&lt;/strong&gt;: Check dev tools network tab. Is the request being made correctly?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching&lt;/strong&gt;: Are we serving any stale data from the cache?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Management&lt;/strong&gt;: Is the component receiving correct data but not rendering correctly?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example, you might discover that the data in the db is correct, but the api has an issue with a timezone conversion and is sending the data from the wrong date. Starting at the UI often times assumes that the other pieces of the application are completely working correctly. Unfortunately, in my experience that is not an assumption you can make when determining the root cause of an issue.&lt;/p&gt;

&lt;p&gt;Holmes investigated a victim's entire history to understand the motivation for a crime. So should we investigate the complete data flow of our systems to understand the source of errors. Eliminate the impossible explanations systematically until you're left with the truth, however unexpected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Have Your Watson
&lt;/h2&gt;

&lt;p&gt;Holmes relied on Watson not as a sidekick, but as a crucial partner in his investigative process. Explaining his reasoning to Watson forced him to articulate his logic and could reveal flaws in his reasoning or spark new insights based on Watson's feedback.&lt;/p&gt;

&lt;p&gt;Every developer needs a Watson when the moment calls. My rule: if I'm stuck for 30 minutes with no clear path forward, I find someone to talk through the problem.&lt;/p&gt;

&lt;p&gt;Other times you may need a Watson:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pair programming&lt;/strong&gt;: Working through the problem together in real-time to find a solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code review&lt;/strong&gt;: Getting someone else feedback on your solution can either validate your approach or reveal a gap you need to close.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Getting Unstuck&lt;/strong&gt;: Explaining your train of thought once you've hit a roadblock to someone else can reveal a crucial point you've overlooked that can get you to the outcome you need.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your Watson doesn't need to be more senior than you. Sometimes a junior developer asking "Why did you choose this approach?" makes you realize you're overcomplicating things. Sometimes a colleague from another team can spot an integration issue you missed because you were too close to the problem.&lt;/p&gt;

&lt;p&gt;The key is being able to articulate your reasoning and being open to feedback. Do not tie yourself to any code. Be focused on the outcome and not your solution. This forces you to examine your assumptions and can give you more confidence in the solution you've chosen. Your teammates can help you the same as Watson helps Holmes see cases from new angles.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Deductive Developer
&lt;/h2&gt;

&lt;p&gt;These are four principles I like to follow when it comes to Deductive Development: gather information before coding, build only what the requirements demand, trace problems to their true source, and collaborate to validate.&lt;/p&gt;

&lt;p&gt;The next time you face a complex development challenge, channel Holmes' methodology. Ask exhaustive questions during planning. Let the facts shape your solution rather than forcing facts to fit your preconceptions. When debugging, start at the data source and work your way up. And when you're stuck, find your Watson to help you see what you might have missed.&lt;/p&gt;

&lt;p&gt;The best developers, like the world's greatest fictional detective, understand that methodology trumps genius.&lt;br&gt;
When you approach your next development challenge, remember that every feature request is a case to be solved, every bug is evidence waiting to be interpreted, and every system is a mystery with logical rules governing its behavior.&lt;/p&gt;

&lt;p&gt;After all, there's no mystery so complex that it can't be unraveled by the right questions, the right evidence, and the right methodology.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
