Skip to content

perf(workspaces): List Workspaces in the turn context - #2613

Merged
thomasjiangcy merged 1 commit into
mainfrom
perf/workspaces-in-turn-context
Nov 3, 2026
Merged

thomasjiangcy merged 1 commit into
mainfrom
perf/workspaces-in-turn-context

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Repo work in traces keeps taking the same detour: searchTools("clone repository") → executeTool(github_cloneRepository) → Workspace-match rejection → switchWorkspace. That is two wasted model steps on a full context, and any sandbox work done before the switch (loadAttachment, bash, readFile) runs in a default Sandbox that the switch throws away.

Root cause: the agent cannot see which Workspace covers a repository. #2315 removed the prompt line about Workspaces because the clone rejection already steers to switchWorkspace. That made the rejected clone the main way the agent finds a Workspace. Even before that, the agent needed a listWorkspaces call to map a repo to a Workspace name.

Fix: loadPromptTurnContext loads the install's Workspace recipes (listWorkspaces(getDb())). The bootstrap turn context renders them as a <workspaces> block, next to <available-skills>:

<workspaces>
Named Sandbox recipes. After `switchWorkspace`, their repositories are already checked out.
- junior: getsentry/junior
- sentry: getsentry/getsentry, getsentry/sentry
</workspaces>

With no Workspaces, the block is omitted. The block lists facts only. The clone rejection stays in place as the runtime gate. <context-trust> and policies/system-prompt.md list the new tag as a runtime fact.

Remaining risk:

  • I did not run the behavioral or integration evals because the sandbox has no model gateway key. Please run them before merge to confirm the agent switches first.
  • The block has no size cap. Its cost grows with the number of Workspaces in an install.
  • The list loads on each new prompt, but it renders only in the bootstrap context. A Workspace created later in a conversation is still found through listWorkspaces.

via @thomasjiangcy.

--

View Session [Sentry]

The agent could not see which Workspace covers a repository, so repo work
ran searchTools, a rejected github_cloneRepository, then switchWorkspace.
List each Workspace and its repositories in the bootstrap turn context so
the agent can switch first, before it does sandbox work that the switch
throws away.

Co-Authored-By: Thomas Jiang <20501235+thomasjiangcy@users.noreply.github.com>
@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 3, 2026 2:54pm UTC

Request Review

@thomasjiangcy
thomasjiangcy marked this pull request as ready for review November 3, 2026 14:56
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 3, 2026
@thomasjiangcy
thomasjiangcy merged commit 75b62e0 into main Nov 3, 2026
47 of 49 checks passed
@thomasjiangcy
thomasjiangcy deleted the perf/workspaces-in-turn-context branch November 3, 2026 15:11

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 7df110e2 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant