Ship production AI

AI Engineering Bootcamp

maven.com/tailabs/ai-engineering-bootcamp

Lightning Lesson · 30 min

High-Signal Context

Find the smallest set of tokens that maximises the chance of the right answer

Dr. Aki Wijesundara

Dr. Aki Wijesundara

Co-Founder, TAI Labs

Courses we offer

Two paths from TAI Labs. Each card shows exactly what we cover.

A 1M token window does not mean 1M usable tokens.

Advertised length

How many tokens the API will accept without erroring.

Effective length

How many tokens it can actually hold accuracy across.

Those are different numbers. The gap is where teams get burned.

Today: three problems · three fixes · one budget

Attention is n²

Every token attends to every other token. Double the context and you quadruple the pairwise relationships. Attention gets thinner, not smarter.

n tokensn² pairsfixed attention budget2n tokens4n² pairssame budget, thinner attention

Context rot and lost-in-the-middle

Retrieval accuracy is high at the start and end of the window, and sags in the middle. Same fact, different position, different answer.

AccuracyStartMiddleEndlost here

Distractor sensitivity

Near-miss content is worse than no content.

One correct chunk

Model has a single authoritative source. Higher chance of the right answer.

Three plausible chunks

One is correct. Two look right. The model cannot tell which is authoritative. Accuracy drops.

Stuffing “maybe relevant” material is not free. It actively competes with the truth.

Needle-in-a-haystack lies to you

What NIAH tests

  • Find a planted sentence
  • Lexical overlap with the question
  • A retrieval trick, not reasoning

What real work needs

  • Multi-hop reasoning
  • Conflicting material
  • Judgement under ambiguity

Passing NIAH at 500k tokens does not mean the model can reason over 500k tokens. Real work degrades much earlier.

Agentic loops fail differently

Single-shot QA is one big blob. An agent accumulates its own exhaust.

Turn 1taskTurn 8toolsTurn 20retriesTurn 30stale readsTurn 40mostly exhaust

By turn 40, most of the context is a record of things that did not work.

Symptom checklist

If two or more of these are true, you do not have a prompt problem. You have a context problem.

Cut an overloaded agent context in passes

Show token count and output quality after each pass. This is the core of the session.

01

Kill duplicates

02

Keep rule

03

Compress

04

Reposition

05

Trim tools

Kill duplicates and stale versions

Before

config.v1.json · config.final.json · config.FINAL2.json. The model will pick the wrong one with confidence.

After

One current source of truth. Everything else is gone or archived outside the window.

Two versions of the same config file is the single most common cause of the model doing the wrong thing.

Apply the keep rule

The keep rule

If removing it would not change the answer, it is decoration.

What stays

Constraints, decisions, facts the answer depends on, and nothing else.

Compress, don't delete

Instead ofKeep
Full transcriptSummary of decisions and open questions
Sample rowsSchema + 2 example rows max
Both file versionsThe diff
Full implementationFunction signature + docstring

Reposition

Task + critical constraintsRetrieved facts · working state · examplesRepeat critical constraints

Never bury the instruction mid-window. Top and bottom are the high-attention zones.

Trim the tool surface

Twenty overlapping tools

You pay for every definition on every turn. Tool selection accuracy degrades as the menu grows.

Dynamic or collapsed tools

Load tools per step, or expose a small allowlist. Planning and execution should not share the same surface.

Cut too far on purpose

This is what separates the session from a blog post: the failure teaches the keep rule better than the success.

A starting split you can steal

Instructions10%Task-critical facts40%Examples15%Working state / history25%Headroom10%

When something comes in, something goes out.

Just-in-time retrieval over pre-loading

Stuff everything up front

You guess what the agent will need. The window fills with maybes.

Let the agent go get it

Filesystem, grep, and targeted retrieval as context. Navigation beats speculation.

Three levers

01 · Compaction

Summarise and reinitialise. Keep decisions and constraints. Discard redundant tool output.

02 · Note-taking

Write state to a file outside the window. Pull it back on demand across thousands of steps.

03 · Sub-agents

A specialist burns 10k tokens in a clean window and returns a 1.5k summary.

Main agentSub-agentburns 10k1.5k summary back

Decision rule

SituationReach for
Conversational flow that needs continuityCompaction
Long iterative work with milestonesStructured note-taking
Parallel research threadsSub-agents

Aggressive trimming that reshuffles your prefix kills cache hits. The cheapest context is often the one you do not change.

Three things to do tomorrow

01

Log token counts per turn on one agent. You cannot cut what you cannot see.

02

Delete your worst duplicate. Re-run. Measure the delta.

03

Pick one raw tool dump and truncate or paginate it.

Leave with one sentence: find the smallest set of high-signal tokens that maximises the chance of the right answer.

Ready to go deeper?

Same two programmes. Scan a QR, then take the next step.

This session was one call

Agents are where it gets hard: the window refills every turn, and nobody is steering it unless you build the harness.

Next

High-signal context is the skill.
Agents are the practice.

AI Engineering Bootcamp: build and ship production AI agents

maven.com/tailabs/ai-engineering-bootcamp

Dr. Aki Wijesundara

Dr. Aki Wijesundara

TAI Labs

1 / 24