Production AI agents fail when their context sources—system prompts, knowledge bases, tool descriptions, and procedural skills—contain errors or gaps. Current maintenance approaches rely on manual log review and ad-hoc debugging, creating a scalability bottleneck as interaction volume grows. We present TRace (TRajectory Attribution for Automated Context Engineering), an automated feedback loop that mines historical agent trajectories to diagnose and remediate context failures. Our key insight is that agent trajectories are rich with implicit dissatisfaction signals—user corrections, rephrasing patterns, abandonment cues—that reveal precisely where context sources failed, without requiring explicit feedback collection. Unlike model finetuning approaches, TRace operates on the context layer, enabling rapid iteration without retraining. The system makes four contributions: (1) a trajectory mining framework that systematically extracts diagnostic information from historical agent executions; (2) multi-component causal attribution that extends textual gradients from monolithic prompt optimization to heterogeneous context sources (skills, knowledge bases, tools, prompts); (3) exploratory verification where agents actively read context sources to distinguish content gaps requiring CREATE operations from stale content requiring UPDATE— achieving 96% operation accuracy; and (4) a reusable simulation methodology and verifiable evaluation benchmark addressing the absence of open datasets for context debugging, with a six category fault taxonomy, complete ground truth annotations, and a cross-layer verification protocol that can be adopted to generate domain-specific benchmarks. Evaluation on 60 dissatisfaction traces spanning three complexity tiers (up to 16 execution nodes) achieves 72.7% root cause node attribution and 82% end-to-end fix effectiveness—demonstrating that over 80% of context-layer failures could be automatically diagnosed and correctly remediated by mining historical agent trajectories, an overlooked resource in production systems.