Skip to content

perf(mcp): skip aria snapshot capture when the response discards it#41923

Open
m4ttheweric wants to merge 2 commits into
microsoft:mainfrom
m4ttheweric:mcp-skip-unused-aria-capture
Open

perf(mcp): skip aria snapshot capture when the response discards it#41923
m4ttheweric wants to merge 2 commits into
microsoft:mainfrom
m4ttheweric:mcp-skip-unused-aria-capture

Conversation

@m4ttheweric

Copy link
Copy Markdown
Contributor

Summary

  • Response.serialize captured a full aria snapshot on every tool response, then discarded it when the response does not render one (snapshot mode none, or tools like browser_run_code_unsafe that never request a snapshot).
  • The accessibility tree walk dominates response latency on heavy pages (~300ms on a 2,500-row table, ~1MB serialized). Skipping it cuts that per-call cost; console links, events, and modal states are still reported.
  • No behavior change when a snapshot is requested.

// tree walk, which dominates response latency on heavy pages. Console,
// events and modal states are still reported.
if (!includeAria) {
if (this.modalStates().length)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplication isn't nice here, easy to forget things in one of the modes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. collapsed the two paths so only the aria walk is conditional; the console/events tail and modal fallback now live in one place.

};
});
} else if (this.modalStates().length) {
// Matches the aria path's modal fallback below, without the race: there

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't welcome low snr comments, coding agents are stubborn at not listening to our claude.md though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants