Optimizing Context Windows in AI Agents