TRIMLAYER LEARN · EVIDENCE-AWARE CONTEXT
Agent context optimization
Agents replay tool outputs, state and retrieved material across multiple steps. Without context control, every step can inherit the full cost and noise of earlier work.
AGENT CONTEXT LOOP
Optimize for the next decision, not the whole trajectory.
Store durable state—identifiers, approvals, completed steps and tool outputs—in your application. Construct each model turn from the next decision plus the evidence required to make it. This prevents a long-running agent from replaying every prior log and schema at every step.
ILLUSTRATIVE CASE
A code agent investigating one failing handler does not need every repository file.
The application can retain the failing test, referenced handler, related type definitions, imports and exact error output while omitting unrelated packages. If the next step names a missing symbol, the agent can recover that scoped source rather than asking for the entire repository again. Evaluate the full trajectory: successful tool actions, recovery frequency, total input tokens and final task completion.
Practical guidance
Separate state from evidence
Keep durable structured state in the application or system of record. Give the model only the evidence required for the current decision or tool call.
Practical guidance
Define the next step
Name the function, file, claim, user intent or decision the agent must handle. A clear task contract makes relevance measurable and limits accidental omission.
Practical guidance
Trim tool output
Preserve errors, identifiers, numeric values and referenced records while removing unrelated rows, repeated schemas and verbose diagnostic material for the current step.
Practical guidance
Recover only when needed
Attach a scoped recovery path to omitted source so a later agent step can request the exact original. Include recovered tokens in effective-savings calculations.
Practical guidance
Test complete trajectories
Evaluate success across the whole agent run, not only one step. Measure tool accuracy, state consistency, recovery frequency, input tokens and end-to-end latency.
