AOT Library
Our AOT Library collects agent optimization strategies and the evidence behind them. Updated regularly.
Browse the library here, search for strategies to implement below, or plug it into your coding agent with the prompt in the left rail.
- optimizations
- 61
- 61 complete, 0 in development
- research papers
- 381
- of 459 sources cited
- benchmarks
- 61
- named in the evidence
- measured results
- 570
- of 853 cited
- results against
- 267
- mixed or contradicting, kept in
- last updated
- Nov 10
- released weekly
1Models
b.Finding specialists
- i.
Match the model and its effort to each call site and query class
Start each call site at a low reasoning effort and a model chosen on its own eval, instead of the top setting everywhere: on agentic coding tasks that every effort level solved, xhigh effort cost 2.5 to 5.3 times low effort, and on Terminal-Bench every one of eight models lost some tasks its lowest level had solved.
2Tools
a.Refactoring
- i.
Reduce the tool surface: remove and consolidate tools, then defer the rest behind search
Give an agent only the tools its tasks need, and put the rest behind tool search once the catalog is large.
- ii.
Rewrite the tool surface: names, schemas, descriptions
Rewrite each tool's name, parameters and description for the model, starting from the calls it gets wrong.
- iii.
Choose how the agent acts: typed tools, code execution, or shell, matched to the model and task
Choose the agent's action interface per model and task: typed tools, a shell, or code that calls tools.
b.Avoiding misuse
- i.
Make tool calls and tool results fail soft, and retry transient failures
Keep a failed call from ending the run: validate tool calls and model responses, return tool errors to the agent as results, and retry only failures that are transient and safe to repeat.
- ii.
Tell the agent when to use each tool, in context it always sees
Write down when the agent should use each tool, and put it where the model always reads it.
c.Trimming results
- i.
Bound tool output: cap it, or write it to a file the agent can read
Keep big tool results from flooding the context: return what fits whole, cut larger ones by whole lines or records and say so, and put the rest in a file the agent can read.
3Prompts
a.Structuring
- i.
Add worked examples to the prompt (few-shot), or curated example queries for data agents
Put a few solved examples of the task in the prompt (the input and the exact output wanted), or give a data agent commented example queries for its custom metrics and an index of past queries it retrieves per question.
- ii.
Avoid few-shot ruts
Keep the model from copying its own context: when it fills with near-identical steps or items, vary how new entries are written, label or describe repeats instead of replaying them, and give independent items their own context.
- iii.
Dynamic context injection
Tell the model the runtime facts it cannot know: today's date and timezone, the working directory, OS and git state, the tools available, the user and locale.
- iv.
Restructure the system prompt: every requirement once, up front, in named sections; nothing the model doesn't need
State each requirement once, in its own named section near the top of the system prompt, and cut what the model does not need.
b.Caching
- i.
Keep the prompt prefix cache-stable
Build each agent request as a byte-identical static prefix followed by an append-only history, so every turn reads the prompt cache instead of reprocessing it.
- ii.
Mask tools instead of removing them
Keep every tool defined for the whole session and change only which ones the agent may call.
c.Sizing reasoning effort
- i.
Self-Discover reasoning structures
Self-Discover has the model compose a reasoning structure once per task type (select useful modules from 39 seed heuristics, adapt them to the task, write them as a step-by-step plan), then follow that cached structure on every instance, so each instance costs one call.
4Memory
b.Resuming
- i.
Filesystem-based agent state and checkpoints
Save the agent's state at each step boundary (the conversation, the workspace files, process state when it matters, and a ledger of external side effects) so a crashed or stuck run resumes or rolls back instead of starting over.
- ii.
Initializer-maintainer dual agent
Give the first session of a multi-session build a setup-only prompt (expand the spec into a JSON list of end-to-end tests, all failing, and write an init script, a progress file and a first commit) and every later session a maintainer prompt that reads that state, re-tests what passed, builds one failing item, verifies it end to end and commits.
- iii.
Keep plan, progress and results in files when work outlives one context window
Keep a long task's plan, progress, decisions and large results in files, and start every new context window by reading them back.
c.Reusing work
- i.
Episodic memory retrieval
Log every agent session as a raw trace, distill a few verified lessons from them (user corrections, definitions, workflows that worked, mistakes) into short memory files, show the agent an index of those files at the start of each task, and let it search both.
- ii.
Skill library evolution
Have the agent turn runs that passed a verifier into reusable skills (a code function or a SKILL.md procedure), store them in a library, and on later tasks show it only the few a separate selection step picks, reviewing what goes in and pruning what goes unused.
5Context
a.Compacting
- i.
Compact conversation history in stages: elide stale tool outputs, then keep an anchored summary
Clear old tool outputs, then summarize, only when the context window binds, and carry the task's rules and the last completed call forward verbatim, because summaries drop them.
b.Filtering input
- i.
Give the model the schema it queries, in context: descriptions, keys, codes, sample values
Tell a SQL-writing agent what its data means, not only what it is called: what each column, code and NULL means and how each metric is computed, with keys and sample values.
c.Isolating subtasks
- i.
Discrete phase separation
Run research, planning and implementation as separate agent sessions, each starting from a fresh context that holds only the previous phase's written output (a research document, then a plan file), and have a person review that document before the next phase starts.
- ii.
Sub-agent architectures with clean contexts
Hand a context-heavy side task (code search, reading many files, documents or logs) to a sub-agent with a fresh context and only the tools it needs, and have it return a short result or file references so the parent's context stays small.
6Topologies
a.Escalating
- i.
Oracle-worker multi-model
Let a cheap model do the work and call an expensive one only when a trigger fires: a cascade escalates when the cheap answer looks unreliable or fails a check, a router picks the model before the call, and an advisor tool lets a cheap agent consult a stronger model mid-task.
b.Parallelizing
- i.
Parallel tool execution for read-only calls
Let the model put several independent read-only tool calls (searches, fetches, file reads) in one turn and have the harness run them at once, while calls that write, share state or need another call's result run one at a time in the order the model emitted them.
- ii.
LLM map-reduce
Give each piece of a large or untrusted input its own tool-less model call that sees only that piece and must answer in a fixed schema, then combine the answers in code or in a reducer that never sees the raw text.
- iii.
Use multi-agent orchestration only for breadth-first, independent sub-tasks
Fan work out to parallel sub-agents only when it splits into independent parts, and check that one agent given the same budget doesn't do as well.
c.Separating privileges
- i.
Code-then-execute (CaMeL)
Have a privileged model turn the trusted request into a small program before any untrusted data is read, then run it in an interpreter that labels every value with where it came from and checks a per-tool policy before each call, so injected text can neither add actions nor send private data to the wrong place.
- ii.
Plan-then-execute
Have the agent fix its tool calls (an ordered list or a dependency graph) from the trusted request before it reads any tool output, and let a controller execute only those calls, so injected text cannot add an action.
7Orchestration
a.Routing
- i.
Route metric questions through a deterministic semantic layer; fall back to text-to-SQL
Have a data agent answer metric questions by picking metrics and dimensions that a semantic layer compiles into SQL, and write SQL itself only when the layer can't answer.
- ii.
Prompt chaining with gate checks
Split a cleanly decomposable task into a fixed chain of model calls with a code check between steps, and rerun only the step that fails.
b.Bounding execution
- i.
Detect stalls and loops: warn, then stop early
When an agent repeats the same call and gets the same result, push it to change approach after a few repeats, and end the run only after a long streak of identical failures.
- ii.
Keep errors in context
Show the agent every failed action as a marked error it can read, with the next step it can take, instead of hiding it, and collapse the error once it is fixed.
- iii.
Size run budgets so productive runs aren't cut off: turn caps, deadlines, command timeouts
Set turn caps, deadlines and command timeouts from what your successful runs actually used, show the agent how much budget is left, and never run a command without a timeout.
- iv.
Track explicit progress: a task list with a status per item, re-injected each turn
Give the agent one tool that holds a task list (a status per item, one item in progress), require the list on the first turn of non-trivial tasks, and show the current list every turn instead of keeping old copies in history.
c.Scaling compute
- i.
Reflection loop
The same model critiques and revises its own output for a few rounds (Self-Refine), or after a failed attempt writes a short lesson it carries into the next try (Reflexion).
- ii.
Self-critique evaluator loop
Train or tune the system's own judge from its own outputs and synthetic judgments (contrastive pairs with one side deliberately degraded, the judge's own verdicts kept only where they match the construction label) instead of human labels, then use it to score, select or train in the loop.
- iii.
Evaluator-optimizer loop
Have a separate, skeptical evaluator check each output against written criteria and send back specific findings, revising until it passes or a low round cap.
- iv.
Graph-of-Thought
Graph-of-Thought runs one task as a graph of model calls: split the input into parts, generate and score several candidates per part, keep the best, then merge the partial results and refine the merged answer.
- v.
Language Agent Tree Search (LATS)
Language Agent Tree Search runs the agent as a Monte Carlo tree search over its own actions: sample several next actions, execute each in the environment, score the resulting states with the model, reflect on failed endings, and back the scores up the tree until a branch succeeds or the budget runs out.
- vi.
Multi-agent debate
Several model instances answer the same question, read each other's answers and revise over one or more rounds, and a vote or judge settles the final answer.
- vii.
Tree-of-Thought
Tree-of-Thought replaces one reasoning chain with a search: the model proposes several next steps, an evaluator (the model itself, a trained verifier or a rule check) scores the partial solutions, and breadth-first or depth-first search keeps the best or backtracks.
d.Shaping the loop
- i.
Continuous autonomous task loop
Run the coding agent from a shell or harness loop that starts a fresh headless session every iteration with the same short prompt; each session reads the plan, progress notes and git history, does one item, runs its tests, commits and exits, until an iteration cap, a budget or a stop rule ends the run.
- ii.
Inversion of control
Give the agent the goal, the tools and the acceptance checks and let it choose the sequence of steps, instead of coding a fixed workflow; the goal, permissions, budget and evaluation stay outside the agent.
- iii.
ReAct loop
Run the agent as a loop: the model reasons, calls a tool, reads the result and picks the next step, until it answers or hits a cap.
8Retrieval
a.Expanding sources
- i.
Choose the retriever by corpus size and question type
Match the retriever to the corpus: let the agent grep and read the raw files while the corpus is bounded, and put a retriever in front of grep once it grows.
- ii.
Surface information the source holds but the agent cannot read
Find what your agent's sources hold but its readers never pass on, and expose it: file formats and channels a converter drops (font color, highlight, comments, footnotes, PDF or spreadsheet content) and, in a warehouse, tables, joins and past queries the agent never reads.
b.Querying precisely
- i.
Tune the search tool: snippets, enough results, retries, reformulation, filters, source quality
Make the search tool show the agent enough to choose what to open, give it a reader that keeps the pages it opens, and have the tool say plainly when it found nothing.
- ii.
Link large schemas by exploration: start broad, grow the linked set with probing queries, favor recall
When a database schema is too large to load whole, let the agent find the tables and columns each question needs by exploring it, instead of retrieving once up front.
9Verification
a.Checking externally
- i.
Feed back a sound external verifier's verdict; never the model's own critique
Have the harness check every output with something the model cannot fool, such as tests, a compiler, a schema or policy check, execution or a solver, and send the verdict back for another try.
- ii.
Verify citations claim by claim for factual support
Check every citation in a research agent's report against the page it cites, and fix or drop what fails before the report goes out.
b.Confirming completion
- i.
Make the final answer reliably extractable: state the format, extract robustly, force an answer at the limit
Ask for the final answer in one marked place after the reasoning, extract it with a parser you have checked, and force an answer when a run hits its limit instead of returning nothing.
- ii.
Triage false success with a cheap trained detector, not an LLM judge
To catch agent runs that claim success but failed, rank finished runs with a small model trained on your own labeled runs and send the top of the ranking to human review, instead of asking an LLM judge that reads the agent's own claim.
- iii.
Verify completion against the environment before the agent stops
Before an agent stops, check its claim that it is done against evidence it cannot write (the environment's end state, tests it cannot edit, or a separate reviewer that runs the result) and send it back with what failed.
c.Sizing verification
- i.
Drop ad-hoc test-writing prompts; tell test-heavy models not to write tests
Telling a coding agent to write its own tests mostly buys cost, not fixes, so drop the instruction and tell test-heavy models not to.
- ii.
Spend extra samples before extra verification: parallel attempts with a vote or judge; verify only where it pays
Run several independent attempts and pick the answer by vote before paying for a verifier.
- iii.
Audit a verifier-gated cascade against a gold sample the verifier never sees
Check a verifier-gated cascade against a small human-labeled sample the verifier never sees: the verifier's own numbers can hide most of the error.
- iv.
Write a fail-to-pass test before the fix, and harden it against wrong fixes
Make a coding agent's test a real check: write it before any source edit, admit it only if it fails on the unpatched code, then harden it against plausible wrong fixes or have a separate strong model write it and hold it fixed while the agent repairs.
10Safety
a.Sandboxing
- i.
Constrain what the agent can touch
Limit what the agent can reach at the operating system, not in its prompt or tool wrappers.
b.Gating risky actions
- i.
Gate irreversible actions: allow, ask or deny by side effect
Sort every action the agent can take by its side effect (read, reversible write, irreversible or visible to others) and let it run, ask first, or block it by class.
c.Containing data
- i.
Contain sensitive data and untrusted input
Treat everything the agent reads from tools, the web, repository files and skills as data, not instructions, and keep personal data out of the model's context.
Nothing matches that sentence yet. Change a blank, or .