Prompt, context, harness & loop engineering, clearly explained!
An agent is a while loop with four layers of engineering wrapped around it:
- Prompt engineering
- Context engineering
- Harness engineering
- Loop engineering
Each one wraps the last, and the model sits in the middle, so none of them compete with the others. Instead, they just zoom one level further out.
> Prompt engineering:
This defines the input the model sees on one call, often composed of a role, instructions, examples, and an output format.
The techniques here alter the internal computation and reasoning the model goes through due to the wording it sees:
- Chain-of-thought makes it work in steps before answering
- Few-shot examples define the format and the edge cases
- A JSON schema or XML tags make the output parseable by code
- Self-consistency samples a few chains and takes the majority
> Context engineering:
It's everything the model sees on a turn, not just the prompt. That includes the query, retrieved docs, memory, prior turns, and tool outputs from earlier steps.
The window is finite and fills up fast, so the engineering work is to rank inputs and cut everything that isn't pulling weight.
You do this by:
- Retrieving only the chunks relevant to the query, then reranking them
- Keeping key facts out of the middle, where accuracy drops
- Summarizing old turns, evict stale outputs, push big blobs to files
> Harness engineering:
It's the code around the model that defines the tools, parses the calls, retries on failure, and can route work to sub-agents so one handles retrieval and another handles code.
A verifier then grades the result by running tests, validating a schema, etc.
Prompt and context involve getting one call right. The harness involves everything that has to happen around that call for it to run in a real system.
> Loop engineering:
In the usual setup, you manage the outer loop, i.e, you write a prompt, read the turns the agent runs, write the next prompt, and repeat, while catching failures.
This layer hands that job to the agent itself. It kicks off on a schedule or an event, and runs many turns with no prompt in between.
A loop inherently doesn't know when it's finished. An agent can report that it's done and halt while the tests still fail. So the stop can't be the agent's word, but rather it has to be a real signal, like:
- A turn and token cap to stop stuck runs
- A no-progress detector to catch repeated calls
- A completion check to verify the goal with a separate model or a deterministic test
By this layer, you're operating on the whole run, so the engineering moves from writing each prompt to setting the goal and the stop conditions up front and letting it run.
A longer run also makes the cost of the layers underneath it grow.
When a tool returns a 50K-token response and nothing removes it, the model reads it again on every later call. Over a loop of twenty steps, one response turns into hundreds of thousands of tokens.
I wrote a full breakdown of where an agent's tokens actually go and how a harness keeps context flat, using TrueForge, an open-source harness that turns an LLM into a working agent.
GitHub repo: https://t.co/ZjePhhfKIh
(don't forget to star it ⭐ )
It covers offloading large tool outputs to files, subagents for context isolation, Code Mode for multi-tool joins, and compaction.
It also has a benchmark of three harnesses on the same 14 tasks, where TrueForge reached the same answers on about 40% of the tokens Claude Managed Agents used.
You can read my full article below.
You don't need long context!
NVIDIA researchers just published a paper questioning whether LLMs actually need huge context windows for long-running tasks.
The problem is that longer context is expensive.
As the context grows, every new token gets slower to generate, uses more memory, and costs more to serve.
In their measurements, going from a 16K to 256K context increased the cost per generated token by 3.6× for GLM 5.2, 5.6× for Kimi K2.6, and 7× for Qwen 3 Coder Next.
Their alternative is frequent context compaction.
Instead of carrying the entire conversation history through a long agent run, you keep a compact representation of the current task state and start a new context when needed.
For long documents, they use a similar idea: keep the documents outside the context and let the agent selectively read the parts it needs rather than loading everything at once.
They test this across software engineering, terminal tasks, tool use, retrieval, and long-document reasoning.
And the results are pretty interesting.
On long-horizon tasks, frequent compaction generally maintained or even improved task accuracy compared with keeping the full history.
They pushed this even further with Single-Action Compaction.
The model takes one action, observes the result, updates a compact semantic state, and then the entire conversation is discarded before the next action.
On Claude Opus 4.5, this preserved SWE-bench Verified performance and improved Terminal-Bench.
On GPT 5.6 Sol, the accuracy drop was only a few percentage points, while the median peak live context stayed around 7–9K tokens.
The paper takes this idea further and proposes Semantic State Space Models.
Instead of maintaining an ever-growing conversation history, the model carries a compact natural-language state between turns containing the information needed to continue the task.
This feels especially relevant for long-running agents.
You may not need to keep hundreds of thousands of tokens alive throughout the entire run. Keep the current state, retrieve what you need, compact aggressively, and continue.
I've shared the paper below!
this paper is f*cking insane
anthropic's engineers worked out why AI agents eat through so many tokens, and their fix is to stop letting the agent call tools one by one.
6 formulas, 1 folder structure, the exact code pattern, all on one page.
set it up tonight and your agent writes one small script instead of 20 tool calls, and the giant documents never even touch its context window.
the absurd part is people pay for bigger context windows and pricier models just to fit all their tools in, while in anthropic's own example the same task dropped from 150,000 tokens to 2,000.
then read the article below ↓
Why not RL an agent's weights inside its harness?
RL for agents throws away rich feedback, so people build harnesses like ACE where the model writes notes for itself. But it was never trained to use them. We give each role its own RL objective.
🚨 KARPATHY ACABA DE FIRMAR EL CERTIFICADO DE DEFUNCIÓN DE CLAUDE PRO, CHATGPT PRO Y GEMINI PRO
Y lo ha hecho con una sola frase:
"Todos están alquilando modelos de vanguardia para trabajos que un modelo local de 3B podría hacer. Los LLM locales pequeños son el futuro."
Este PDF de 18 páginas explica su idea: ejecutar la IA en tu propia máquina.
Sin suscripción.
Sin pagar por cada token.
La verdadera pregunta no es "¿el modelo local es igual de inteligente?"
Es "¿cuántas de mis 1000 llamadas necesitaban de verdad al inteligente?"
Te dejo el PDF abajo 👇
My letter to NVIDIA’s board.
In short, it asks the board to create a special committee of three new directors, elected by shareholders at a special meeting, to decide whether and under what conditions Jensen Huang should return—and to hire no permanent CEO until that committee decides.
The current board may be right. It may be wrong. What it cannot be is impartial. All ten sitting directors are defendants in a lawsuit that faults them for, among other things, deferring too much to Jensen. In that suit, they face personal, non-indemnifiable exposure. Keeping Jensen out stands to strengthen their defenses; bringing him back may undermine those defenses. A fiduciary should decline to decide an important question on behalf of his principal when one answer stands to benefit him personally more than the other.
In other words, in deciding whether to reinstate Jensen, each current director faces two questions: (1) How will this affect NVIDIA? (2) How will it affect me personally and my own defense in the pending lawsuit? Given what is at stake, shareholders deserve a decision from directors who face only the first question.
Stepping aside is also what NVIDIA’s own Code of Conduct calls for. The Code covers potential conflicts as well as actual ones and directs that when one arises, “we immediately remove ourselves from any decision-making role in the matter.”
When the board’s chair explained Jensen’s departure, he cited “personal behavior inconsistent with the company’s code of conduct.” The board must now apply the same Code to itself.
(1/3)
Another brilliant paper from Google on RSI.
(bookmark it)
In RSI, an agent edits its own harness from experience, meaning its prompts, skills, tool rules and memory. The model weights never change.
This works until an edit fixes one task and quietly breaks another. Over several rounds, a self-editing harness can end up worse than the plain agent it started from.
The problem is the signal the agent learns from. A single task score mixes two things: behaviors the latest edit just broke, and gaps the agent never solved.
So the agent can't tell a new regression from an old gap. It ends up writing broad rules that break working tasks, overwriting old skills, or piling stale rules into the prompt.
Google's fix is GUARD, a loop that checks what every edit breaks before it keeps the edit. Each round works like this:
1. Before a task runs, the agent turns it into a checklist of simple yes/no self-checks
2. After the run, it grades the trace against those checks
3. It pins the rules that already pass and ranks newly broken checks first
4. It tests several candidate edits on the same tasks and keeps the winner only if its gains outweigh what it breaks
Rejected edits go into a log, so the agent doesn't retry them. At test time, all of this switches off and one frozen harness runs in a single pass.
The paper shows the difference on four task streams that keep shifting. Other self-editing harnesses swung up and down, and fell below the plain agent as new edits overwrote old skills.
With GUARD, the harness improved at every checkpoint, with zero drops and zero forgetting.
On 43 test tasks with evolving calendar tools, GUARD lifted accuracy by about 9 points, from 72% to 81%. It improved 8 tasks, made none worse, and used less than half the starting agent's tokens per task.
The test set is small, and 81% is the best of five GUARD setups (the mean was about 77%). Treat the numbers as directional.
The GUARD paper (left in the image) is at https://t.co/B9J9sBxaAM
This builds on the previous paper Google released on RSI, Self-Improvement Memory (SIM). SIM gives the optimizer a log of why each past edit was made and whether it worked.
SIM helps the optimizer remember why an edit exists. GUARD checks what an edit breaks before it keeps it.
The SIM paper (right in the image) is at https://t.co/ZLdo7FK7qk
I also wrote an article on a similar idea, covering how to build an agent harness that improves itself automatically.
It's built on @Cometml's Opik, which is 100% open source. The article is quoted below.
Today we’re introducing OCRia-1.5
It’s a new family of document parsing models that push the boundaries of accuracy and cost across multiple document parsing dimensions.
We had just released OCRia-1 a month ago, which set a new SOTA in unified document parsing, but we've only released even more improvements since then.
✅ Tables: Table scores rose from 86.5 -> 90.1 on agentic, 83.2 -> 87.5 on cost-effective
✅ Charts: 74.9->76.8 on agentic, 67.3 -> 73.0 on cost-effective
✅ Forms: +2.6 on agentic, +4.2 on cost-effective
✅ Visual Grounding: +4.1 on agentic, and +11 (!!) points on cost-effective
Together, these models set a new Pareto frontier for document parsing. Our cost-effective OCRia-1.5 is the cheapest and most accurate model for parsing all of tables, charts, forms, handwriting, with high-quality layout.
Blog: https://t.co/9NlhPd6E1s
These scores for all our modes (cost-effective, agentic, agentic plus) reflected within ParseBench-2: https://t.co/PWczfhp0OX
New article out: 𝗡𝗶𝗻𝗲 𝗽𝗹𝗮𝗰𝗲𝘀 𝘁𝗼 𝘂𝘀𝗲 𝗗𝗲𝗰𝗶𝘀𝗶𝗼𝗻 𝗠𝗼𝗱𝗲𝗹𝘀 𝗶𝗻 𝗔𝗴𝗲𝗻𝘁𝗶𝗰 𝗥𝗔𝗚 𝘀𝘆𝘀𝘁𝗲𝗺. Code examples included.
Here are the nine use cases at a glance:
𝟭. 𝗠𝗼𝗱𝗲𝗹 𝗿𝗼𝘂𝘁𝗶𝗻𝗴. The prompt goes to a decision model, it picks the tier. Cheap models for lookups, expensive for what you cannot afford to get wrong.
𝟮. 𝗚𝘂𝗮𝗿𝗱𝗿𝗮𝗶𝗹𝘀. A separate yes-or-no per potential hazard. Before the LLM sees the input or on the answer that has been produced.
𝟯. 𝗥𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹 𝘀𝘂𝗳𝗳𝗶𝗰𝗶𝗲𝗻𝗰𝘆. Is what came back enough to answer, or should we search again.
𝟰. 𝗣𝗮𝘀𝘀𝗮𝗴𝗲 𝗳𝗶𝗹𝘁𝗲𝗿𝗶𝗻𝗴 𝗮𝗻𝗱 𝗿𝗲𝗿𝗮𝗻𝗸𝗶𝗻𝗴. Does this passage answer the question or is it only keyword-adjacent. Apply per candidate and sort by probability.
𝟱. 𝗖𝗶𝘁𝗮𝘁𝗶𝗼𝗻 𝗰𝗵𝗲𝗰𝗸𝗶𝗻𝗴. Does this source support the claim, contradict it, or fail to address it.
𝟲. 𝗧𝗼𝗼𝗹-𝗰𝗮𝗹𝗹 𝗴𝗮𝘁𝗶𝗻𝗴. Allow, ask or deny per call, with the bands in your code.
𝟳. 𝗟𝗼𝗼𝗽 𝘁𝗲𝗿𝗺𝗶𝗻𝗮𝘁𝗶𝗼𝗻. Does the result actually satisfy the acceptance criteria?
𝟴. 𝗖𝗼𝗻𝘁𝗲𝘅𝘁 𝗰𝗼𝗺𝗽𝗮𝗰𝘁𝗶𝗼𝗻. Score each piece of context and drop the stale ones instead of summarising them.
𝟵. 𝗘𝘃𝗮𝗹𝘀 𝗮𝘁 𝗳𝘂𝗹𝗹 𝗰𝗼𝘃𝗲𝗿𝗮𝗴𝗲. Significantly cheaper per verdict than an LLM judge. Potentially unlocks the ability to grade every trace instead of sampling.
Explore them in detail in my latest article: https://t.co/MOOnkLgY9l
Runnable notebooks in my AI Engineer's Handbook: https://t.co/E1JX283U8D
Let me know what you think! Also, if you found it useful, leave a like and repost so that others can benefit as well.
The era of one-size-fits-all inference engines is ending!
We had Claude write a separate megakernel for each of 8 open models, 8B - 594B: one GPU kernel that runs the entire decode loop.
Up to 1.77× faster than vLLM / SGLang, 2.05× with lossless model-specific tricks. 🚀
What slows reinforcement learning post-training?
See how NVIDIA Dynamo helps reduce repeated compute, weight-update overhead, and worker disruption and how @MicrosoftAI uses it for rollout inference.
Read the technical blog ➡️ https://t.co/xpqfc2rCja
Jensen has done so much to accelerate AI development and inspire people around the world. I believe he still has a lot more to contribute to AI, open-source AI, and the future of humanity.
We want Jensen back.
#BringJensenBack#StandWithJensen#NVIDIA#AIRevolution#OpenSourceAI
Introducing Qwen3.8-27B-opencode-adapted 🔥
Yesterday we released our Pi adapter. Today we’re releasing a LoRA adapter trained with RL specifically for the @opencode coding agent; runs locally!
Here’s how pass@1 changes from the base model → OpenCode adapter.
With thinking OFF for both models
🚀 SWE-bench Pro (Hard 51) · 35.3% → 51.0%
💻 Terminal-Bench 2.1 · 47.0% → 53.0%
With thinking ON (xhigh) for both models
🚀 SWE-bench Pro (Hard 51) · 47.1% → 54.9%
💻 Terminal-Bench 2.1 · 55.4% → 56.6%
⚡ With thinking OFF, the adapter lands within 4% of the base model with thinking on xhigh on both benchmarks, while using just 1/8th as many tokens on SWE-bench Pro, and 1/6th on Terminal-Bench.
Which one should we do next??
Open weights: https://t.co/FiQIs92Wrs
Read more about how we do this here: https://t.co/1vZxJ0d5EY
$NVDA / NVIDIA’s entire board (the 10 independent directors pictured here, minus Jensen) is up for election in June 2027. To get rid of them, shareholders either need to run a "Vote No" campaign on the June proxy ballot, or get 15% of 1-year holders to call a special meeting and vote them out by a two-thirds majority.
$NVDA / NVIDIA’s entire board (the 10 independent directors pictured here, minus Jensen) is up for election in June 2027. To get rid of them, shareholders either need to run a "Vote No" campaign on the June proxy ballot, or get 15% of 1-year holders to call a special meeting and vote them out by a two-thirds majority.
Over the past week, I’ve been overwhelmed by the love and support of friends, industry colleagues, and people I've never met. Thank you to everyone who has shown kindness to my family and me. It means the world to me.
I came to the United States 53 years ago, and becoming an American citizen is one of the greatest gifts and proudest moments of my life. NVIDIA has been my life’s work. Building it into the company it is today alongside my colleagues has been a privilege and an honor. Nowhere but in America could a company like NVIDIA be possible. I love our country, and I love NVIDIA.
I did not live up to the standards expected of everyone at NVIDIA, and I have made serious mistakes in my personal life. I created problems for the Board that I deeply regret. I own my mistakes completely, and I am committed to cooperating with the Board’s independent investigation.
Since my departure, I’ve seen an outpouring of calls from NVIDIA’s employees, investors, business partners, and customers for me to return as CEO. Many continue to reach out to me directly as the company navigates complex technology, market, competitive, and geopolitical dynamics. NVIDIA is a once-in-a-generation company. If the Board of Directors decides that my return is in the best interest of our shareholders, our employees, the company, and America, I would be honored to answer these calls and return as CEO.
Thank you again to everyone who has shared their good wishes. I am profoundly humbled by your support. To my family: I love you, and I will spend the rest of my life being worthy of yours.
Jensen
Over the past week, I’ve been overwhelmed by the love and support of friends, industry colleagues, and people I've never met. Thank you to everyone who has shown kindness to my family and me. It means the world to me.
I came to the United States 53 years ago, and becoming an American citizen is one of the greatest gifts and proudest moments of my life. NVIDIA has been my life’s work. Building it into the company it is today alongside my colleagues has been a privilege and an honor. Nowhere but in America could a company like NVIDIA be possible. I love our country, and I love NVIDIA.
I did not live up to the standards expected of everyone at NVIDIA, and I have made serious mistakes in my personal life. I created problems for the Board that I deeply regret. I own my mistakes completely, and I am committed to cooperating with the Board’s independent investigation.
Since my departure, I’ve seen an outpouring of calls from NVIDIA’s employees, investors, business partners, and customers for me to return as CEO. Many continue to reach out to me directly as the company navigates complex technology, market, competitive, and geopolitical dynamics. NVIDIA is a once-in-a-generation company. If the Board of Directors decides that my return is in the best interest of our shareholders, our employees, the company, and America, I would be honored to answer these calls and return as CEO.
Thank you again to everyone who has shared their good wishes. I am profoundly humbled by your support. To my family: I love you, and I will spend the rest of my life being worthy of yours.
Jensen
Jensen is reportedly considering a comeback! 💚
More than ever, our voices matter. Let's show him how many of us stand with him.
NVIDIANs, shareholders, and supporters, please take a moment to read the letter and sign it. Thank you!
#standwithjensen#bringjensenback
https://t.co/pbErEPvjYT