Repository navigation
perf(agent): trace local startup stages - #117653
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:40 PM ET / 23:40 UTC. ClawSweeper reviewWhat this changesAdds nine opt-in Merge readinessThe patch appears correct and remains necessary: current Priority: P3 Review scores
Verification
How this fits togetherLocal agent execution resolves command dependencies, runtime configuration, session/model state, and the attempt runtime before provider preparation begins. This PR feeds those existing owner boundaries into the opt-in diagnostics timeline so performance work can identify which startup stage consumed time. flowchart LR
A[Local agent CLI or ingress] --> B[Command and dependency setup]
B --> C[Config and secrets resolution]
C --> D[Session and model preparation]
D --> E[Attempt runtime loading]
E --> F[Provider preparation]
B --> G[Opt-in diagnostics timeline]
C --> G
D --> G
E --> G
Decision needed
Why: The patch is mechanically sound, but adding a durable core trace taxonomy is a maintainer-owned observability direction rather than a bug fix with a pre-existing public contract. Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +58, Tests +45. Total +103 across 6 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Accept the small, opt-in Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds observability rather than repairing a reported end-user failure. The supplied exact-head workflow evidence does, however, show the new stages in real agent runs. Is this the best way to solve the issue? Yes: reusing the canonical diagnostics timeline at existing owner boundaries is the narrowest maintainable approach, and it preserves the direct execution path when diagnostics are disabled. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2f06ed30d8b1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
0ecdf7b to
6ccc8e4
Compare
|
@clawsweeper re-review All prior before-merge and rank-up items are resolved on
Please refresh the durable review against this exact head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Final exact-head landing gate for
Please close every remaining before-merge item in the durable review if this |
|
@clawsweeper re-review Current-base landing refresh is complete for
Maintainer decision remains to land this observability-only seam separately. |
|
Maintainer decision: accept the standalone nine-stage |
|
Merged via squash.
|
What Problem This Solves
Local agent startup time before the existing
agent.preparespans could not beattributed to command loading, config/secrets setup, session state, model
selection, or attempt-runtime loading.
Why This Change Was Made
Adds opt-in
agent.startupdiagnostics timeline spans around the existing ownerboundaries. The spans reuse the canonical diagnostics timeline, preserve the
original direct execution path when diagnostics are disabled, and do not change
provider, model, config, session, or error policy.
Maintainer Decision
Land the observability seam separately from any optimization. The exact Kova
evidence shows that most pre-provider time remains outside these new spans, so
combining speculative startup changes with the instrumentation would obscure
the baseline. Follow-up performance work should target the measured owners.
User Impact
No user-visible runtime change. Maintainers get stage-level data for local agent
startup when diagnostics are explicitly enabled.
Exact-Head Evidence
6ccc8e439da7ace01aa4429190612f0fe7860eb1.https://github.com/openclaw/openclaw/actions/runs/30722860302
profile, and live OpenAI.
agent.startupstage appeared in 10 normal turn traces:agent.startupwas the slowest new span at 125-149 ms30722795395, without this instrumentation:(+1.8%). This is not a strict same-SHA A/B because current
mainadvancedbetween runs, but the intervening changes did not touch this agent surface.
known profiler-overhead diagnostic (1053 MB over 1000 MB); the workflow
classified it as profiling-only and passed.
was 691/698 ms.
Local Verification
node scripts/run-vitest.mjs src/agents/startup-timing.test.ts src/commands/agent-via-gateway.test.ts src/agents/agent-command.ingress-diagnostics.test.tsoxfmt --check,oxlint, andgit diff --checkpassed.mainatb2278f3d10591d9eec4c091c82a4077d777143a6has not changed the six touched files, and
git merge-tree --write-treeisclean.
Findings And Next Work
The new spans explain roughly 230-250 ms of a roughly 3.2-second normal
pre-provider path. The largest remaining bucket is still about 2.9 seconds of
unattributed process/module bootstrap. Repeated plugin metadata scans account
for another roughly 175-190 ms per cold/warm pair. Optimize those owners in
separate PRs using this timeline as the baseline.
Storage And Compatibility
No persisted state, schema, config, protocol, or public API changes. Timeline
events are written only through the existing opt-in diagnostics contract.