-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
observability: emit per-MCP-server sub-spans inside bundle-tools so cold-start cost is attributable #81595
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Summary
The
[trace:embedded-run] prep stagesline and thetimelinediagnostic (openclaw.diagnostics.v1envelope) both exposebundle-toolsas a single aggregate duration. On hosts with multiple stdio MCP servers configured, this stage routinely accounts for the dominant share of per-turn prep time — but it's a black box: there's no way to attribute the cost to a specific MCP server, plugin tool registry, or sub-step.This makes regressions and duplicate-child situations (e.g. #75621) much harder to diagnose than they need to be, and makes proposed fixes like #80131 (tool bundling memoization) harder to verify after the fact.
Concrete observation
On a Linux/WSL host running OpenClaw
2026.5.7with 6 stdio MCP servers configured (filesystem,github,desktop-automationvia WSL→cmd.exe, and 3×graphify.serve), bundle-tools shows a bimodal distribution:filesystemMCP)All evidence points at sequential
tools/listcold-start across the MCP children (re-spawned per prep cycle), with one slow child dominating, but there is no log signal that names which child is slow. Diagnosis required ad-hocps/strace/timing experiments.Proposal
Emit nested sub-spans inside
bundle-toolsto the timeline diagnostic (openclaw.diagnostics.v1), one per MCP server / tool source. Also include a compact summary line in the existing aggregate[trace:embedded-run] prep stageslog whendiagnostics.flagsincludestimelineor a newbundle-tools.detailflag.Suggested shape (JSONL timeline):
{"span":"bundle-tools","durationMs":20931,"children":[ {"span":"mcp.tools_list","server":"filesystem","durationMs":3120,"toolCount":11}, {"span":"mcp.tools_list","server":"github","durationMs":1840,"toolCount":29}, {"span":"mcp.tools_list","server":"desktop-automation","durationMs":11420,"toolCount":6,"warn":"slow"}, {"span":"mcp.tools_list","server":"graphify-orchestrator","durationMs":1505,"toolCount":7}, {"span":"mcp.tools_list","server":"graphify-trader","durationMs":1490,"toolCount":7}, {"span":"mcp.tools_list","server":"graphify-openclaw","durationMs":1456,"toolCount":7}, {"span":"core-plugin-tools.assemble","durationMs":80} ]}Compact one-liner (for the existing log channel):
Either format is enough to identify the slowest server at a glance.
Why this matters now
Two open performance issues would directly benefit:
psafter the fact. Per-server timing would surface the duplicate (two children responding to the same(server, config)key) as duplicated sub-spans or anomalous totals.It also helps users with many MCP servers decide which servers are pulling weight vs being dead-weight cold-start cost.
Backwards compatibility
diagnostics.flagsincludestimeline(already gated) or a new dedicated flag — no change to default behavior.bundle-toolsvalue in the existing[trace:embedded-run] prep stagesline stays as-is, so downstream parsers keep working.Environment
2026.5.7(eeef486)v22.22.26.6.87.2-microsoft-standard-WSL2Offer
Happy to test patches against this workload — I already have a CSV parser of the prep-stages line and a baseline corpus across two days of bimodal traffic.