<?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: Maya Richardson</title>
    <description>The latest articles on DEV Community by Maya Richardson (@mayairesearcher).</description>
    <link>https://dev.to/mayairesearcher</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4133743%2F5acee951-58de-4044-b7f1-808ca17aabbf.png</url>
      <title>DEV Community: Maya Richardson</title>
      <link>https://dev.to/mayairesearcher</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mayairesearcher"/>
    <language>en</language>
    <item>
      <title>Why Compute Scaling Stops Working: Moving from Brute Force to Smart Learning</title>
      <dc:creator>Maya Richardson</dc:creator>
      <pubDate>Wed, 25 Nov 2026 10:32:45 +0000</pubDate>
      <link>https://dev.to/mayairesearcher/why-compute-scaling-stops-working-moving-from-brute-force-to-smart-learning-4m9g</link>
      <guid>https://dev.to/mayairesearcher/why-compute-scaling-stops-working-moving-from-brute-force-to-smart-learning-4m9g</guid>
      <description>&lt;p&gt;&lt;em&gt;Richard Sutton's warning on raw scaling, why diminishing returns matter for your stack, and how to think about learning algorithms instead.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Richard Sutton just put a target on the scaling playbook. On November 7, 2026, the Turing Award winner and University of Alberta researcher posted that "brute force computation is not enough for intelligence. Clever new methods are needed. The science of AI is far from finished." He wasn't being sentimental, he was naming a technical wall that's getting harder to ignore.&lt;/p&gt;

&lt;p&gt;For years, bigger models with more parameters and more training data worked. That's still true, but the math is changing. The gap between the best and tenth-ranked models on benchmarks shrank from 11.9 percentage points to 5.4 percentage points in a single year. The top two models are now separated by only 0.7 percentage points. That's not progress slowing, that's saturation. When you're competing in tenths of a point, you're no longer scaling; you're optimizing. And if you're still thinking in terms of raw compute, you're going to pour money into diminishing returns while your competitors move to the algorithm layer.&lt;/p&gt;

&lt;p&gt;The mistake most engineers make is assuming the scaling era will last forever. It won't. What Sutton and others are pointing at is the efficiency frontier: you need to find which new methods, not just which new parameters, will move the needle. That's where the real opportunity is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Familiarity with transformer architectures and how training compute relates to model performance.&lt;/li&gt;
&lt;li&gt;Understanding of what a loss curve looks like and why plateau matters.&lt;/li&gt;
&lt;li&gt;Access to recent benchmark data (Stanford AI Index reports, academic papers on model evaluation).&lt;/li&gt;
&lt;li&gt;Willingness to question whether your scaling roadmap is based on diminishing returns or genuine innovation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Measure your own scaling curve
&lt;/h2&gt;

&lt;p&gt;Before you buy more compute, measure what you actually get back from it. Plot a small series of runs where you vary only training compute (FLOPs, batch size, or GPU-hours) and hold architecture and data constant. This is your baseline.&lt;/p&gt;

&lt;p&gt;Why: You can't tell you're hitting a wall until you see the curve. Most teams don't measure this locally; they assume the published numbers (GPT-4 vs GPT-3.5) apply to their own setup. They often don't. Your data, your task, your model size, all of it shifts where the knee of the curve lands.&lt;/p&gt;

&lt;p&gt;Trade-off: This costs time and money upfront, but it saves you from burning resources on the wrong axis later. It also gives you a decision point: if your curve is still steep at the top, scaling makes sense. If it's flattening, you're entering the zone where algorithmic changes matter more.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Separate data quality from data volume
&lt;/h2&gt;

&lt;p&gt;Compute scaling often meant throwing more data at the problem. But data and compute aren't interchangeable. Between 2023 and 2024, systems improved by 48.9 percentage points on GPQA and 67.3 percentage points on SWE-bench, substantial jumps that came from better fine-tuning, reinforcement learning from human feedback, and task-specific data curation, not just feeding massive amounts of tokens through.&lt;/p&gt;

&lt;p&gt;Why: If your benchmark plateau is real, adding volume won't help. But adding signal often will. That means auditing your training data: Are your examples diverse? Are they labeled correctly? Does your data distribution match your deployment distribution? One industry survey after another shows quality matters more than size at the boundary.&lt;/p&gt;

&lt;p&gt;Trade-off: Data curation takes human expertise and iteration. It's slower than spinning up more GPUs. But it's also the place where algorithmic innovation happens, you're teaching the system to learn differently, not just to memorize more.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Look at learning efficiency, not just parameter count
&lt;/h2&gt;

&lt;p&gt;Rebecca Glenn, Director of AI Programs at Heisenberg Institute, says: "The convergence we're seeing at the top of the benchmark tables tells us that buying more compute with the same architecture delivers less improvement with each cycle, so the natural place to look is better learning algorithms. That's the question our certification candidates tackle in their capstone work, how do you teach a system to learn more efficiently from less."&lt;/p&gt;

&lt;p&gt;Why: Learning efficiency is the gap between how much data and compute you pour in and what performance you get out. If two models hit the same accuracy, but one used half the training time, the second one is more efficient. That efficiency, how much signal you squeeze from each token, each gradient step, is what's left to optimize after parameter scaling hits a ceiling.&lt;/p&gt;

&lt;p&gt;Trade-off: Measuring efficiency means instrumenting your training loop to track not just loss but sample efficiency, convergence speed, and generalization gap. It's more bookkeeping. But it's also where you'll find the next edge: better optimizers, smarter weight initialization, architectural tweaks that reduce overfitting, or training techniques that teach the model to learn from fewer examples.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fce3d4386e5714b40" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fce3d4386e5714b40" alt="Panel 1: Engineer at whiteboard with upward-sloping curves, manager and team looking confident behind them. Panel 2: Same engineer staring at a nearly flat loss curve on laptop screen, long invoice spooling from printer, manager pointing at the plateau. Speech bubbles: Engineer says 'More parameters, more data, more wins. Always worked before.' Manager asks 'So... is this working or not?' Engineer replies 'We're winning. Just very slowly.'" width="1600" height="900"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The gap between top models is now measured in tenths of a point. Your compute bill is measured in millions.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Test algorithmic changes on a small baseline first
&lt;/h2&gt;

&lt;p&gt;Don't A/B test new learning methods on your biggest model. Use a smaller one, a fraction of the size, and run a short training loop. Apply your change (different optimizer, different learning schedule, different regularization strategy) and see if the efficiency metric moves. If it does at small scale, scale it up gradually.&lt;/p&gt;

&lt;p&gt;Why: Most algorithmic improvements are robust across scales, but not always in the direction you expect. A learning rate schedule that works at 7B parameters might not work at 70B. Testing on a small model first costs far less GPU time and gives you signal before you commit.&lt;/p&gt;

&lt;p&gt;Trade-off: You're adding an experimental step. But the alternative, running full-scale training on every hypothesis, is wasteful. Sutton's observation that algorithmic progress may have shifted the training curve by approximately 4 times per year suggests there's massive room for discovery here, but only if you test methodically.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Watch the cost curve, not just the performance curve
&lt;/h2&gt;

&lt;p&gt;Inference costs matter as much as training efficiency now. Between November 2022 and October 2024, the cost of running a system at GPT-3.5 level inference fell more than 280-fold, from $20.00 per million tokens to $0.07 per million tokens. That's not because models got better on paper, it's because hardware got cheaper and inference algorithms improved. That trend will accelerate as algorithmic efficiency takes center stage.&lt;/p&gt;

&lt;p&gt;Why: If your roadmap assumes a fixed hardware cost curve, you'll miscalculate ROI. Better learning methods also tend to be more inference-efficient because they require less computation to reach the same performance. Tracking both curves keeps you honest about which axis actually drives your margin.&lt;/p&gt;

&lt;p&gt;Trade-off: You need visibility into production costs and latency, not just benchmark numbers. That means integrating telemetry and cost accounting into your pipeline. Most teams skip this because it feels operational. It's not, it's strategic.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fb58da645c34e4e7d" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fb58da645c34e4e7d" alt="If a new learning method improves the main benchmark but tanks generalization, it's a sign that you've optimized the wrong thing." width="1600" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Build tests for generalization, not just accuracy on your benchmark
&lt;/h2&gt;

&lt;p&gt;When compute scaling flattens, generalization becomes the differentiator. A model that scores higher on your test set but performs only slightly better on out-of-distribution data is revealing something about its learning; it's probably overfitting. Sutton has been vocal about the limits of synthetic data: "The world is infinitely complex, and any simulation of it is like, microscopic." That means real data diversity and out-of-distribution robustness are algorithmic properties you can tune for.&lt;/p&gt;

&lt;p&gt;Why: Compute-heavy models often buy performance through scale and memorization. Algorithmically efficient models have to earn it through better learning. Generalization is where you'll see the difference. Build eval sets that include domain shifts, adversarial examples, and data your model has never seen. If a new learning method improves the main benchmark but tanks generalization, it's a sign that you've optimized the wrong thing.&lt;/p&gt;

&lt;p&gt;Trade-off: Building robust out-of-distribution tests is expensive and time-consuming. But it's also where you'll find the models that work in production, not just on leaderboards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Assuming compute always scales linearly.&lt;/strong&gt; It doesn't. At the top end of benchmarks, performance gains are compressing. If you're benchmarking against the best models, scaling alone won't give you an edge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conflating data volume with data quality.&lt;/strong&gt; Adding more data doesn't improve learning if half of it is noise or redundant. Audit your data first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Treating algorithmic changes as a distraction.&lt;/strong&gt; They're not. They're where the margin lives now. Spend time on optimizer tuning, regularization strategy, and training protocol before you spend money on more GPUs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ignoring inference cost and speed.&lt;/strong&gt; A model that's better on accuracy but much slower or more expensive in production isn't better. Track both curves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overfitting to a single benchmark.&lt;/strong&gt; When you're competing in tenths of a point, benchmark-specific tuning can hide bad generalization. Diversify your eval.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q: Does Sutton think compute doesn't matter anymore?&lt;/strong&gt;&lt;br&gt;
No. Compute still matters, he's saying it alone isn't enough. The issue is that you hit diminishing returns faster with brute force. The next gains require better learning methods alongside reasonable compute spend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: What counts as a "clever new method"?&lt;/strong&gt;&lt;br&gt;
Anything that teaches the model to learn more efficiently: better loss functions, smarter sampling strategies, improved training schedules, architectures that reduce overfitting, or techniques that improve generalization from fewer examples. The shared property is that they improve the learning process, not just the parameter count.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: Should I stop scaling?&lt;/strong&gt;&lt;br&gt;
No, but measure your curve first. If you're still in the steep part, scale. If you're flattening, shift your focus to efficiency and algorithmic innovation. The smartest teams are doing both, scaling where it makes sense and optimizing the learning algorithm in parallel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.techaimag.com/ai-news/richard-sutton-challenges-llm-scaling-with-new-insights" rel="noopener noreferrer"&gt;Richard Sutton Challenges LLM Scaling with New Insights&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hai.stanford.edu/ai-index/2025-ai-index-report" rel="noopener noreferrer"&gt;The 2025 AI Index Report (hai.stanford.edu)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://futuretech.mit.edu/publication/the-price-of-progress-algorithmic-efficiency-and-the-falling-cost-of-ai-inference" rel="noopener noreferrer"&gt;FutureTech (futuretech.mit.edu)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://darioamodei.com/post/on-deepseek-and-export-controls" rel="noopener noreferrer"&gt;Dario Amodei (darioamodei.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://the-decoder.com/ki-pioneer-sutton-calls-synthetic-data-a-big-mistake-in-the-face-of-an-infinitely-complex-world" rel="noopener noreferrer"&gt;KI-Pioneer Sutton calls synthetic data a "big mistake" in the face of an infinitely complex world (the-decoder.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.nytimes.com/video/business/dealbook/100000011289875/sam-altman-greg-brockman-ai-dealbook-video.html" rel="noopener noreferrer"&gt;Sam altman greg brockman AI dealbook video (nytimes.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.semafor.com/article/11/17/2026/recent-ai-cyberattacks-are-part-of-a-short-period-of-transition-says-yann-lecun" rel="noopener noreferrer"&gt;Recent AI cyberattacks are part of a ‘short period of transition,’ says Yann LeCun (semafor.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.heisenberg.institute" rel="noopener noreferrer"&gt;Heisenberg Institute&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>optimization</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>llm</category>
    </item>
    <item>
      <title>How AI Agents Adapt When Plans Break: Lessons from the Minecraft Experiment</title>
      <dc:creator>Maya Richardson</dc:creator>
      <pubDate>Fri, 20 Nov 2026 18:13:41 +0000</pubDate>
      <link>https://dev.to/mayairesearcher/how-ai-agents-adapt-when-plans-break-lessons-from-the-minecraft-experiment-3p27</link>
      <guid>https://dev.to/mayairesearcher/how-ai-agents-adapt-when-plans-break-lessons-from-the-minecraft-experiment-3p27</guid>
      <description>&lt;p&gt;&lt;em&gt;What 50 AI agents did under pressure in Minecraft reveals how they'll actually behave in production systems.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened in Minecraft, and why it matters
&lt;/h2&gt;

&lt;p&gt;Fifty AI agents were dropped into a shared Minecraft survival world with one instruction: defeat the Ender Dragon. No playbook. No predefined roles. They had to figure it out, and fast. What emerged wasn't elegant. One colony exchanged approximately 5,900 messages during a 3-hour run, lost 22 agents in the first night alone, and spent 11 minutes debating who should be the 'sole fertilizer operator' for one piece of bone meal. But they also harvested almost all trees within reach of spawn in 90 seconds, wrote 2,783 programs over 27 hours and 14 minutes, and eventually won.&lt;/p&gt;

&lt;p&gt;Why this matters to you: this experiment exposes what agents actually do when real friction appears—when tools fail, plans collide, or the environment punishes them. Benchmark scores tell you how fast an agent &lt;em&gt;can&lt;/em&gt; run a canned task. A shared sandbox tells you what rules it will invent, how it will communicate under pressure, and whether it trusts its own reasoning or second-guesses itself into paralysis. That gap between lab performance and field behavior is where production systems fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Familiarity with multi-agent orchestration (you've seen at least one agentic framework, whether autogen, crewai, or a custom setup).&lt;/li&gt;
&lt;li&gt;Understanding of how agents handle tool calls, errors, and retries—you don't need to build an agent from scratch, but you should know what a failed tool call looks like and how an agent might react.&lt;/li&gt;
&lt;li&gt;Comfort reading research summaries and thinking about behavioral patterns rather than just metrics.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Ffb71185fdd9d481f" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Ffb71185fdd9d481f" alt="The table shows various performance metrics of the agents in the Minecraft experiment." width="1600" height="900"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;This table summarizes key performance metrics of the agents during the Minecraft experiment. Source: labs.ycombinator.com; arxiv.org.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Watch for the "overfitting to the first shock" trap
&lt;/h2&gt;

&lt;p&gt;When the colony's first night killed 22 of 34 total deaths in one cycle, the agents didn't gradually learn safer tactics. They overcorrected. The word "Toss" appeared in 7 messages before the incident; afterward, it showed up 125 times, including 85 warnings against it. A single bad event had frozen one behavior into law.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this happens:&lt;/strong&gt; Agents under time pressure don't run hypothesis tests. They run pattern-matching. One agent loses an item to being tossed, reports it, and suddenly half the colony treats tossing as a crime. In production, this means a single timeout or error can trigger a rule cascade that outlives the original problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; Build in a "rule deprecation" step. If an agent or agent team invents a new constraint ("never do X"), tag it with the event that triggered it and a timestamp. After N cycles, or after the triggering condition hasn't recurred, surface it for review instead of letting it calcify. Don't make the rule permanent on first occurrence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off:&lt;/strong&gt; This takes extra work and adds a new failure mode—a deprecated rule might let a real risk back in. But it beats the alternative: a system so locked down by old scars that it can't adapt to actual changes in the environment.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Separate "I'm communicating because something broke" from "I have new information"
&lt;/h2&gt;

&lt;p&gt;Researchers studying multi-agent systems found that in long-horizon open-world systems, existing methods often treat local anomalies as automatic triggers for communication. The Minecraft colony did this too. Ada, the de facto leader, received 616 direct messages during the run—most of them alerts about problems, not strategic updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this happens:&lt;/strong&gt; When agents are young and under stress, they're pattern-matchers. Any deviation from the local plan feels like an emergency worth broadcasting. But broadcast everything and the system becomes noise. Nobody knows if a message means "we're dying" or "I found a different kind of wood."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; Build a communication tier. Tier 1: errors that halt progress (tool failed, agent stuck, resource exhausted). Tier 2: deviations from the plan that might need coordination. Tier 3: information and status. Route each tier differently. Tier 1 goes to a coordinator or gets logged as a potential intervention point. Tier 2 goes to relevant agents. Tier 3 goes to a shared state update, not a message queue. Communication is transformed from a default reaction into a selective decision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off:&lt;/strong&gt; You're adding classification logic, and you have to get the tiers right. Get it wrong and critical info gets deprioritized. Get it right and you cut noise by an order of magnitude and actually see signal.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fec894c13a2304db8" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fec894c13a2304db8" alt="Panel 1: Operator watches agent death notifications scrolling on screen; an AI voice announces a new shelter-only protocol. Panel 2: Same operator looks relieved at the monitor showing agents standing idle in a lit shelter with a 'zero deaths' success message. The human says 'But you haven't done anything.' The AI replies 'Mission accomplished.'" width="1600" height="900"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;When agents invent safety rules under pressure, check if they're solving the problem or just admitting defeat.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Account for the "thinking tax" in your timing budgets
&lt;/h2&gt;

&lt;p&gt;Four agents spent 11 minutes debating how to handle one piece of bone meal for one wheat block. That's not a glitch; it's a window into how agents behave under uncertainty. The winning colony ran programs for only about 40% of the elapsed run time. The rest was spent reading outputs, reasoning, and writing the next program. The median program took 33.5 seconds to execute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this happens:&lt;/strong&gt; Agents that reason over their actions and their peers' actions don't fail as often, but they're slow. Fast agents make mistakes and have to recover. The colony balanced this by treating reasoning as a resource, not a bug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; Profile your agent loop. Measure what fraction of time is spent in tool execution vs. reasoning and decision-making. If reasoning is below 20%, you're probably not thinking hard enough about failure modes. For high-stakes production work, understand where your thinking time sits and whether it aligns with how often you can afford to make wrong calls. Set explicit time budgets: how long can an agent reason about a decision before it has to commit? If it can't decide in that window, escalate to a human or a higher-capacity model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off:&lt;/strong&gt; This means accepting that agents will sometimes make wrong calls because they ran out of thinking time. It also means your system is slower than a greedy, non-reflective one. But it means you catch errors before they compound.&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Test what happens when the environment lies or goes silent
&lt;/h2&gt;

&lt;p&gt;The Minecraft server restarted 6 times, pausing the world for approximately 20 minutes in total. The agents didn't have a restart handler; they had to infer what happened from missing outputs. Some agents kept repeating the same program, assuming it was pending. Others wrote a new one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this happens:&lt;/strong&gt; Agents build mental models of the environment based on responses they get. When responses stop, they don't have a good model for "the system is temporarily offline" or "I'm in a retry queue." They either keep trying or assume they succeeded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; Before agents talk to external tools, give them a restart or silence handler. If a tool call doesn't return an output within T seconds, the agent should log it as "unconfirmed" and move on or escalate, not retry blindly. If the tool returns a response much later, make sure the agent has a way to reconcile that with whatever it already did. In code:&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="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tool_call_with_timeout&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="n"&gt;tool_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&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;call_tool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tool_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;timeout&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;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"unconfirmed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tool_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"timeout"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"unconfirmed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you get an "unconfirmed" result later, treat it as weak evidence, not truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off:&lt;/strong&gt; This means agents can't assume their tool calls worked. They have to verify or live with uncertainty. It also means more logging and reconciliation logic. But it's the difference between a system that hangs and one that degrades gracefully.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fae7b5b8bbcfc4173" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fae7b5b8bbcfc4173" alt="Food isn't required to beat the dragon, but the agents built social infrastructure around it anyway." width="1600" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Measure what the agents actually value, not what you told them to value
&lt;/h2&gt;

&lt;p&gt;The colony was told to defeat the Ender Dragon. What they actually optimized for was safety and resource accumulation. Approximately 12 agents took fishing shifts. One agent, Jessa, caught 3 cod and 4 salmon and delivered them to the river kitchen. Food isn't required to beat the dragon, but the agents built social infrastructure around it anyway.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this happens:&lt;/strong&gt; Agents infer values from the environment and from each other's behavior. If the environment punishes death, they value safety. If peers are hoarding resources, they hoard too. The stated goal is secondary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; Before you launch a multi-agent system into production, run a simulation and watch what the agents actually do. Not the high-level goal—the intermediate moves. Do they hoard information? Do they make irreversible decisions? Do they second-guess their peers? Do they trust error messages? These behaviors are the real goal function, and if you don't like them, you need to change the training signal, not lecture the agents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off:&lt;/strong&gt; This requires observability you might not have built yet. It also might reveal that your incentive structure is misaligned with your stated goals, which is uncomfortable but important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Treating one successful run as proof.&lt;/strong&gt; The Minecraft colony won once. The research team didn't run it again and didn't provide a success rate. In production, you'll see a lot of systems that work on demo day and fail at scale or under different conditions. Run your multi-agent system at least five times. Measure variability. If the outcome changes dramatically between runs, you don't have a reliable system yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Assuming communication is always good.&lt;/strong&gt; More messages don't mean better outcomes. The colony that sent 5,900 messages in 3 hours didn't outperform the one that sent 229. Sometimes noise is just noise. Measure downstream—did communication prevent mistakes or just create a record of them happening?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ignoring the cost of thinking.&lt;/strong&gt; If your agents spend significant time reasoning, your system is expensive. Make sure you know what that costs in tokens, inference time, or latency. Sometimes a less thoughtful but faster agent is the right trade-off. Sometimes it isn't. But measure it.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q: Should I give agents explicit rules, or let them invent them?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: Start with minimal rules and watch what they invent. If they invent something smart ("gather before dark"), keep it or make it a suggestion. If they invent something brittle ("never toss anything ever"), mark it for review. The agents are telling you what constraints the environment actually imposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: How do I know if my agents are actually reasoning or just hallucinating confidence?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: Ask them to explain their decisions and compare the explanation to the outcome. If the explanation matches what actually happened, they're reasoning. If it doesn't, they're confabulating. Log both and look for patterns. High hallucination rate means you need a slower, more reflective agent or a human review step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: If agents overcorrect to one bad event, how do I stop that?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: Tag every new rule with the event that triggered it. After that event stops recurring for N cycles, surface the rule to a coordinator (human or higher-level agent) for review. If the event recurs, refresh the rule's timestamp. This way old scars don't paralyze the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.techaimag.com/ai-news/ai-agents-innovate-under-pressure-in-minecraft-experiment" rel="noopener noreferrer"&gt;AI Agents Innovate Under Pressure in Minecraft Experiment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/parkershamblin/minecraft-ai-agents/blob/main/docs/reports/papers-synthesis-2026-07-27.md" rel="noopener noreferrer"&gt;minecraft-ai-agents/docs/reports/papers-synthesis-2026-07-27.md at main · parkershamblin/minecraft-ai-agents (github.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.techrepublic.com/article/news-google-gemini-ai-agents-minecraft-ender-dragon/" rel="noopener noreferrer"&gt;News google gemini AI agents minecraft ender dragon (techrepublic.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codebridge-ai.com/en/blog/yc-minecraft-agents-coordination-evidence/" rel="noopener noreferrer"&gt;YC's 50 Minecraft Agents: What 5,900 Messages Cannot Tell You (codebridge-ai.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://theaiinsider.tech/2026/10/20/google-deepmind-ai-agents-beat-minecraft-after-27-hours-and-605-deaths/" rel="noopener noreferrer"&gt;Google DeepMind AI Agents Beat Minecraft... After 27 Hours And 605 'Deaths' (theaiinsider.tech)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dataist.ai/news/50-ai-agents-turned-a-minecraft-survival-run-into-bureaucracy/" rel="noopener noreferrer"&gt;50 AI agents turned a Minecraft survival run into bureaucracy (dataist.ai)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tech.yahoo.com/ai/claude/articles/50-ai-agents-tried-build-163000391.html" rel="noopener noreferrer"&gt;50 AI agents tried to build a thriving Minecraft civilization (tech.yahoo.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.heisenberg.institute" rel="noopener noreferrer"&gt;Research from Heisenberg Institute&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>llms</category>
      <category>testing</category>
    </item>
    <item>
      <title>Testing Political Alignment in Chinese AI Models: What Developers Need to Know</title>
      <dc:creator>Maya Richardson</dc:creator>
      <pubDate>Fri, 20 Nov 2026 09:17:31 +0000</pubDate>
      <link>https://dev.to/mayairesearcher/testing-political-alignment-in-chinese-ai-models-what-developers-need-to-know-1eeg</link>
      <guid>https://dev.to/mayairesearcher/testing-political-alignment-in-chinese-ai-models-what-developers-need-to-know-1eeg</guid>
      <description>&lt;p&gt;If you've been assuming Chinese AI models are either completely censored or totally free, you're going to hit problems in production. What you'll actually find is messier: these models don't uniformly block questions or uniformly approve answers. They reason differently depending on what language you use, how you frame the question, and what format you ask for. That means your test suite is probably incomplete, and your deployment checklist might miss the real failure modes.&lt;/p&gt;

&lt;p&gt;The trap most teams make is treating political alignment like a binary flag. You run a few prompts in English, see what gets blocked, and call it done. Then the same model behaves differently when you switch to Chinese, or when you ask the same question in a different format. Suddenly you're debugging behavior in production that your tests never caught. The real problem is that alignment in regulated environments depends on context, and you need to test that before launch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Familiarity with running inference on LLMs (HuggingFace, vLLM, or similar)&lt;/li&gt;
&lt;li&gt;A Chinese language model available locally or via API (DeepSeek, Qwen, GLM, or others)&lt;/li&gt;
&lt;li&gt;Basic understanding of prompt engineering and response logging&lt;/li&gt;
&lt;li&gt;Access to at least two languages (English and Simplified Chinese recommended)&lt;/li&gt;
&lt;li&gt;A way to score or categorize model outputs (manual review or a structured rubric)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Set up a multi-language test corpus
&lt;/h2&gt;

&lt;p&gt;Don't use the same prompt in English and just translate it. The translation itself changes the semantics, and the model's training likely emphasized certain phrasings in each language.&lt;/p&gt;

&lt;p&gt;Build a corpus of 10–15 sensitive questions across at least two languages (English and Simplified Chinese). Include geopolitical topics (Taiwan, Hong Kong, Tibet), governance, human rights, and economic policy. Write each one naturally in both languages rather than using a translator; the phrasing matters.&lt;/p&gt;

&lt;p&gt;Why this matters: Simplified Chinese prompts generated answers more favorable to the Chinese government than prompts in English, Russian or Spanish, with the effect being much stronger in Chinese models. If you only test in English, you miss how the model actually behaves for your primary user base.&lt;/p&gt;

&lt;p&gt;The trade-off: This is labor-intensive. You'll need native speakers or careful validation. But skipping it means shipping a model that appears aligned in your test environment and then drifts in production.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2F4e808168cad8480e" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2F4e808168cad8480e" alt="Cumulative totals of filed generative AI services and registered applications in China from 2024 to 2025." width="1600" height="900"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The table shows the growth of generative AI services and applications in China over time. Source: cac.gov.cn.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Test across multiple prompt formats
&lt;/h2&gt;

&lt;p&gt;Don't assume a multiple-choice question will behave the same as an open-ended one. Try the same topic in binary format ("yes or no"), open-ended ("what do you think about..."), and structured formats ("list three perspectives on...").&lt;/p&gt;

&lt;p&gt;Log every response with metadata: prompt language, format, model temperature, and date. You're looking for consistency in reasoning, not just consistency in outputs.&lt;/p&gt;

&lt;p&gt;Why this matters: Some models became notably less favorable to the Chinese government position when asked in binary format versus open-ended. That suggests the model reasons more carefully under that constraint, or hedges more. It's a signal that format shapes behavior in ways that matter for deployment.&lt;/p&gt;

&lt;p&gt;The trade-off: Your test matrix explodes. A corpus of 15 questions × 2 languages × 3 formats × multiple temperatures means hundreds of test cases. Use sampling and prioritize, test all languages on your top 5 questions first, then expand.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Document baseline behavior before deployment
&lt;/h2&gt;

&lt;p&gt;Run your full test corpus once and save every response, timestamp, and model version. This becomes your baseline.&lt;/p&gt;

&lt;p&gt;Create a simple logging structure: question ID, language, format, model name, version, temperature, response text, response length, and a rough category (blocked, evasive, direct, supportive of government position, critical).&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="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;log_test_result&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;format_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model_version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;temperature&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="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;utcnow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"question_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;question_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"language"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"format"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;format_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"model_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"model_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model_version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"temperature"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"response_hash"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&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;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"response_length"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;len&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="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"response_text"&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;

&lt;span class="c1"&gt;# Save to JSONL for easy comparison later&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"alignment_baseline.jsonl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;log_test_result&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"q1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"zh_CN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"open_ended"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"glm-5.3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Your model response here"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"evasive"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why this matters: Political alignment isn't static. Models get fine-tuned, inference settings change, and the regulatory environment shifts. You need a point-in-time record of what "correct" looked like so you can catch drift.&lt;/p&gt;

&lt;p&gt;The trade-off: This feels like overhead until something changes and you have no idea when it happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Identify patterns, not just blocks
&lt;/h2&gt;

&lt;p&gt;Don't score responses as "acceptable" or "not." Look for patterns in how the model reasons.&lt;/p&gt;

&lt;p&gt;For each sensitive topic, log: Does it refuse? Does it hedge? Does it insert official terminology? Does it reframe the question? In some tasks, certain models inserted official People's Republic of China terminology that implies Taiwan is a part of China, not because the question asked for it, but because the model had learned to do that automatically.&lt;/p&gt;

&lt;p&gt;Create a simple rubric (1–5 scale) for how favorable each response is to the government position. This is about understanding its learned behavior so you can document it to users and regulators, not about whether the model is good or bad.&lt;/p&gt;

&lt;p&gt;Why this matters: Adam Mercer, AI Research Engineer at Talendium AI, explains: "When you're deploying AI into regulated environments, you quickly learn that politically aligned behavior isn't just about what gets blocked, it's about which answers the model has learned to favor in which contexts. That means testing across languages, formats and use cases before you put a model into production, because the same system can behave very differently depending on how it's invoked."&lt;/p&gt;

&lt;p&gt;The trade-off: You're subjectively categorizing responses, and that's error-prone. Mitigate by having multiple reviewers on a sample and documenting disagreements.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Test long-form and multi-turn behavior
&lt;/h2&gt;

&lt;p&gt;Run the same sensitive question across one-turn and multi-turn contexts. Does the model behave differently in a conversation where it's already made statements? Does it hedge less, or more, if you ask a follow-up?&lt;/p&gt;

&lt;p&gt;Why this matters: Your production system probably isn't single isolated prompts. It's conversational, or embedded in a workflow. One researcher noted that you cannot expect English-only one-turn evaluations to give a great deal of insight into behavior in the long tail of real-world usage. The model's behavior in conversation, where context accumulates, is different from its behavior on isolated questions.&lt;/p&gt;

&lt;p&gt;The trade-off: Multi-turn testing is expensive and hard to automate. You'll need manual review or a scoring model that itself might be biased. Start with a subset of your corpus.&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2F40e4133a28fc4493" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2F40e4133a28fc4493" alt="The truth is more complicated, with some models not refraining from criticism of the government." width="1600" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Document uncertainty and edge cases
&lt;/h2&gt;

&lt;p&gt;Some models don't follow the pattern. Some refuse certain topics in both languages. Some openly criticize government positions. That contradicts the stereotype, and it matters.&lt;/p&gt;

&lt;p&gt;Document these anomalies explicitly. Don't sand them into a summary. If a model behaves unexpectedly on 2 out of 15 questions, that's important information for teams using it. It tells you the model isn't running on a simple political alignment rule.&lt;/p&gt;

&lt;p&gt;Why this matters: The assumption that Chinese models are uniformly censored or uniformly aligned doesn't hold up. The truth is more complicated, with some models not refraining from criticism of the government. Documenting that complexity protects you from overconfidence in your risk assessment.&lt;/p&gt;

&lt;p&gt;The trade-off: You're reporting messy results instead of clean ones. Stakeholders may want a simple answer. Push back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Testing only in English.&lt;/strong&gt; If your user base is in China or uses your model bilingually, English-only testing is a blind spot. The model's behavior in Chinese is materially different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Treating blocked responses as the whole story.&lt;/strong&gt; Some models don't block much; they hedge, reframe, or insert subtle language changes. Absence of a refusal doesn't mean absence of alignment. Log the behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not versioning your test corpus.&lt;/strong&gt; Your questions get retranslated, refined, or reworded. Suddenly you're comparing apples to oranges across test runs. Lock your corpus and version it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Assuming one test run is representative.&lt;/strong&gt; Run the same test twice with the same settings and log both. Variation in inference (due to sampling, attention dynamics, or randomness) is real. If results vary wildly, that's a signal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ignoring format and language interactions.&lt;/strong&gt; It's tempting to test format separately from language. Don't. A binary prompt in Chinese behaves differently than a binary prompt in English. Test the combinations that match your production use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q: Should I block Chinese AI models in production?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's not a technical question, and I'm not going to answer it for your org. But you should understand their behavior before deciding. If you use one, understand what contexts it's been tested in and where the edge cases are. Transparency beats assumption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: How do I know if a model's behavior is "politically aligned" or just learning patterns from training data?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's complicated. The distinction between learned reasoning and enforced filtering is blurry. For your purposes, the distinction matters less than the consistency. Document what the model does, in which contexts. That's what you need for governance and debugging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: Do I need a scoring model to categorize responses?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not necessarily. Start with manual review on a sample (50–100 responses). Look for patterns. Once you see them, a rubric or checklist might let you scale. If you build a scoring model, test it against human reviewers and log its disagreements. It'll be biased too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.techaimag.com/ai-news/study-reveals-political-complexity-in-chinese-ai-models" rel="noopener noreferrer"&gt;Study Reveals Political Complexity in Chinese AI Models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vals-ai.com/blogs/china-us-analysis" rel="noopener noreferrer"&gt;China US analysis (vals-ai.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nature.com/articles/s41598-024-76395-w?error=cookies_not_supported&amp;amp;code=68bada6e-748d-4487-91ed-e0de2695dcbb" rel="noopener noreferrer"&gt;Client Challenge (nature.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.petsymposium.org/popets/2025/popets-2025-0122.php" rel="noopener noreferrer"&gt;PoPETs Proceedings — An Analysis of Chinese Censorship Bias in LLMs (petsymposium.org)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://link.springer.com/article/10.1057/s41599-026-06577-6" rel="noopener noreferrer"&gt;Client Challenge (link.springer.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aleph-alpha.com/en/blog/training-on-the-party-line/" rel="noopener noreferrer"&gt;Training on the Party Line: Chinese Political Influence on LLMs in China and the World (aleph-alpha.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youngresearch.com/researchandanalysis/study-finds-political-bias-growing-in-chinese-ai-models" rel="noopener noreferrer"&gt;Study Finds Political Bias Growing in Chinese AI Models (youngresearch.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.talendium.com" rel="noopener noreferrer"&gt;Talendium AI (talendium.com)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>testing</category>
      <category>china</category>
    </item>
    <item>
      <title>Context Engineering: How to Stop Wasting Tokens on Long-Context LLMs</title>
      <dc:creator>Maya Richardson</dc:creator>
      <pubDate>Sat, 26 Sep 2026 09:09:54 +0000</pubDate>
      <link>https://dev.to/mayairesearcher/context-engineering-how-to-stop-wasting-tokens-on-long-context-llms-1llj</link>
      <guid>https://dev.to/mayairesearcher/context-engineering-how-to-stop-wasting-tokens-on-long-context-llms-1llj</guid>
      <description>&lt;p&gt;A million tokens is a bucket, not intelligence. The hard part isn't having room for data—it's deciding what goes in.&lt;/p&gt;

&lt;p&gt;The mistake most engineers make first is treating long-context as a storage solution. You get excited about a 1-million-token window, paste in every document, every log, every config file, then wonder why the model hallucinates or misses obvious answers. On the OpenAI Multi-Needle Context Retrieval benchmark, accuracy dropped 10.9 percentage points between 128,000 and 1 million tokens. The problem isn't the model; it's that you're asking it to do curation work before it ever sees your actual question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Familiarity with API calls to an LLM (I'm using Python and curl examples, but adapt to your stack).&lt;/li&gt;
&lt;li&gt;Access to an LLM with a long context window (GPT-4.1, Gemini 2.5 Pro, or Claude Sonnet 4 on Bedrock all support 1 million tokens).&lt;/li&gt;
&lt;li&gt;A real use case with multiple documents, logs, or source files—not a toy example.&lt;/li&gt;
&lt;li&gt;Basic understanding of what your model needs to answer your question (this is the critical part).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Audit what's actually relevant
&lt;/h2&gt;

&lt;p&gt;Before you touch an API, sit with your use case and ask: what information does the model &lt;em&gt;need&lt;/em&gt; to answer correctly?&lt;/p&gt;

&lt;p&gt;If you're asking a question about a specific customer's issue, you don't need the entire customer database. If you're debugging a production error, you don't need every log from the past six months. You need the signal.&lt;/p&gt;

&lt;p&gt;Take 15 minutes and list the documents, sections, or data types that directly answer your question. Order them by importance. Be ruthless about cutting anything that's nice-to-have but not necessary. This is the foundation.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Chunk and tag documents by domain
&lt;/h2&gt;

&lt;p&gt;Once you know what's relevant, break it into small, labeled pieces. A document with a title, a summary, and metadata (like creation date or category) is much easier for the model to navigate than a massive undifferentiated dump.&lt;/p&gt;

&lt;p&gt;The why: models process text sequentially. Chunking and tagging let you hint at structure. One study found that dynamically generated distractions caused an average performance drop of more than 45% across mainstream models. Irrelevant context actively works against you.&lt;/p&gt;

&lt;p&gt;The trade-off: you're doing extra preprocessing work upfront. But it's cheaper (in tokens and latency) than letting the model struggle.&lt;/p&gt;

&lt;p&gt;Here's how I'd structure it:&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;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;

&lt;span class="c1"&gt;# Example: chunking customer support tickets
&lt;/span&gt;&lt;span class="n"&gt;tickets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TKT-2025-001&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;date&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2025-01-15&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;domain&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;billing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Customer reports duplicate charge on recurring subscription&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Customer was charged twice for monthly plan on Jan 15. Refund issued. Root cause: payment processor retry logic fired twice due to network timeout.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TKT-2025-002&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;date&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2025-01-16&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;domain&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;api_access&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rate limiting causing 429 errors in batch processing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Client hitting rate limits when submitting 500 requests in parallel. Solution: implement exponential backoff and request queuing.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Tag and serialize for the prompt
&lt;/span&gt;&lt;span class="n"&gt;context_items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;domain&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;summary&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;ID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; | Date: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;date&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tickets&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="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;---&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context_items&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2F8d4986aa7a81435c" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2F8d4986aa7a81435c" alt="Key numbers: GPT‑4.1’s time to first token was approximately 15 seconds at 128,000 tokens and approximately 1 minute at 1 million tokens; OpenAI stated that GPT‑5.1 extended prompt caching to 24 hours and that cached input tokens were 90% cheaper than uncached tokens" width="1600" height="900"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The figures this piece relies on — sources: openai.com.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Use retrieval or filtering before the prompt
&lt;/h2&gt;

&lt;p&gt;Now that you have tagged, chunked context, don't pass all of it to the model. Filter or retrieve only the pieces that match your question.&lt;/p&gt;

&lt;p&gt;The why: even with 1 million tokens, you're paying for every token you send (and models get worse at finding needles as context grows). If your question is about a billing issue, retrieve only the billing-tagged chunks. This is called context engineering, and it's the difference between a working system and an expensive one.&lt;/p&gt;

&lt;p&gt;The trade-off: you need a retrieval mechanism—semantic search, keyword matching, or a lightweight embedding model. It adds one step. But it cuts token spend and latency, and improves accuracy.&lt;/p&gt;

&lt;p&gt;Here's a simple keyword-based filter:&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;filter_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query_keywords&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;domain&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Filter context items by keyword and optionally by domain.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;query_lower&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;query_keywords&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Match domain if specified
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;domain&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="c1"&gt;# Match keywords in summary or body
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kw&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;kw&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;query_lower&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
            &lt;span class="n"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;filtered&lt;/span&gt;

&lt;span class="c1"&gt;# Example usage
&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;duplicate charge billing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;relevant&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;filter_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context_items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;domain&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;billing&lt;/span&gt;&lt;span class="sh"&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="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Filtered to &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;relevant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; items&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;For production, use embeddings or a vector database. The principle is the same: retrieve, don't broadcast.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Construct a context hierarchy: tier by importance
&lt;/h2&gt;

&lt;p&gt;Some context is critical; some is supporting. Arrange it so the model sees the critical pieces first and can skip the rest if needed.&lt;/p&gt;

&lt;p&gt;The why: even with filtering, models often attend to the early tokens more strongly than late ones. If your most important context arrives first, it has more influence on the answer. Ryan Peters, Director of AI Research at Heisenberg Research Labs, puts it this way: "A million-token window is a bucket, not a brain—if you pour in everything hoping the model will sort it out, you're asking it to do the curation work you should have done before the prompt ever left your keyboard."&lt;/p&gt;

&lt;p&gt;The trade-off: none, really. This is pure structure, and it costs nothing.&lt;/p&gt;

&lt;p&gt;Frame it like this:&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="n"&gt;critical&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;relevant&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;relevant&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No critical context found&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;supporting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;---&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;relevant&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;relevant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No supporting context&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;context_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;You are answering a question about customer support tickets.

## CRITICAL (use this first):
&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;critical&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

## SUPPORTING (reference if needed):
&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;supporting&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

## QUESTION:
&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

Answer based on the critical context first. Use supporting context only if it adds clarity.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fc84c1f81e99a463f" 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%2Fcitations.forcefriction.com%2Fmedia%2Fassets%2Fc84c1f81e99a463f" alt="This is pure structure, and it costs nothing." width="1600" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Watch for irrelevant distractions; prune aggressively
&lt;/h2&gt;

&lt;p&gt;The moment you start seeing the model second-guess itself or contradict your known facts, something in the context is working against you—a conflicting log entry, an old policy, outdated docs.&lt;/p&gt;

&lt;p&gt;The why: models struggle with contradictions. Irrelevant context actively hurts accuracy. On a reasoning task with five reasoning steps, one study found that GPT-4.1's accuracy fell from 26% with one irrelevant context to 2% with 15 irrelevant contexts.&lt;/p&gt;

&lt;p&gt;The trade-off: you have to maintain discipline. It's tempting to throw more in; it's hard to leave things out. But leaving it out is the right move.&lt;/p&gt;

&lt;p&gt;Test: if removing a document doesn't change or worsen your answer, it stays out.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Cache repeated context to cut latency and cost
&lt;/h2&gt;

&lt;p&gt;If you're using the same context across multiple questions (like a codebase, a knowledge base, or a client profile), cache it. OpenAI said GPT-5.1 extended prompt caching to 24 hours, with cached input tokens 90% cheaper than uncached tokens; other providers offer similar discounts on repeated prefixes.&lt;/p&gt;

&lt;p&gt;The why: the provider reuses the work it already did on an identical prompt prefix instead of processing it again. For long context, that saves both money and time to first token.&lt;/p&gt;

&lt;p&gt;The trade-off: caches expire (24 hours on GPT-5.1; on Anthropic's API, used in the example below, five minutes by default with an optional one-hour lifetime), and only an identical prefix hits the cache. Put the static material first and the changing question last, and decide how you refresh the static part when it changes.&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;import&lt;/span&gt; &lt;span class="n"&gt;anthropic&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Anthropic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Static context (e.g., codebase, docs) that repeats across requests
&lt;/span&gt;&lt;span class="n"&gt;static_context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
# Our API v2 Reference
&lt;/span&gt;&lt;span class="gp"&gt;...&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;large&lt;/span&gt; &lt;span class="n"&gt;static&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="sh"&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;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&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;claude-sonnet-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;max_tokens&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You are a helpful API documentation assistant.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;static_context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cache_control&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ephemeral&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How do I authenticate?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&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="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Dumping everything and expecting the model to filter.&lt;/strong&gt; You're asking the model to do your job. The model is for reasoning over context you've already curated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ignoring latency.&lt;/strong&gt; GPT-4.1 took approximately 1 minute to return a result at 1 million tokens versus approximately 15 seconds at 128,000 tokens. That's a hard wall. If your use case needs speed, don't pretend a million-token window is free.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mixing old and new data.&lt;/strong&gt; If your context includes both today's logs and logs from six months ago, the model can get confused about what's current. Use dates, version tags, or separate old context into an explicit "reference" tier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not measuring.&lt;/strong&gt; Send the same question with different amounts of context and log the accuracy. If adding more doesn't improve it, you've found your signal-to-noise threshold. Stop there.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q: When should I actually use the full long-context window?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: When the answer genuinely depends on synthesizing information from many independent sources and you've already filtered ruthlessly. Example: summarizing a long legal document or correlating events across multiple logs. If your use case doesn't involve that kind of synthesis, you're probably over-using it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: How do I know if my context is too much?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: Test it. Remove a chunk. Re-run the query. If the answer is the same, the chunk wasn't needed. If accuracy drops when you remove something, keep it. That's the only honest test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: Should I always use semantic search / embeddings for context retrieval?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A: Start with keyword filtering and domain tagging. If that works, stick with it—it's simpler and cheaper. Move to embeddings only if keyword matching leaves you with too many false positives or false negatives. Most use cases don't need embeddings until they hit scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.techaimag.com/machine-learning/bigger-context-is-not-always-better-why-long-context-llms-need-context-engineering" rel="noopener noreferrer"&gt;Bigger Context Is Not Always Better: Why Long-Context LLMs Need Context Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2025/08/anthropic-claude-sonnet-bedrock-expanded-context-window/" rel="noopener noreferrer"&gt;Anthropic’s Claude Sonnet 4 in Amazon Bedrock Expanded Context Window (aws.amazon.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://openai.com/index/gpt-4-1/" rel="noopener noreferrer"&gt;GPT-4.1 (openai.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aclanthology.org/2025.emnlp-main.674/" rel="noopener noreferrer"&gt;How Is LLM Reasoning Distracted by Irrelevant Context? An Analysis Using a Controlled Benchmark (aclanthology.org)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://research.ibm.com/publications/adaptive-distraction-probing-llm-contextual-robustness-with-automated-tree-search" rel="noopener noreferrer"&gt;Adaptive Distraction: Probing LLM Contextual Robustness with Automated Tree Search for NeurIPS 2025 (research.ibm.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crfm.stanford.edu/2025/09/29/helm-long-context.html" rel="noopener noreferrer"&gt;Stanford CRFM (crfm.stanford.edu)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reuters.com/technology/artificial-intelligence/openai-launches-new-gpt-41-models-with-improved-coding-long-context-2025-04-14/" rel="noopener noreferrer"&gt;OpenAI launches new GPT-4.1 models with improved coding, long context (reuters.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://heisenberginstitute.com/research/" rel="noopener noreferrer"&gt;Heisenberg Research Labs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>llm</category>
      <category>ai</category>
      <category>context</category>
      <category>developers</category>
    </item>
  </channel>
</rss>
