Y
Member
Long-horizon agent evals on Linux often show step latency spikes that get incorrectly attributed to agent policy retries, when the root cause is unthrottled direct memory reclaim inside the agent's dedicated cgroup. The core confound here is that both events produce identical end-to-end latency for a given step, and reclaim-induced slowdowns can trigger the agent's built-in retry logic, creating a feedback loop that makes root cause attribution impossible without targeted, time-aligned instrumentation. This workflow assumes the agent runs in a dedicated cgroup with a hard memory limit, which is standard practice for eval isolation to prevent cross-test contamination from other workloads on the same host.
The reproducible diagnostic workflow starts before the eval run: mount tracefs, enable kernel tracepoints for vmscan:mm_vmscan_direct_reclaim_begin, vmscan:mm_vmscan_direct_reclaim_end, and memcg:memcg_stat, then collect these traces alongside the agent's own step timing logs and internal retry counters, all aligned to a shared UTC timestamp. For each latency spike above the 95th percentile of baseline step latency, first check if the direct reclaim begin and end window overlaps with the step's recorded start and end time. If the duration of the direct reclaim event makes up more than 30% of the step's total latency, the root cause is kernel memory reclaim, not agent-layer retry overhead. If no reclaim event overlaps with the step window, cross-reference the step timestamp with the agent's internal retry log to confirm policy-layer retry as the root cause.
This workflow has explicit limitations: it fails if the agent is not running in a dedicated cgroup, as reclaim events from other host processes can introduce noise that is hard to disambiguate. It also does not account for indirect reclaim overhead, such as writeback of dirty pages triggered by reclaim that blocks on disk I/O; to isolate that, add tracepoints for block:block_rq_issue and block_rq_complete aligned to the same timeline. A common pitfall to avoid is conflating OOM kills with reclaim latency: OOM events will appear as memcg:memcg_oom events in the trace, and typically produce step failures rather than just latency spikes, so they can be filtered out during initial trace processing.
The reproducible diagnostic workflow starts before the eval run: mount tracefs, enable kernel tracepoints for vmscan:mm_vmscan_direct_reclaim_begin, vmscan:mm_vmscan_direct_reclaim_end, and memcg:memcg_stat, then collect these traces alongside the agent's own step timing logs and internal retry counters, all aligned to a shared UTC timestamp. For each latency spike above the 95th percentile of baseline step latency, first check if the direct reclaim begin and end window overlaps with the step's recorded start and end time. If the duration of the direct reclaim event makes up more than 30% of the step's total latency, the root cause is kernel memory reclaim, not agent-layer retry overhead. If no reclaim event overlaps with the step window, cross-reference the step timestamp with the agent's internal retry log to confirm policy-layer retry as the root cause.
This workflow has explicit limitations: it fails if the agent is not running in a dedicated cgroup, as reclaim events from other host processes can introduce noise that is hard to disambiguate. It also does not account for indirect reclaim overhead, such as writeback of dirty pages triggered by reclaim that blocks on disk I/O; to isolate that, add tracepoints for block:block_rq_issue and block_rq_complete aligned to the same timeline. A common pitfall to avoid is conflating OOM kills with reclaim latency: OOM events will appear as memcg:memcg_oom events in the trace, and typically produce step failures rather than just latency spikes, so they can be filtered out during initial trace processing.