<?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>DEV Community: Muhammad Mairaj</title>
    <description>The latest articles on DEV Community by Muhammad Mairaj (@thisismairaj).</description>
    <link>https://dev.to/thisismairaj</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%2F3512436%2Fa4f6bf28-568e-4cc1-b587-ece30565b1f4.jpg</url>
      <title>DEV Community: Muhammad Mairaj</title>
      <link>https://dev.to/thisismairaj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thisismairaj"/>
    <language>en</language>
    <item>
      <title>How to build a Claude Sonnet 4.5 agent in 10 minutes</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Tue, 30 Sep 2025 21:31:08 +0000</pubDate>
      <link>https://dev.to/thisismairaj/how-to-build-a-claude-sonnet-45-agent-in-10-minutes-1390</link>
      <guid>https://dev.to/thisismairaj/how-to-build-a-claude-sonnet-45-agent-in-10-minutes-1390</guid>
      <description>&lt;p&gt;We are going to build an AI agent that uses Claude Sonnet 4.5. We will use the agent primitive by Langbase.&lt;/p&gt;

&lt;p&gt;An agent works as a runtime LLM agent. You can specify all parameters at runtime and get the response from the agent. The agent uses Langbase’s unified LLM API to provide a consistent interface for interacting with 600+ LLMs across all the top providers.&lt;/p&gt;

&lt;p&gt;See the full &lt;a href="https://langbase.com/models" rel="noopener noreferrer"&gt;list of supported models&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Okay, let’s get to building.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Step 1: Install Langbase SDK
&lt;/h2&gt;

&lt;p&gt;Langbase SDK comes in both &lt;strong&gt;TypeScript&lt;/strong&gt; and &lt;strong&gt;Python&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;langbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;langbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Get your Langbase API Key
&lt;/h2&gt;

&lt;p&gt;Every request you send to Langbase needs an API key. To generate one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign up at &lt;a href="https://langbase.com/" rel="noopener noreferrer"&gt;Langbase.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;From the sidebar, click API Keys&lt;/li&gt;
&lt;li&gt;Create a new API key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more details, follow the &lt;a href="https://langbase.com/docs/api-reference/api-keys" rel="noopener noreferrer"&gt;API key guide&lt;/a&gt;.&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;In your .env file, add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LANGBASE_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_langbase_api_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we’re using Claude Sonnet 4.5 (Anthropic), you’ll also need your Anthropic API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LLM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_anthropic_api_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Write the Code
&lt;/h2&gt;

&lt;p&gt;TypeScript version (index.ts):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;langbase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anthropic:claude-sonnet-4-5&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;instructions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You are a helpful AI Agent.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Explain what an AI Engineer does.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LLM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tsx index.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python version (index.py):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langbase&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Langbase&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;langbase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Langbase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LANGBASE_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;langbase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;anthropic:claude-sonnet-4-5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;instructions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You are a helpful AI Agent.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Explain what an AI Engineer does.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LLM_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;response:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;output&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python index.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: That’s it 🚀
&lt;/h2&gt;

&lt;p&gt;That’s basically 5–6 lines of code.&lt;/p&gt;

&lt;p&gt;With Langbase’s agent primitive, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamically modify the prompt, model, or instructions&lt;/li&gt;
&lt;li&gt;Enable streaming responses&lt;/li&gt;
&lt;li&gt;Switch between 600+ AI models with the same API&lt;/li&gt;
&lt;li&gt;Use both open-source (DeepSeek, Kimi K2, Grok 4) and frontier models (Claude Sonnet 4.5, GPT-5, Gemini 2.0, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What are you waiting for? Build your Claude Sonnet 4.5 agent!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The complete guide to evals</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Tue, 30 Sep 2025 21:24:07 +0000</pubDate>
      <link>https://dev.to/thisismairaj/the-complete-guide-to-evals-3nd3</link>
      <guid>https://dev.to/thisismairaj/the-complete-guide-to-evals-3nd3</guid>
      <description>&lt;h2&gt;
  
  
  What are evals?
&lt;/h2&gt;

&lt;p&gt;Evals, short for evaluations, are systematic processes designed to measure and benchmark the performance of AI models, prompts, and workflows. In the context of AI and machine learning, evals refer to structured methods of testing whether a system produces outputs that meet predefined quality, accuracy, or safety standards.&lt;br&gt;
Key terms to understand here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model evaluation: Testing how well a model performs on tasks like summarization, classification, or reasoning.&lt;/li&gt;
&lt;li&gt;Prompt evaluation: Measuring the consistency, accuracy, and reliability of a prompt across variations.&lt;/li&gt;
&lt;li&gt;Benchmarking: Comparing one system against others using shared datasets or criteria.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put simply, evals are the feedback loops that ensure AI systems are reliable, safe, and useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why evals matter in 2025
&lt;/h2&gt;

&lt;p&gt;With the rise of AI-powered applications across industries, evals have become critical to trust and adoption.&lt;br&gt;
According to Stanford's 2024 AI Index, 52% of companies report challenges in measuring the reliability of generative AI outputs, and nearly 68% of executives say they are investing in evaluation frameworks to reduce hallucinations and compliance risks.&lt;br&gt;
As Andrew Ng put it: "AI systems are only as good as the evaluations we run on them. Without proper testing, you're essentially flying blind."&lt;br&gt;
Key reasons evals matter today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reliability: Users need consistent answers from AI systems.
Safety: Evals catch harmful or biased outputs before deployment.
Regulation: Governments are introducing audit requirements (e.g., EU AI Act).&lt;/li&gt;
&lt;li&gt;Trust: Businesses and end-users rely on transparent evaluation scores.
Iteration: Continuous evals help refine prompts, models, and workflows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, evals are no longer optional - they are a competitive and compliance necessity.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to implement evals in your AI workflows
&lt;/h2&gt;

&lt;p&gt;Implementing evals requires a structured approach that balances automation with human review. Here's a step-by-step framework:&lt;br&gt;
&lt;strong&gt;Step 1: Define evaluation goals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What do you want to measure - accuracy, safety, style, or factual correctness? Choose metrics aligned with your business use case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Select test datasets&lt;/strong&gt;&lt;br&gt;
Use real-world samples from your domain (customer queries, documents).&lt;br&gt;
Consider synthetic datasets for edge cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Choose evaluation methods&lt;/strong&gt;&lt;br&gt;
Automated metrics: BLEU, ROUGE, accuracy, latency.&lt;br&gt;
LLM-as-a-judge: Using another model to grade outputs.&lt;br&gt;
Human review: Domain experts validating results&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Run iterative evaluations&lt;/strong&gt;&lt;br&gt;
Automate periodic evals during development.&lt;br&gt;
Track performance trends over time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Integrate with deployment pipeline&lt;/strong&gt;&lt;br&gt;
Add evals as CI/CD checks before shipping changes.&lt;br&gt;
Automate alerts if scores drop below thresholds.&lt;/p&gt;

&lt;p&gt;Next step prompt: Once you've completed basic evals, ask: How do I expand my evaluation system to cover fairness, safety, and compliance?&lt;/p&gt;

&lt;h2&gt;
  
  
  Evals vs alternatives
&lt;/h2&gt;

&lt;p&gt;While evals are central, they are often compared against other quality-assurance approaches like A/B testing, user surveys, or synthetic monitoring.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature comparison table
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F220b186e74b4793st1z2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F220b186e74b4793st1z2.png" alt=" " width="740" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros and cons of evals
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Objective and repeatable&lt;/li&gt;
&lt;li&gt;Scalable across tasks and models&lt;/li&gt;
&lt;li&gt;Detects hidden weaknesses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requires dataset preparation&lt;/li&gt;
&lt;li&gt;May not capture "real-world" nuance without human input&lt;/li&gt;
&lt;li&gt;Setup can be resource-intensive initially&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use case scenarios&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enterprise AI apps: Ensure compliance with legal standards.&lt;/li&gt;
&lt;li&gt;Consumer chatbots: Test reliability before mass rollout.&lt;/li&gt;
&lt;li&gt;Healthcare AI: Verify factual correctness and reduce bias.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Frequently asked questions
&lt;/h3&gt;

&lt;p&gt;Q1: How are evals different from benchmarks?&lt;br&gt;
A: Benchmarks are shared, static test sets, while evals can be customized for your use case. Evals are ongoing, whereas benchmarks are more like snapshots.&lt;/p&gt;

&lt;p&gt;Q2: Do I always need humans in the loop for evals?&lt;br&gt;
A: Not always. Automated metrics and LLM-as-a-judge methods are effective for many tasks, but human validation is critical in regulated or high-stakes domains.&lt;/p&gt;

&lt;p&gt;Q3: Can evals prevent hallucinations?&lt;br&gt;
A: They don't eliminate hallucinations entirely, but they can detect and reduce them significantly when paired with guardrails.&lt;/p&gt;

&lt;p&gt;Q4: How often should I run evals?&lt;br&gt;
A: Best practice is to run them continuously - at least before every major deployment or prompt update.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>performance</category>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Agentic vs Graph RAG: Two paths to smarter AI systems</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Thu, 25 Sep 2025 19:26:05 +0000</pubDate>
      <link>https://dev.to/thisismairaj/agentic-vs-graph-rag-two-paths-to-smarter-ai-systems-44fb</link>
      <guid>https://dev.to/thisismairaj/agentic-vs-graph-rag-two-paths-to-smarter-ai-systems-44fb</guid>
      <description>&lt;p&gt;When I first started working with LLMs, retrieval felt like magic.&lt;/p&gt;

&lt;p&gt;You drop in a vector database, point it at your documents, and suddenly the model can “remember” everything it couldn’t fit in the context window.&lt;/p&gt;

&lt;p&gt;But the more I used it, the more I realized retrieval alone isn’t the endgame.&lt;/p&gt;

&lt;p&gt;It’s like giving a student a stack of textbooks. Yes, they can look things up. But what you really want is for them to understand, reason, and make connections on their own.&lt;/p&gt;

&lt;p&gt;That’s where two new approaches come in: agentic RAG and graph RAG.&lt;/p&gt;

&lt;p&gt;Both take retrieval and stretch it in new directions. Both are attempts to get closer to actual intelligence.&lt;/p&gt;

&lt;p&gt;And they couldn’t be more different.&lt;/p&gt;

&lt;h3&gt;
  
  
  What agentic RAG does
&lt;/h3&gt;

&lt;p&gt;Agentic RAG is about giving models the ability to act.&lt;/p&gt;

&lt;p&gt;Instead of just fetching documents, the model becomes an agent that decides what to look for, how to look for it, and when to stop.&lt;/p&gt;

&lt;p&gt;It’s like the difference between a librarian fetching you a single book and a research assistant who knows your goal, can read the books, summarize them, and then run off to find the next lead.&lt;/p&gt;

&lt;p&gt;This kind of system feels alive in a way plain RAG doesn’t. It’s iterative, goal-driven, and flexible.&lt;/p&gt;

&lt;p&gt;The downside is complexity. Once you make the model an agent, you also inherit the messiness of agents: loops, dead ends, hallucinations, and cost.&lt;/p&gt;

&lt;p&gt;But when it works, it feels like magic.&lt;/p&gt;

&lt;p&gt;Building agentic RAG becomes easier with Langbase SDK. &lt;a href="https://langbase.com/docs/examples/build-agentic-rag" rel="noopener noreferrer"&gt;Here's a guide&lt;/a&gt; if you are interested.&lt;/p&gt;

&lt;h3&gt;
  
  
  What graph RAG does
&lt;/h3&gt;

&lt;p&gt;Graph RAG goes in the opposite direction.&lt;/p&gt;

&lt;p&gt;Instead of making the model act like an agent, it structures the knowledge itself.&lt;/p&gt;

&lt;p&gt;Imagine taking all your data and turning it into a graph of entities, relationships, and connections. Instead of raw chunks of text, you have a map of how ideas fit together.&lt;/p&gt;

&lt;p&gt;When the model queries this graph, it’s no longer just pulling a paragraph. It’s pulling an entire web of meaning.&lt;/p&gt;

&lt;p&gt;This makes answers more grounded and less brittle. You don’t have to hope the right chunk happens to be retrieved. The graph gives you the relationships directly.&lt;/p&gt;

&lt;p&gt;Graph RAG feels less flashy than agentic RAG, but it’s sturdier. It’s the difference between a curious assistant and a well-organized library.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing between the two
&lt;/h3&gt;

&lt;p&gt;The funny thing is you don’t actually have to choose.&lt;/p&gt;

&lt;p&gt;Agentic RAG and graph RAG are two different bets on the same problem: how do we get models to reason over knowledge instead of just parroting it back?&lt;/p&gt;

&lt;p&gt;If you care about exploration and discovery, agentic RAG will take you further.&lt;/p&gt;

&lt;p&gt;If you care about accuracy and structure, graph RAG is safer.&lt;/p&gt;

&lt;p&gt;The smartest systems I’ve seen combine both. An agent that can reason and plan, but also a knowledge graph to keep it grounded.&lt;/p&gt;

&lt;p&gt;One gives you flexibility, the other gives you stability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this matters now
&lt;/h3&gt;

&lt;p&gt;I don’t think we’ve seen the final form of RAG yet.&lt;/p&gt;

&lt;p&gt;Right now, everyone is experimenting. Some are pushing towards agentic systems. Others are betting on graphs.&lt;/p&gt;

&lt;p&gt;The reason it matters is simple. Retrieval is the foundation of every serious AI system. If you can make retrieval smarter, you make everything smarter.&lt;/p&gt;

&lt;p&gt;That’s why I think agentic RAG and graph RAG are more than passing fads. They’re the first real attempts to move beyond raw text search and into reasoning.&lt;/p&gt;

&lt;p&gt;The next decade of AI might be decided by which of these paths works best—or how we combine them.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>llm</category>
      <category>ai</category>
      <category>rag</category>
    </item>
    <item>
      <title>Why most AI demos fail in production</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Thu, 25 Sep 2025 18:57:22 +0000</pubDate>
      <link>https://dev.to/thisismairaj/why-most-ai-demos-fail-in-production-60g</link>
      <guid>https://dev.to/thisismairaj/why-most-ai-demos-fail-in-production-60g</guid>
      <description>&lt;p&gt;AI demos are intoxicating.&lt;/p&gt;

&lt;p&gt;They make you feel like the future has arrived.&lt;/p&gt;

&lt;p&gt;A few clicks, a few prompts, and suddenly you are looking at something that feels like science fiction.&lt;/p&gt;

&lt;p&gt;But here’s the problem.&lt;/p&gt;

&lt;p&gt;The same demo that dazzles on stage almost always collapses when you try to turn it into a product.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because a demo is theater, and production is reality.&lt;/p&gt;

&lt;h2&gt;
  
  
  The best case bias
&lt;/h2&gt;

&lt;p&gt;A demo is built to impress, not to last.&lt;/p&gt;

&lt;p&gt;It only shows the happy path.&lt;/p&gt;

&lt;p&gt;The presenter knows what to type.&lt;/p&gt;

&lt;p&gt;They avoid the weird edge cases.&lt;/p&gt;

&lt;p&gt;The inputs are clean, the timing is perfect, and the audience only sees the system at its best.&lt;/p&gt;

&lt;p&gt;Production is the opposite.&lt;/p&gt;

&lt;p&gt;Real users are unpredictable.&lt;/p&gt;

&lt;p&gt;They type half-formed thoughts, use slang, and ask things the system was never designed to handle.&lt;/p&gt;

&lt;p&gt;If the demo is a polished photo, production is a stress test.&lt;/p&gt;

&lt;p&gt;Most demos are not built for that test.&lt;/p&gt;

&lt;h2&gt;
  
  
  The missing infrastructure
&lt;/h2&gt;

&lt;p&gt;Another reason demos fail is that they don’t show the scaffolding.&lt;/p&gt;

&lt;p&gt;What looks like a single model output is often supported by hidden tricks: a preloaded context, hand-picked data, or a carefully engineered prompt.&lt;/p&gt;

&lt;p&gt;In production, those tricks don’t scale.&lt;/p&gt;

&lt;p&gt;You need infrastructure.&lt;/p&gt;

&lt;p&gt;You need ways to manage memory, handle retrieval, track costs, and monitor reliability.&lt;/p&gt;

&lt;p&gt;Without that, you have a toy, not a product.&lt;/p&gt;

&lt;p&gt;And toys break when people start using them in ways you didn’t expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fragility of prompts
&lt;/h2&gt;

&lt;p&gt;Prompts are like duct tape.&lt;/p&gt;

&lt;p&gt;They hold demos together.&lt;/p&gt;

&lt;p&gt;But duct tape doesn’t hold under stress.&lt;/p&gt;

&lt;p&gt;A prompt that works in one demo often fails with different inputs.&lt;/p&gt;

&lt;p&gt;Models change.&lt;/p&gt;

&lt;p&gt;Users stretch the boundaries.&lt;/p&gt;

&lt;p&gt;Suddenly, the system that looked smart in a five-minute demo looks lost when exposed to the chaos of production.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost problem
&lt;/h2&gt;

&lt;p&gt;No one talks about cost in a demo.&lt;/p&gt;

&lt;p&gt;You can burn through tokens without worrying.&lt;/p&gt;

&lt;p&gt;But production is a different story.&lt;/p&gt;

&lt;p&gt;When you go from ten queries to ten thousand, the bill starts to matter.&lt;/p&gt;

&lt;p&gt;And scaling an AI system isn’t just about efficiency.&lt;/p&gt;

&lt;p&gt;It’s about trade-offs: do you use a smaller model and risk worse results, or pay for a larger one and risk unsustainable costs?&lt;/p&gt;

&lt;p&gt;Most demos ignore that question.&lt;/p&gt;

&lt;p&gt;Production forces you to answer it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The missing feedback loop
&lt;/h2&gt;

&lt;p&gt;A demo doesn’t need to improve.&lt;/p&gt;

&lt;p&gt;It’s a one-time performance.&lt;/p&gt;

&lt;p&gt;But a real product has to get better over time.&lt;/p&gt;

&lt;p&gt;You need a feedback loop.&lt;/p&gt;

&lt;p&gt;You need to capture when the system fails, learn from it, and adapt.&lt;/p&gt;

&lt;p&gt;Without that, the quality slowly declines.&lt;/p&gt;

&lt;p&gt;Users lose trust.&lt;/p&gt;

&lt;p&gt;And once trust is gone, the product is dead.&lt;/p&gt;

&lt;h2&gt;
  
  
  What really matters
&lt;/h2&gt;

&lt;p&gt;The lesson is simple.&lt;/p&gt;

&lt;p&gt;Anyone can build a demo.&lt;/p&gt;

&lt;p&gt;The hard part is building something that survives messy inputs, unpredictable users, and real-world economics.&lt;/p&gt;

&lt;p&gt;That requires engineering.&lt;/p&gt;

&lt;p&gt;It requires discipline.&lt;/p&gt;

&lt;p&gt;It requires treating AI not as magic, but as a component in a larger system that needs to be designed, tested, and maintained.&lt;/p&gt;

&lt;p&gt;Demos are fun.&lt;/p&gt;

&lt;p&gt;But products change the world.&lt;/p&gt;

&lt;p&gt;And the gap between the two is where most teams fail.&lt;/p&gt;

</description>
      <category>product</category>
      <category>testing</category>
      <category>ai</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Learning in public: The fastest way to grow as a software engineer</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Wed, 24 Sep 2025 20:16:00 +0000</pubDate>
      <link>https://dev.to/thisismairaj/learning-in-public-the-fastest-way-to-grow-as-a-software-engineer-1edf</link>
      <guid>https://dev.to/thisismairaj/learning-in-public-the-fastest-way-to-grow-as-a-software-engineer-1edf</guid>
      <description>&lt;p&gt;Learning is a lifelong journey, especially in the fast-paced world of technology. While many people consume content quietly, the concept of "learning in public" offers a powerful way to accelerate your growth as a developer. Inspired by Shawn Wang’s essay on &lt;a href="https://www.swyx.io/learn-in-public" rel="noopener noreferrer"&gt;Learning in Public&lt;/a&gt;, this post explores how sharing your learning process openly can transform your skills, network, and career.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Learning in Public?
&lt;/h2&gt;

&lt;p&gt;Learning in public is about creating a habit of sharing what you learn as you learn it. Instead of keeping your progress private, you document your journey through blogs, tutorials, videos, or social media posts. This "learning exhaust" not only helps you solidify your knowledge but also benefits others who are on similar paths.&lt;/p&gt;

&lt;p&gt;The key idea is to create the resources you wish you had when you started. Whether it’s a blog post explaining a tricky concept, a YouTube video walking through a coding challenge, or a Reddit thread answering a question, your contributions add value to the community while reinforcing your own understanding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Learn in Public?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. You Become Your Own Best Teacher
&lt;/h3&gt;

&lt;p&gt;When you explain concepts to others, you’re forced to clarify your own understanding. Writing a blog post or recording a tutorial requires you to break down complex ideas into digestible pieces, which deepens your mastery. As Shawn Wang puts it, the biggest beneficiary of learning in public is &lt;em&gt;future you&lt;/em&gt;. By documenting your progress, you create a personal knowledge base that you can revisit and build upon.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. It’s Okay to Be Wrong
&lt;/h3&gt;

&lt;p&gt;Learning in public means embracing vulnerability. You might make mistakes or share incomplete knowledge, but that’s part of the process. The internet will correct you, and that feedback is invaluable. As Wang advises, “Wear your noobyness on your sleeve.” When critics point out flaws, listen, learn, and improve. This iterative process helps you grow faster than learning in isolation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. You Build a Network of Mentors
&lt;/h3&gt;

&lt;p&gt;When you share your work publicly, you attract the attention of experienced developers who notice your genuine curiosity. These individuals often become informal mentors, offering guidance and opportunities. Wang emphasizes, “Pick up what they put down.” When a senior engineer asks for help on a project, seize the chance to contribute. These interactions can lead to one-on-one mentorship that you can’t buy.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. You Amplify Your Impact
&lt;/h3&gt;

&lt;p&gt;By teaching others, you amplify the knowledge of those around you. As Wang notes, “By teaching you, they teach many.” Your beginner’s perspective is a unique asset—your questions and explanations resonate with others who are just starting out. Over time, people will seek you out for help, mistaking you for an expert. Answer to the best of your ability and lean on your mentors when you’re stuck.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Opportunities Follow Visibility
&lt;/h3&gt;

&lt;p&gt;Shawn Wang shares the story of Chris Coyier, who built a massive audience through his site CSS-Tricks by consistently sharing what he learned. While Coyier and his peers started at similar skill levels, his willingness to teach publicly led to a successful career, including raising nearly $90,000 for a site redesign. Learning in public creates visibility, which can open doors to speaking engagements, job offers, and even paid opportunities.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Start Learning in Public
&lt;/h2&gt;

&lt;p&gt;Ready to take the plunge? Here are practical ways to start learning in public today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write Blogs or Tutorials&lt;/strong&gt;: Share your coding journey on platforms like Medium or a personal blog. Write about a new framework you’re learning or a bug you solved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create Videos or Streams&lt;/strong&gt;: Record a YouTube video or Twitch stream walking through a project. Talking through your code helps you process and teaches others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contribute to Open Source&lt;/strong&gt;: Make pull requests to libraries you use or build your own small projects. Cloning a tool you admire from scratch can deepen your understanding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Engage on Public Forums&lt;/strong&gt;: Answer questions on Stack Overflow or Reddit. Avoid private platforms like Slack or Discord—focus on public spaces where your contributions are discoverable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Summarize and Share&lt;/strong&gt;: After attending a conference or workshop, write a summary of what you learned. This reinforces your knowledge and helps others who couldn’t attend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build a Knowledge Base&lt;/strong&gt;: Document your progress in a persistent format, like a personal wiki or GitHub repository. Over time, this becomes a valuable resource for you and others.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Overcoming the Fear of Learning in Public
&lt;/h2&gt;

&lt;p&gt;Sharing your work can feel daunting. You might worry about being judged or making mistakes. But as Wang points out, discomfort is a sign you’re pushing yourself. Embrace the impostor syndrome—it means you’re growing. If someone criticizes you, ask for specific feedback and use it to improve. Block abusive comments and keep moving forward.&lt;/p&gt;

&lt;p&gt;Learning in public isn’t just about immediate gains—it’s about building a reputation as a curious, collaborative developer. Over time, your contributions will compound. You’ll develop a portfolio of work, a network of supporters, and a deeper understanding of your craft. As Wang says, “Eventually, they’ll want to pay you for your help too. A lot more than you think.”&lt;/p&gt;

&lt;h2&gt;
  
  
  It's a mindset shift
&lt;/h2&gt;

&lt;p&gt;Learning in public is a mindset shift that transforms how you approach your development journey. By sharing your knowledge, embracing feedback, and engaging with the community, you accelerate your growth and open doors to new opportunities. Start small—write a blog post, answer a question, or share a project. The key is to begin. As you learn in public, you’ll not only help yourself but also inspire others to do the same.&lt;/p&gt;

&lt;p&gt;What’s one thing you’ve learned recently that you could share with the world? Start today, and let future you reap the rewards.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>ai</category>
      <category>software</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Context engineering 101: Branch AI conversations with Langbase</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Wed, 24 Sep 2025 20:04:02 +0000</pubDate>
      <link>https://dev.to/thisismairaj/context-engineering-101-branch-ai-conversations-with-langbase-pe8</link>
      <guid>https://dev.to/thisismairaj/context-engineering-101-branch-ai-conversations-with-langbase-pe8</guid>
      <description>&lt;p&gt;Long conversations with AI often go off track. Topics pile up, irrelevant details linger, and eventually responses degrade. This is what we call context rot.&lt;/p&gt;

&lt;p&gt;The fix? Branching conversations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Branch Conversations?
&lt;/h2&gt;

&lt;p&gt;Branching is a form of context engineering. Instead of keeping one messy thread, you split the conversation at decision points. Each branch evolves independently, while the original conversation remains intact.&lt;/p&gt;

&lt;p&gt;Benefits include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevent context drift between different discussion paths&lt;/li&gt;
&lt;li&gt;Reduce token usage by trimming unnecessary history&lt;/li&gt;
&lt;li&gt;Explore in parallel without polluting the main thread&lt;/li&gt;
&lt;li&gt;Merge insights back when you’re ready&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it as Git for conversations: fork, explore, and (optionally) merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with Langbase
&lt;/h2&gt;

&lt;p&gt;Branching with &lt;a href="https://langbase.com/" rel="noopener noreferrer"&gt;Langbase&lt;/a&gt; takes just a few lines of code. Let’s walk through it step by step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Dependencies
&lt;/h3&gt;

&lt;p&gt;Install the Langbase SDK in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i langbase dotenv
# or
pnpm add langbase dotenv
# or
yarn add langbase dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1.1: Langbase API key
&lt;/h3&gt;

&lt;p&gt;Every request you send to Langbase needs an API key. You need to generate your API key by following these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up at &lt;a href="https://langbase.com/" rel="noopener noreferrer"&gt;Langbase.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;From the sidebar, click on the API keys&lt;/li&gt;
&lt;li&gt;From here, you can create a new API key. For more details, follow &lt;a href="https://langbase.com/docs/api-reference/api-keys" rel="noopener noreferrer"&gt;this guide&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file and add your API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LANGBASE_API_KEY=xxxxxxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize Langbase with your API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import dotenv from 'dotenv';
import { Langbase, ThreadMessage } from 'langbase';

dotenv.config();

const langbase = new Langbase({
  apiKey: process.env.LANGBASE_API_KEY!,
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create the Initial Conversation
&lt;/h3&gt;

&lt;p&gt;Let’s start with a practical example: choosing state management for a React app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function createConversation() {
  const thread = await langbase.threads.create({
    messages: [
      { role: 'user', content: 'I need to add state management to my React app' },
      { role: 'assistant', content: 'How complex is your app and what are your main requirements?' },
      { role: 'user', content: "It's medium-sized, with user data, API calls, and real-time updates" },
      { role: 'assistant', content: 'You could use Redux for its ecosystem, or Zustand for simplicity. Which do you prefer?' },
    ],
  });

  return thread.id;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Branch the Conversation
&lt;/h3&gt;

&lt;p&gt;At the decision point (Redux vs Zustand), create a new branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function branchThread(threadId: string, branchAt: number) {
  const messages = await langbase.threads.messages.list({ threadId });
  const messagesToKeep = messages.slice(0, branchAt);

  const branch = await langbase.threads.create({
    messages: messagesToKeep as ThreadMessage[],
    metadata: {
      parent: threadId,
      branchedAt: branchAt.toString(),
    },
  });

  return branch.id;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Continue Each Branch
&lt;/h3&gt;

&lt;p&gt;Now both threads evolve independently:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function main() {
  const originalId = await createConversation();
  const branchId = await branchThread(originalId, 4);

  // Continue with Redux
  await langbase.threads.append({
    threadId: originalId,
    messages: [
      { role: 'user', content: "Let's go with Redux" },
      { role: 'assistant', content: 'Great choice! Redux Toolkit makes setup easier. Here’s how…' },
    ],
  });

  // Explore Zustand
  await langbase.threads.append({
    threadId: branchId,
    messages: [
      { role: 'user', content: 'Tell me about Zustand' },
      { role: 'assistant', content: "Zustand is lightweight and only 2KB. Here’s how to get started…" },
    ],
  });
}

main();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now have two independent discussions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Original&lt;/strong&gt; → continues with Redux&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branch&lt;/strong&gt; → explores Zustand&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Run It
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tsx index.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see two clean, focused threads in your console.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this matters
&lt;/h3&gt;

&lt;p&gt;Branching prevents conversations from collapsing under their own weight. Instead of a single, tangled thread, you get structured trees of thought:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep threads modular and adaptive&lt;/li&gt;
&lt;li&gt;Reuse branches for future work&lt;/li&gt;
&lt;li&gt;Merge insights or summaries back into the main conversation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;a href="https://langbase.com" rel="noopener noreferrer"&gt;Langbase&lt;/a&gt;, branching isn’t just possible — it’s simple.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>contextengineering</category>
      <category>typescript</category>
    </item>
    <item>
      <title>9 AI primitives that simplify building AI agents</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Wed, 24 Sep 2025 19:38:23 +0000</pubDate>
      <link>https://dev.to/thisismairaj/9-ai-primitives-that-simplify-building-ai-agents-3m1l</link>
      <guid>https://dev.to/thisismairaj/9-ai-primitives-that-simplify-building-ai-agents-3m1l</guid>
      <description>&lt;p&gt;Building AI agents at scale is hard. You need to juggle tools, memory, conversation state, observability, and cost management — all while ensuring your workflows remain reliable and efficient.  &lt;/p&gt;

&lt;p&gt;That’s exactly where Langbase SDK comes in. It provides a set of AI primitives — simple, composable building blocks — that let you create powerful AI systems without reinventing the wheel.  &lt;/p&gt;

&lt;p&gt;Here are 9 primitives from Langbase that make it easier to build production-ready AI applications:  &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pipe
&lt;/h2&gt;

&lt;p&gt;Pipe is the foundation. It’s a unified primitive with everything you need to build serverless AI agents: tools, memory, threads, dynamic variables, observability, tracing, and cost controls.  &lt;/p&gt;

&lt;p&gt;In short: Pipe is your “all-in-one” building block. With &lt;a href="https://langbase.com/studio" rel="noopener noreferrer"&gt;Langbase Studio&lt;/a&gt;, you can also manage access, add safety, and track usage with ease.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feg8q68oudopvgjexphb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feg8q68oudopvgjexphb1.png" alt=" " width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Memory
&lt;/h2&gt;

&lt;p&gt;Agents need memory to feel “human-like.”  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://langbase.com/memory" rel="noopener noreferrer"&gt;Langbase Memory&lt;/a&gt; primitive gives your agents long-term, semantic memory — essentially RAG as an infinitely scalable API. It’s also 30–50x more cost-efficient compared to alternatives, making it practical for real-world apps.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F249uuol9rglyqvhh5af0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F249uuol9rglyqvhh5af0.jpg" alt=" " width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Agent
&lt;/h2&gt;

&lt;p&gt;Agent is the runtime primitive that powers serverless AI agents. It offers a unified API over 600+ LLMs, with support for advanced features like:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Streaming
&lt;/li&gt;
&lt;li&gt;Tool calling
&lt;/li&gt;
&lt;li&gt;Structured outputs
&lt;/li&gt;
&lt;li&gt;Vision models
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With Agent, you can swap and extend LLMs seamlessly.  &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Workflow
&lt;/h2&gt;

&lt;p&gt;Real-world agents often require multiple steps. Workflow helps you chain those steps reliably, with built-in durability, retries, and timeouts.  &lt;/p&gt;

&lt;p&gt;Every step is traceable, and detailed logging ensures you know exactly what’s happening in your pipeline.  &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Threads
&lt;/h2&gt;

&lt;p&gt;Managing context across long conversations is tricky. Threads solve this by storing and handling conversation history automatically — no need for custom databases.  &lt;/p&gt;

&lt;p&gt;Better yet, Threads support branching, so you can avoid “context rot” when conversations drift in multiple directions.  &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Tools
&lt;/h2&gt;

&lt;p&gt;Tools extend your agents beyond the LLM. With just a few lines, you can:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perform web searches
&lt;/li&gt;
&lt;li&gt;Crawl webpages for content
&lt;/li&gt;
&lt;li&gt;Add custom functionalities tailored to your app
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes your AI agents far more capable than a vanilla LLM.  &lt;/p&gt;

&lt;h2&gt;
  
  
  7. Parser
&lt;/h2&gt;

&lt;p&gt;Structured and unstructured documents are everywhere.  &lt;/p&gt;

&lt;p&gt;Parser helps extract text from files like CSV, PDF, and more, so you can turn them into clean text for further analysis or use in pipelines.  &lt;/p&gt;

&lt;h2&gt;
  
  
  8. Chunker
&lt;/h2&gt;

&lt;p&gt;Working with large documents? Use Chunker.  &lt;/p&gt;

&lt;p&gt;It splits text into smaller, manageable sections — essential for RAG pipelines or when you need fine-grained control over what part of the document your model sees.  &lt;/p&gt;

&lt;h2&gt;
  
  
  9. Embed
&lt;/h2&gt;

&lt;p&gt;Embed converts text into vector embeddings, unlocking capabilities like:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Semantic search
&lt;/li&gt;
&lt;li&gt;Text similarity comparisons
&lt;/li&gt;
&lt;li&gt;Other advanced NLP tasks
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With Embed, you can build retrieval pipelines, recommendation systems, and intelligent search features.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Langbase SDK gives you a complete suite of AI primitives that scale from hobby projects to production-grade AI systems.  &lt;/p&gt;

&lt;p&gt;Instead of reinventing the wheel, you can focus on building smarter, more capable AI agents — faster.  &lt;/p&gt;

&lt;p&gt;Explore the docs and start building: &lt;a href="https://langbase.com/docs/sdk?utm_source=DevRel&amp;amp;utm_campaign=Threads" rel="noopener noreferrer"&gt;Langbase SDK Documentation&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>ai</category>
      <category>llms</category>
      <category>aiagents</category>
      <category>aiframeworks</category>
    </item>
    <item>
      <title>20 AI concepts, explained clearly</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Tue, 23 Sep 2025 19:47:28 +0000</pubDate>
      <link>https://dev.to/thisismairaj/20-ai-concepts-explained-clearly-5a24</link>
      <guid>https://dev.to/thisismairaj/20-ai-concepts-explained-clearly-5a24</guid>
      <description>&lt;p&gt;Artificial Intelligence (AI) has exploded in recent years, powering everything from chatbots and recommendation engines to image generators and autonomous agents.&lt;/p&gt;

&lt;p&gt;But if you’re just starting out, the jargon can feel overwhelming.&lt;br&gt;
Terms like &lt;em&gt;transformers, embeddings, RAG,&lt;/em&gt; and &lt;em&gt;fine-tuning&lt;/em&gt; pop up everywhere.&lt;/p&gt;

&lt;p&gt;This guide breaks down &lt;strong&gt;20 fundamental AI concepts&lt;/strong&gt; in plain language.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Large Language Models (LLMs)
&lt;/h3&gt;

&lt;p&gt;At the core of today’s AI revolution are LLMs like GPT, Claude, and Llama.&lt;br&gt;
They’re essentially giant neural networks trained to &lt;strong&gt;predict the next word&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Input: &lt;em&gt;“All that glitters…”&lt;/em&gt;&lt;br&gt;
Output: &lt;em&gt;“…is not gold.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That simple predictive mechanism unlocks surprising intelligence.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Tokenization
&lt;/h3&gt;

&lt;p&gt;Before text can be fed into a model, it’s chopped into &lt;strong&gt;tokens&lt;/strong&gt; (small chunks of text).&lt;/p&gt;

&lt;p&gt;Example: &lt;em&gt;“dancing” → [“danc”, “ing”]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This allows the model to work with language at a granular, structured level.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Vectors (Embeddings)
&lt;/h3&gt;

&lt;p&gt;Models convert tokens into vectors, numerical points in multi-dimensional space.&lt;br&gt;
Words with similar meanings end up close together.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“happy” sits near “joy”&lt;/li&gt;
&lt;li&gt;“sad” is further away&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how AI “understands” meaning.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Memory
&lt;/h3&gt;

&lt;p&gt;Memory lets LLMs retain information from past interactions.&lt;/p&gt;

&lt;p&gt;It helps them remember context, preferences, or facts across conversations.&lt;/p&gt;

&lt;p&gt;This makes AI more personal and consistent over time.&lt;br&gt;
Try &lt;a href="https://langbase.com/docs/memory" rel="noopener noreferrer"&gt;Langbase Memory&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Self-Supervised Learning
&lt;/h3&gt;

&lt;p&gt;Instead of humans labeling data, models learn by filling in blanks:&lt;/p&gt;

&lt;p&gt;“All that glitters ___ not gold.”&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;self-supervised&lt;/strong&gt; method scales to trillions of tokens, no need for endless manual labeling.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Tools
&lt;/h3&gt;

&lt;p&gt;Tools are external functions or APIs that an LLM can call.&lt;/p&gt;

&lt;p&gt;They extend what the model can do, like fetch data, or query databases.&lt;/p&gt;

&lt;p&gt;Think of them as the model’s “hands” to interact with the world.&lt;/p&gt;

&lt;p&gt;To learn about tools in detail, &lt;a href="https://langbase.com/docs/features/tool-calling" rel="noopener noreferrer"&gt;see this guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Fine-Tuning
&lt;/h3&gt;

&lt;p&gt;A base model is general-purpose.&lt;br&gt;
Fine-tuning = retraining it on &lt;strong&gt;specialized data&lt;/strong&gt; (legal, medical, financial, etc.).&lt;/p&gt;

&lt;p&gt;The result: a model adapted to your domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Few-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;Instead of retraining, sometimes you just need to show examples in the prompt:&lt;/p&gt;

&lt;p&gt;Q: “Where’s my parcel?”&lt;br&gt;
Example → Answer style&lt;/p&gt;

&lt;p&gt;The model learns to mimic the pattern instantly.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Retrieval-Augmented Generation (RAG)
&lt;/h3&gt;

&lt;p&gt;LLMs don’t know real-time info.&lt;br&gt;
RAG fixes this by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieving relevant docs from a database&lt;/li&gt;
&lt;li&gt;Feeding them into the model&lt;/li&gt;
&lt;li&gt;Generating grounded answers&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the backbone of many AI apps today. To learn about RAG in detail, &lt;a href="https://langbase.com/docs/explained/rag" rel="noopener noreferrer"&gt;see this guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Vector Databases
&lt;/h3&gt;

&lt;p&gt;To power RAG, we need special databases.&lt;br&gt;
They store &lt;strong&gt;document embeddings&lt;/strong&gt; (vectors) and quickly find the most relevant ones.&lt;/p&gt;

&lt;p&gt;Examples: &lt;a href="https://www.pinecone.io/" rel="noopener noreferrer"&gt;Pinecone&lt;/a&gt;, &lt;a href="https://weaviate.io/" rel="noopener noreferrer"&gt;Weaviate&lt;/a&gt;, &lt;a href="https://milvus.io/" rel="noopener noreferrer"&gt;Milvus&lt;/a&gt;, &lt;a href="https://python.langchain.com/docs/integrations/vectorstores/faiss/" rel="noopener noreferrer"&gt;FAISS&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Model Context Protocol (MCP)
&lt;/h3&gt;

&lt;p&gt;LLMs can’t browse or act on their own.&lt;br&gt;
MCP lets them connect to external tools and APIs, extending their abilities.&lt;/p&gt;

&lt;p&gt;Imagine asking an AI: &lt;em&gt;“Book me a flight tomorrow.”&lt;/em&gt;&lt;br&gt;
MCP makes it possible.&lt;/p&gt;

&lt;p&gt;Try building &lt;a href="https://langbase.com/docs/mcp-servers" rel="noopener noreferrer"&gt;MCP-powered agents&lt;/a&gt; with Langbase.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Context Engineering
&lt;/h3&gt;

&lt;p&gt;Prompt engineering was just the beginning.&lt;br&gt;
Context engineering means carefully shaping the information fed into an LLM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RAG&lt;/li&gt;
&lt;li&gt;Few-shot examples&lt;/li&gt;
&lt;li&gt;Summarization&lt;/li&gt;
&lt;li&gt;External tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal: deliver the &lt;strong&gt;right context&lt;/strong&gt; at the right time.&lt;/p&gt;

&lt;h3&gt;
  
  
  13. Agents
&lt;/h3&gt;

&lt;p&gt;Agents are LLM-powered programs that can use tools, call APIs, and orchestrate tasks. They don’t just answer; they plan, fetch data, and take actions.&lt;/p&gt;

&lt;p&gt;Example: a travel agent that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finds flights&lt;/li&gt;
&lt;li&gt;Books hotels&lt;/li&gt;
&lt;li&gt;Emails your itinerary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try building one with &lt;a href="https://langbase.com/docs/agent" rel="noopener noreferrer"&gt;Langbase runtime agents&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  14. Reinforcement Learning from Human Feedback (RLHF)
&lt;/h3&gt;

&lt;p&gt;How do models become more &lt;em&gt;human-aligned&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;They generate multiple outputs.&lt;br&gt;
Humans rate them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Good answers → rewarded&lt;/li&gt;
&lt;li&gt;Bad answers → penalized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Over time, the model learns human preferences.&lt;/p&gt;

&lt;h3&gt;
  
  
  15. Chain of Thought (CoT)
&lt;/h3&gt;

&lt;p&gt;Instead of spitting out answers, models show step-by-step reasoning.&lt;br&gt;
This helps with math, logic, and complex problem-solving.&lt;/p&gt;

&lt;h3&gt;
  
  
  16. Multimodal Models
&lt;/h3&gt;

&lt;p&gt;The future isn’t just text.&lt;br&gt;
Multimodal AI handles &lt;strong&gt;text, images, audio, and video&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upload a chart → get a summary&lt;/li&gt;
&lt;li&gt;Ask it to generate music&lt;/li&gt;
&lt;li&gt;Describe an image → get variations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  17. Small Language Models (SLMs)
&lt;/h3&gt;

&lt;p&gt;Not all models need to be massive.&lt;br&gt;
SLMs are compact, domain-specific, and cheaper to run.&lt;/p&gt;

&lt;p&gt;Perfect for enterprises that need private, efficient AI.&lt;/p&gt;

&lt;h3&gt;
  
  
  18. Distillation
&lt;/h3&gt;

&lt;p&gt;How do you make big models smaller without losing smarts?&lt;br&gt;
Distillation = training a small “student” model to mimic a large “teacher” model.&lt;/p&gt;

&lt;p&gt;This makes deployment lighter + faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  19. Reasoning Models
&lt;/h3&gt;

&lt;p&gt;Beyond prediction.&lt;br&gt;
Reasoning models can &lt;strong&gt;plan, break down problems, and explore solutions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of them as AI that &lt;em&gt;thinks&lt;/em&gt; more than just &lt;em&gt;guesses&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  20. Foundation Models
&lt;/h3&gt;

&lt;p&gt;The giants that start it all.&lt;br&gt;
Trained on massive datasets, they act as &lt;strong&gt;base layers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;From there, developers fine-tune or adapt them into specialized smaller models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final thoughts
&lt;/h3&gt;

&lt;p&gt;AI can feel intimidating, but at its core, it’s about patterns, context, and reasoning.&lt;/p&gt;

&lt;p&gt;If you understand these 20 concepts, you’ll have a strong foundation to explore deeper, whether you’re building AI products, researching, or just curious about the tech shaping our future.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llms</category>
      <category>tech</category>
    </item>
    <item>
      <title>RAG vs fine-tuning vs prompt engineering</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Tue, 23 Sep 2025 19:36:44 +0000</pubDate>
      <link>https://dev.to/thisismairaj/rag-vs-fine-tuning-vs-prompt-engineering-fcg</link>
      <guid>https://dev.to/thisismairaj/rag-vs-fine-tuning-vs-prompt-engineering-fcg</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybn38k0lqbw3nnavug9i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybn38k0lqbw3nnavug9i.jpeg" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Improving outputs from large language models is rarely a question of "which single tool" to use. It is a design choice that balances accuracy, latency, cost, maintenance, and safety.&lt;/p&gt;

&lt;p&gt;This article provides a thorough, practical comparison of the three dominant approaches: prompt engineering, RAG, and fine-tuning. So you can choose and combine them effectively for real products.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR for each approach
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Prompt engineering&lt;/strong&gt;: Change the input (the prompt) to better activate the model's existing knowledge and skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAG&lt;/strong&gt;: Give the model fresh, domain-specific evidence by retrieving external content and appending it to the prompt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fine-tuning&lt;/strong&gt;: Change the model itself by training it on domain examples so the knowledge and behavior are baked into its weights.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt engineering: what's it all about?
&lt;/h2&gt;

&lt;p&gt;Prompt engineering shapes how the model interprets and prioritizes information that already exists in its parameters.&lt;/p&gt;

&lt;p&gt;The challenge with prompt engineering is consistency. Prompts evolve over time, and subtle changes can produce significantly different results. This is where Langbase Pipes become useful.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can experiment with variations side by side.&lt;/li&gt;
&lt;li&gt;You can roll back to earlier versions.&lt;/li&gt;
&lt;li&gt;You can track which prompts deliver consistent, high-quality results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach allows you to iterate rapidly without losing control, much like developers use Git for code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By the way, Langbase provides &lt;a href="https://langbase.com/docs/memory" rel="noopener noreferrer"&gt;memory agents&lt;/a&gt;, the most inexpensive RAG solution.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key techniques
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Role and instruction framing (system or lead-in statement that defines tone, role, and constraints).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Few-shot prompting (showing examples to demonstrate desired style/logic).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Chain-of-thought or step-by-step prompts to improve reasoning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Output constraints (formatting, JSON schema, length, explicit style rules).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prompt templates and variable substitution for repeatable tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  When to use it
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fast iteration, prototyping, and low-cost improvements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you cannot or do not want to change model weights or add infra.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To enforce formatting and to reduce simple ambiguity in user input.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Limitations and risks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cannot add factual knowledge that the model does not already have.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Brittleness: minor wording changes can produce different results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can't solve problems that require current data beyond the model's cutoff.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Evaluation is often empirical and requires careful A/B testing and versioning of prompts.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Maintain prompt templates under version control and track experiments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use unit tests and automated checks for format and safety.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine with lightweight verification (e.g., regex checks, parsers) to catch format violations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  RAG: how it works and doesn't
&lt;/h2&gt;

&lt;p&gt;RAG augments model output with material retrieved from a document corpus (internal knowledge base, web, PDFs, etc.). Technically this is "retrieve, augment, generate."&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://langbase.com/docs/memory" rel="noopener noreferrer"&gt;Langbase Memory&lt;/a&gt;, you can implement RAG directly. Memory lets you ingest documents, store embeddings, and retrieve relevant chunks during a conversation.&lt;/p&gt;

&lt;h3&gt;
  
  
  High-level architecture
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ingest&lt;/strong&gt;: documents are preprocessed, split into chunks, and embedded.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Store&lt;/strong&gt;: embeddings and chunk metadata are stored in a vector database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Retrieve&lt;/strong&gt;: for each user query, compute an embedding and fetch top-k semantically similar chunks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Re-rank and filter&lt;/strong&gt;: optionally re-score retrieved results with a secondary model or heuristics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Augment prompt&lt;/strong&gt;: concatenate the selected chunks or their summaries with the original query.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate&lt;/strong&gt;: the LLM produces an answer conditioned on the augmented prompt.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppju3xcn54e3pyd6szpf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppju3xcn54e3pyd6szpf.jpg" alt=" " width="800" height="467"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://langbase.com/docs/memory" rel="noopener noreferrer"&gt;Langbase Memory (RAG)&lt;/a&gt; architecture&lt;/p&gt;

&lt;h3&gt;
  
  
  Why RAG is valuable
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Gives access to up-to-date, domain-specific facts without retraining the model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enables provenance: you can link answers back to documents or passages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Good for domains where the base model's cutoff or coverage is insufficient.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Operational trade-offs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Latency&lt;/strong&gt;: retrieving and re-ranking adds time per query.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Infrastructure&lt;/strong&gt;: requires embedding services, a vector DB, and periodic re-ingestion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost&lt;/strong&gt;: embedding + storage + retrieval + LLM calls can be materially more expensive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hallucination risk&lt;/strong&gt;: the model can still hallucinate or over-generalize even with retrieved context; requiring explicit citation and grounding helps&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Chunk documents with overlap to preserve context but avoid redundancy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Precompute and refresh embeddings when sources change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use re-rankers (BM25, cross-encoders) to improve precision.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limit context length and prioritize high-quality sources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Surface provenance (document id, snippet, URL) with each claim.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fine-tuning
&lt;/h2&gt;

&lt;p&gt;Fine-tuning updates model weights by training on a labeled, domain-specific dataset. Variants include full fine-tuning and parameter-efficient methods (LoRA, adapters, PEFT), which change fewer parameters for lower cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  What fine-tuning achieves
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Embeds domain knowledge and preferred behaviors directly into the model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improves consistency for specialized tasks and can reduce the need for long context windows at inference.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Eliminates the per-query retrieval overhead if all needed knowledge can be encoded in the model.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Requirements and costs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt;: high quality, well-labeled examples are essential. Thousands of curated examples are typical for nontrivial tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compute&lt;/strong&gt;: training requires GPUs or managed training services; costs can escalate for large models&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintenance&lt;/strong&gt;: to update knowledge you need to retrain or adapt the model; versioning and rollback mechanisms are necessary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Risks&lt;/strong&gt;: catastrophic forgetting (losing general capabilities), overfitting to training data, possible introduction of biases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  When to choose fine-tuning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When you need very high performance on a narrow, stable domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When latency must be minimal and predictable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When privacy/regulatory constraints require on-device or on-premise models with no external retrieval.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Best practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hold out evaluation and test sets that reflect production prompts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use parameter-efficient methods where possible to reduce compute and avoid full retrains.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor general-purpose performance post-tuning to detect catastrophic forgetting.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep fine-tuned models versioned and provide an easy rollback path&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Comparing the approaches (concise)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prompt engineering&lt;/strong&gt; improves clarity and control without infrastructure changes but cannot expand a model's knowledge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RAG&lt;/strong&gt; provides fresh, domain-specific evidence at the cost of extra infrastructure, latency, and complexity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fine-tuning&lt;/strong&gt; embeds deep expertise into the model itself, delivering faster inference and specialized behavior, but requires data, compute, and maintenance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most production systems use a hybrid: fine-tune where stable expertise is needed, use RAG to add recent or large external corpora, and apply prompt engineering to shape output and enforce constraints.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example: Legal AI agent (detailed pipeline)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ingest firm knowledge: policies, playbooks, annotated past briefs → chunk, embed, store in a secure vector DB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fine-tune a core model on firm templates and permitted language to internalize style, disclaimers, and firm policy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At query time:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Compute query embedding; retrieve top-k passages from vector DB.&lt;/li&gt;
&lt;li&gt;Re-rank passages via a cross-encoder or BM25 hybrid.&lt;/li&gt;
&lt;li&gt;Construct a controlled prompt that includes: the most relevant passages, an instruction to cite sources, and a JSON output schema.&lt;/li&gt;
&lt;li&gt;Run generation on the fine-tuned model.&lt;/li&gt;
&lt;li&gt;Run a verifier that checks claims against retrieved passages; if inconsistencies appear, flag for human review.&lt;/li&gt;
&lt;li&gt;Return response with inline citations and an "evidence" panel for the user to inspect.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This hybrid approach gives fast, policy-compliant writing, up-to-date legal citations, and auditability through provenance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decision flow: which to pick first
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Want immediate, low-cost improvements?&lt;/strong&gt; Start with prompt engineering.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Need current facts or large corpora accessible at query time?&lt;/strong&gt; Implement RAG.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Need high, repeatable accuracy in a narrow domain and can afford training?&lt;/strong&gt; Fine-tune (or use parameter-efficient tuning).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Complex, production use cases often require all three: fine-tuning for domain rules, RAG for fresh evidence, and prompt engineering for consistent outputs and safety controls.&lt;/p&gt;

&lt;p&gt;At &lt;a href="https://langbase.com/?utm_source=Medium.com&amp;amp;utm_campaign=DevRel" rel="noopener noreferrer"&gt;Langbase&lt;/a&gt;, we build, deploy and scale AI agents, co-powered by these approaches.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llms</category>
      <category>promptengineering</category>
      <category>rag</category>
    </item>
    <item>
      <title>The shortest AI agent you can build</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Thu, 18 Sep 2025 20:41:27 +0000</pubDate>
      <link>https://dev.to/thisismairaj/the-shortest-ai-agent-you-can-build-57p4</link>
      <guid>https://dev.to/thisismairaj/the-shortest-ai-agent-you-can-build-57p4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikuwnc1avp0syi1yplj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikuwnc1avp0syi1yplj0.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're going to build an AI agent that uses GPT-5. We'll use agent primitive by &lt;strong&gt;Langbase&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The agent works as a runtime LLM agent. You can specify all parameters at runtime and get the response from the agent. Agent uses Langbase's unified LLM API to provide a consistent interface for interacting with &lt;strong&gt;600+ LLMs&lt;/strong&gt; across all the top LLM providers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://langbase.com/docs/models" rel="noopener noreferrer"&gt;See the list of supported models and providers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Okay, let's get to building! 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Start by installing the Langbase SDK (comes in both TypeScript and Python).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;langbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Langbase API Key
&lt;/h2&gt;

&lt;p&gt;Every request you send to Langbase needs an API key. You need to generate your API key by following these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up at &lt;a href="https://langbase.com" rel="noopener noreferrer"&gt;Langbase.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;From the sidebar, click on the &lt;strong&gt;API keys&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;From here, you can create a new API key. For more details, follow &lt;a href="https://langbase.com/docs/api-keys" rel="noopener noreferrer"&gt;this guide&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file and place the Langbase API key like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LANGBASE_API_KEY=your_langbase_api_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another environment variable you need is for the LLM model you decide to use. In this example, we are using OpenAI's GPT-5. So add the LLM API Key like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LLM_API_KEY=your_openai_api_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting Up the Code
&lt;/h2&gt;

&lt;p&gt;Next, create an &lt;code&gt;index.ts&lt;/code&gt; file and import the necessary packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Langbase&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;langbase&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv/config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's initialize Langbase:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;langbase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Langbase&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LANGBASE_API_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The AI Agent Code
&lt;/h2&gt;

&lt;p&gt;Finally, the code for the AI agent. It might be the &lt;strong&gt;shortest AI agent ever&lt;/strong&gt;. Here it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;langbase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;openai:gpt-5-mini-2025-08-07&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;instructions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You are a helpful AI Agent.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Who is an AI Engineer?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LLM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running Your Agent
&lt;/h2&gt;

&lt;p&gt;Finally, run your code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tsx index.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  That's It!
&lt;/h2&gt;

&lt;p&gt;That's like &lt;strong&gt;5–6 lines of code&lt;/strong&gt;. The code is pretty much the same in Python too.&lt;/p&gt;

&lt;p&gt;You can dynamically modify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The prompt&lt;/li&gt;
&lt;li&gt;The model&lt;/li&gt;
&lt;li&gt;The system prompt (instructions param)&lt;/li&gt;
&lt;li&gt;Get the agent to stream the output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's up to you! Langbase supports &lt;strong&gt;600+ AI models&lt;/strong&gt;. This includes open source models like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kimi K2&lt;/li&gt;
&lt;li&gt;DeepSeek R1
&lt;/li&gt;
&lt;li&gt;Grok 4&lt;/li&gt;
&lt;li&gt;And many more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What are you waiting for? &lt;strong&gt;Build your AI agent today!&lt;/strong&gt; &lt;/p&gt;

</description>
      <category>programming</category>
      <category>ai</category>
      <category>llms</category>
    </item>
    <item>
      <title>Context engineering: What, why and how to engineer context</title>
      <dc:creator>Muhammad Mairaj</dc:creator>
      <pubDate>Thu, 18 Sep 2025 20:30:28 +0000</pubDate>
      <link>https://dev.to/thisismairaj/context-engineering-what-why-and-how-to-engineer-context-be9</link>
      <guid>https://dev.to/thisismairaj/context-engineering-what-why-and-how-to-engineer-context-be9</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3b4nubly1jlm0owzchqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3b4nubly1jlm0owzchqy.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;In the past two years, prompt engineering has risen as a crucial skill for getting the most out of AI systems. But as context windows grow bigger, a new discipline is emerging: &lt;strong&gt;context engineering&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Today, the underlying models are powerful for most tasks. The reason agents fail is that they are not provided the right context. The bottleneck shifts from model capability to system design. That's where context engineering comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the heck is context engineering?
&lt;/h2&gt;

&lt;p&gt;Context engineering is designing systems to deliver context to the LLM. It involves filling the LLM's context window with exactly what it needs to succeed at a specific step in a complex workflow. It is setting the stage for the models to perform effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The complete environment for the model.&lt;/strong&gt; Includes background, tone, intent, history, tools, and guardrails.&lt;/p&gt;

&lt;p&gt;Compare LLMs to an OS, where CPU is the model and RAM represents a "working memory" for the model. Just like an OS curates what fits into the RAM, context engineering is the science of filling the context window with just the right amount of right information.&lt;/p&gt;

&lt;p&gt;Enough information to do the task, but not too much to confuse the LLM and save token costs. AI models get their AI agents get their context from multiple dynamic sources. It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instructions&lt;/strong&gt; - prompts, memories, guardrails, and preferences&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval&lt;/strong&gt; - retrieval systems to fetch relevant information
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool outputs&lt;/strong&gt; - data flowing in from web search and APIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, they form the model's perception of the task at hand. Context engineering is about orchestrating this perception with precision, ensuring that every token counts and every part of the context serves a purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  The context window
&lt;/h2&gt;

&lt;p&gt;The context window is the amount of information the model sees at a time. It is limited, and there is ample debate around token optimization to best manage the window.&lt;/p&gt;

&lt;p&gt;Context engineering is the craft of carefully filling this window with the right information. There is so much context available to the model at any time. For example, a deep-research agent might retrieve hundreds of pages of content through search tools - far exceeding what the model can fit into its context window.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It's like packing a bag for a hike. Take too little and you're lost. Take too much and you're overwhelmed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you provide too little information, the model gives vague answers. If you provide too much information, the context overflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why context engineering is important
&lt;/h2&gt;

&lt;p&gt;In multi-agent systems, where a complex task is distributed across several agents, managing context becomes absolutely critical.&lt;/p&gt;

&lt;p&gt;Consider a scenario where a task is being divided between multiple agents. The subagents receive a fragment of the overall context and a subtask. The agent that divided the task has the full context of the task. The subagents don't have that broader context. They can easily miscommunicate and produce nothing close to the original task.&lt;/p&gt;

&lt;p&gt;This happens often in multi-agent architectures. Agent-to-agent communication can fix the problem of miscommunication between agents, but that's early at the moment. Until that matures, ensure the task is parallelizable for multi-agent scenarios.&lt;/p&gt;

&lt;p&gt;One way to curb this problem is &lt;strong&gt;context compression&lt;/strong&gt;. Agent interactions can span hundreds of turns and may have token-heavy tool calls, resulting in context overflow. At each turn, compress the context to only forward high-value tokens.&lt;/p&gt;

&lt;p&gt;This is one of the techniques of context engineering. General principles for building agents are still in their infancy, so there is lot of ongoing experimentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond prompts: A system approach
&lt;/h2&gt;

&lt;p&gt;Prompts are instructions part of one interaction for accomplishing a task. Prompt engineering involves specific phrasings, examples, or formatting that trigger desired responses. Context engineering requires systematic approaches: database design, information architecture, retrieval systems, and knowledge management.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompt is what you ask.&lt;/strong&gt; E.g. "Translate this paragraph to Spanish"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context is what the model knows when you ask it.&lt;/strong&gt; E.g. "User is a South Asian. Previous conversations were about visiting Spain."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The prompt is just the tip of the iceberg. Context is everything underneath that makes it possible.&lt;/p&gt;

&lt;p&gt;Engineering context is much larger. Designing systems to best deliver the right context agents running in production for months, require structures. These structures are scalable, and rigorously tested to avoid breaking real-world production environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The shift from prompts to context is not just semantic, it's systematic.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Engineering a great context
&lt;/h2&gt;

&lt;p&gt;To engineer effective context, you have to make decisions in real time - about what to include, exclude and carry forward. Key questions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What's the broader task at hand?&lt;/li&gt;
&lt;li&gt;What information does the model need?&lt;/li&gt;
&lt;li&gt;What should it remember from earlier steps?&lt;/li&gt;
&lt;li&gt;What should it forget to avoid getting confused?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Context engineering is still an emerging discipline, and best practices continue to evolve. However, it is not an optional skill. &lt;strong&gt;It's the core of how the powerful AI systems will work from here on.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llms</category>
      <category>contextengineering</category>
      <category>promptengineering</category>
    </item>
  </channel>
</rss>
