Studio Code: don't expose share_screenshot outside the remote-session runtime - #3365
Merged
Conversation
…me, not the feature flag
…milestone, not per edit
Collaborator
📊 Performance Test ResultsComparing 28fe1b4 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
gcsecsey
approved these changes
May 6, 2026
Comment on lines
+26
to
+27
| 'Use this when the user explicitly asks to see the site, or when you finish a logical milestone with a clear visible result worth looking at — not after every intermediate edit. ' + | ||
| 'One screenshot per milestone, not per tool call. If the change is non-visual (data, listings, logs), skip the screenshot and reply in text. ' + |
Member
There was a problem hiding this comment.
Thanks for improving the prompt and the description, it makes sense to only take a screenshot witht these conditions. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Related issues
How AI was used in this PR
Claude Code traced the bug to the gating in
apps/cli/ai/tools/index.ts, threaded the existingremoteSessionruntime flag throughbuildAgentTools, and updated the unit tests to drive the new option directly. It also rewrote the eager wording in the tool description and the matchingREMOTE_SESSION_GUIDANCEblock. I reviewed each diff and verified the behavior locally.Proposed Changes
Gate
share_screenshoton the active runtime, not the feature flagshare_screenshotwas registered wheneverSTUDIO_ENABLE_REMOTE_SESSION=true, so directstudio codesessions also got the tool and the agent kept trying to share screenshots into a void. The flag is meant to opt users into theremote-sessioncommand, not to advertise a Telegram-only tool to every interactive run.isRemoteSessionEnabled()check inresolveStudioToolDefinitionswith a newremoteSessionoption onCreateStudioToolsOptions, mirroring the existingenablePreviewSteeringpattern.remoteSessionvalue (fromconfig.env.STUDIO_REMOTE_SESSION === '1'inapps/cli/ai/runtimes/pi/index.ts) throughbuildAgentToolsinto the tool resolver. The system prompt'sREMOTE_SESSION_GUIDANCEwas already gated on that same runtime signal — only the tool registration was on the wrong flag.apps/cli/ai/mcp-server.ts) callsresolveStudioToolDefinitions()with no options, soshare_screenshotis correctly excluded there too — it would have nowhere to deliver an image from external assistants like Claude Desktop.share-screenshot.tsand rewrote the gating tests to drive the new option instead of mutatingprocess.env.Tone down
share_screenshoteagerness inside remote sessionsREMOTE_SESSION_GUIDANCEechoed it. That phrasing was the proximate reason the agent fired the tool aggressively whenever it was registered.Testing Instructions
STUDIO_ENABLE_REMOTE_SESSION=true npm run cli:build && STUDIO_ENABLE_REMOTE_SESSION=true node apps/cli/dist/cli/main.mjs codeand confirm the agent no longer tries to callshare_screenshotafter visible site changes.studio code remote-session start) and confirm the Telegram bridge still receives screenshots —STUDIO_REMOTE_SESSION=1is set byturn-runner.tsfor the spawned child, so the tool is registered there. Verify the agent now sends one screenshot per milestone instead of one per edit.npm test -- apps/cli/ai/tests/tools.test.ts apps/cli/lib/tests/feature-flags.test.tspasses.npm run typecheckpasses.Pre-merge Checklist