Skip to content

perf(agent): scope read_workspace to the requested section - #110

Open
kvnloo wants to merge 4 commits into
CopilotKit:mainfrom
kvnloo:perf/read-workspace-section-scoped
Open

kvnloo wants to merge 4 commits into
CopilotKit:mainfrom
kvnloo:perf/read-workspace-section-scoped

Conversation

@kvnloo

@kvnloo kvnloo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Problem

The model's read_workspace tool currently calls the full workspace snapshot for every request, then throws most of it away.

For section: "mail", that still loads:

  • calendar events;
  • files;
  • browser sessions;
  • actions;
  • activity;
  • profile/token metadata.

The same over-read happens for calendar and files requests.

A downstream PGlite benchmark with mail 2000 / events 500 / files 200 / browsers 300 / actions 800 / activity 1000 measured the mail path at roughly 291.9ms / 2.6MB → 254.8ms / 2.0MB, with calendar/files sections avoiding >90% of unrelated transfer.

Change

Add WorkspaceService.sectionSnapshot() for the three tool-visible source sections and make read_workspace use it.

The existing full snapshot() remains the full workspace API and still performs one connection check. Shared mail/event loading preserves:

  • live Google fetches;
  • mail caching;
  • event persistence;
  • existing sorting and query filtering.

A files-only read does not touch Google, browsers, actions, activity, profile, or runtime metadata.

Regression

Persistence coverage compares mail/calendar/files section results against the corresponding fields from the existing full snapshot.

No connector permissions, tool schema, or returned section payload changes.

This branch has not been deployed

No deployments
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.

1 participant