agents/skills/iterative-latency-investigation/SKILL.md
This skill defines the main coordination protocol, state machine, and safety
loops for the ierative latency investigation orchestrator. The Orchestrator
coordinates a swarm of specialized subagents (TelemetryCaptureAgent,
SQLTraceAnalyzerInstrumentationAgent, TraceInjectionAgent) to execute
targeted browser scenarios, detect uninstrumented "black boxes," and iteratively
inject C++ trace macros to break them down.
This system is strictly designed for data collection, diagnosis, and
instrumentation. The Orchestrator and its subagents MUST NOT perform any
C++ code optimizations, caching, or refactoring. All code changes are
exclusively restricted to injecting TRACE_EVENT macros to expose
uninstrumented latency gaps.
The Orchestrator is initiated with:
chrome_binary: Path to the built Chrome executable (e.g.
out/Default/chrome).scenario: The Telemetry UI story name to run (e.g. omnibox:search).target_slice: The entrypoint trace event to investigate (e.g.
OmniboxEditModel::OpenMatch).arg_key (Optional): Argument key to filter the root target_slice.arg_value (Optional): Argument value to filter the root target_slice
(requires arg_key).parent_session_id: Unique UUID for grouping all the artifacts.The Orchestrator manages the execution across the following phases:
graph TD
Start([Start]) --> BaseCap[Phase 1: Baseline Capture]
BaseCap --> BaseAna[Phase 2: Baseline SQL Analysis]
BaseAna --> LoopCheck{Has 'Black Box' Gap?}
LoopCheck -- "Yes
(Step < 200 & Progressing)" --> PivotCheck{Pivot Focus to Subevent?}
PivotCheck -- "Yes" --> Pivot[Set Target = Subevent] --> Inject[Phase 3: Trace Injection]
PivotCheck -- "No" --> Inject
Inject --> Recompile{Compile Success?}
Recompile -- Yes --> VerifyCap[Capture Verification Trace]
VerifyCap --> VerifyAna[Analyze Verification Trace]
VerifyAna --> LoopCheck
Recompile -- No --> Revert[Revert Changes]
Revert --> FinalReport[Phase 4: Final Breakdown Report]
LoopCheck -- "No / Step Budget Exceeded
/ No Progress for 2 Loops" --> FinalReport
FinalReport --> End([End])
The ochestrator should avoid conducting the trace collection, analysis or code edit itself. Instead, it should define subagents to perform these tasks.
At the start of the execution, the Orchestrator must define the specialized subagents:
git checkout -b e2e_nla_{parent_session_id}
TelemetryCaptureAgent subagent to execute the Telemetry
benchmark.scenario, chrome_binary, and parent_session_id.{ "status": "SUCCESS", "trace_file_path": "out/e2e_nla_run_{id}/capture/artifacts/run_{ts}/.../trace.pb" }
SQLTraceAnalyzerInstrumentationAgent subagent.trace_file_path, focus_slice_name (which is the
target_slice), parent_session_id, and optional arg_key/arg_value (if
initial filters were provided).out/e2e_nla_run_{id}/analysis/trace_analysis_results.jsonout/e2e_nla_run_{id}/analysis/trace_analysis_dispatch_report.mdThe Orchestrator runs an iterative loop that continues dynamically until either we exceed the total budget (200 agent steps) or we detect no progress for 2 consecutive iterations on the active focus slice.
focus_stack = [target_slice] (where target_slice is the
root user-provided event, optionally with arg_key/arg_value filters).For each iteration:
focus_stack (active_target = focus_stack.peek()).trace_analysis_results.json's black_boxes and
bottlenecks under the active_target.active_target is < 0.2ms (200us) or < 1.0% of the
focus duration, or if the method was already attempted:
focus_stack, returning the parent to the active position.focus_stack is empty, terminate the loop and proceed to Phase 4.chrome::Navigate or FrameTreeNode::DidStartLoading discovered inside
the parent) onto the focus_stack.arg_key and arg_value)
if they are needed to uniquely identify and isolate the target subevent
call (for instance, to avoid analyzing initialization calls of the same
method).active_target for the next iterations' SQL analysis and trace injection."GAP_INSTRUMENTATION") inside the active_target.target_method, instructions, category, and
parent_session_id.TraceInjectionAgent returns "FAILED",
or TelemetryCaptureAgent fails to capture):
TelemetryCaptureAgent to capture a new verification trace
(trace_verification_{iteration}.pb).SQLTraceAnalyzerInstrumentationAgent to parse the new trace under
the active_target (passing focus_slice_name and its associated
arg_key/arg_value filters if present).trace_analysis_results.json to verify the breakdown.focus_stack (or abort loop) and proceed to Phase 4.Once the loop terminates, the Orchestrator composes an Overall Investigation Report on the user-provided root event (the initial focus target).
out/e2e_nla_run_{parent_session_id}/analysis/overall_investigation_report.mdOpenMatch -> pivot Navigate), illustrate the
hierarchical deep-dive path. If code change are made, include the git
branch name of the code change in the document.The Orchestrator MUST strictly enforce these safety limits to protect the workspace and compute budgets:
git checkout main (or the original
baseline branch).git branch -D e2e_nla_{parent_session_id} to
restore the developer's workspace completely untouched.