Make console session commands agent-invocable - #15138
Merged
Merged
Conversation
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. |
Give the Start New Console Session and Select Session commands an optional
id argument so they can run without any user interaction, and report their
outcome as data so a programmatic caller can tell a real change apart from a
picker the user dismissed.
- startNewConsoleSession takes a runtimeId and returns
{ started, sessionId, message }; selectSession takes a sessionId and
returns { selected, sessionId, message }.
- A supplied id that names no runtime or session, or names a session that
has exited, throws instead of falling back to the picker, which would
leave a programmatic caller waiting on the user.
- The exited-session check reuses the state filter the session picker
already applies, extracted as isActiveSessionState.
- Both commands still open their picker when no id is supplied, so the
command palette, keybinding, and menu paths are unchanged.
- Promote both anonymous action classes to exported StartNewConsoleSessionAction
and SelectSessionAction for testability, and move selectSession off the
shared registerLanguageRuntimeAction helper so it can carry arg metadata.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
dhruvisompura
force-pushed
the
dhruvi/agent-compatible-console
branch
from
August 4, 2026 22:59
27a51d7 to
b860504
Compare
dhruvisompura
marked this pull request as ready for review
August 5, 2026 00:41
midleman
approved these changes
Aug 5, 2026
midleman
left a comment
Contributor
There was a problem hiding this comment.
Looks good! I played with it quite a bit and it seems to be working quite well. :) Some scenarios I tested:
- starting console session via command
- switching console session via command
- switching to notebook session via command (this was cool, it switches focus to the notebook tab and the console session tab)
- starting notebook runtime via command
- commands working post window reload
- commands working post session restart
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Addresses part of #15063.
Summary
Makes two console commands invocable by Posit Assistant:
workbench.action.language.runtime.startNewConsoleSession: gains aruntimeIdargument. When supplied, the session starts headless (no runtime picker); an unknown id throws sopositron.ai.validateAndExecuteCommandreports{ok: false}instead of silently succeeding. The anonymous action class is promoted to an exportedStartNewConsoleSessionActionfor testability.workbench.action.language.runtime.selectSession: same treatment with asessionIdargument (SelectSessionAction), converted off the sharedregisterLanguageRuntimeActionhelper so it can carry arg metadata. An id naming a session that has exited throws too, because the session picker already leaves exited sessions out and selecting one by id shouldn't get around that.Both commands only show interactive pickers if a runtimeId/sessionId is not provided which lets us programmatically execute the command without interruption. If the id is omitted the picker still opens and waits on the user, and the command has no way to tell an agent caller from a human one (nothing in
ICommandServicecarries the caller, andvalidateAndExecuteis deliberately not a policy gate -- see posit-dev/assistant#1810). So the id is declared required in the agent metadata thatpositron.ai.getAgentAllowedCommands()reports, while the argument stays optional in code to keep the palette, keybinding, and menu paths working.Both commands also report their outcome as data now:
startNewConsoleSessionreturns{started, sessionId, message}andselectSessionreturns{selected, sessionId, message}. Without this, a picker the user dismissed reached Assistant asRan '<command id>'., which reads as success even though nothing happened.startNewConsoleSessionused to return a bare session id string, soselectLanguageRuntimeSessionnow readssessionIdoff the result -- that's the "New Console Session..." item inside the Select Session picker.MAJOR GAP
This PR only updates the commands to be non-interactive but doesn't make them usable by Assistant without some additional context.
Posit Assistant does not currently have a way to learn what a valid
runtimeId/sessionIdvalue is. These are currently internal values within Positron. The initial plan was to leveragegetRegisteredRuntimes()to create a mapping of runtimes to their IDs forworkbench.action.language.runtime.startNewConsoleSessionand provide that context alongside the system prompt. I was going to do something similar forworkbench.action.language.runtime.selectSession.Given that we want to move away from putting context in the system prompt, we need to provide this context some other way. We can't add new tools to Assistant, so the stepping stone is still two commands (
getRuntimeIds,getSessionIds) that Assistant can run throughpositronCommandto get the information it needs, readinggetRegisteredRuntimes()andactiveSessionson the Positron side. We document all four commands in the same reference file and tell Assistant how to use them together. Tracking that in #15346.One lookup fewer than planned:
startNewConsoleSessionnow returns the newsessionId, so starting a session and then making it active doesn't needgetSessionIdsat all. AndgetSessionIdscan filter with theisActiveSessionStatehelper this PR extracts, so the sessions it lists are exactly the onesselectSessionwill accept.Screenshots
Took some videos to show that the existing behavior has not changed
15138-switchSession.mp4
15138-startSession.mp4
15138-newSessionFromPicker.mp4
15138-dismissPickers.mp4
Release Notes
New Features
Bug Fixes
Validation Steps
@:console @:sessions
Verify user behavior is unchanged
Esc. Verify nothing starts and no error notification appears.+button in the Console pane title bar still opens the runtime picker.Verify the commands are advertised to Assistant
workbench.action.language.runtime.startNewConsoleSessionandworkbench.action.language.runtime.selectSessionappear, each with itsargsentry (required: true,type: "string") and areturnsdescription.Verify the non-interactive path
SETUP: get a real
runtimeIdandsessionIdfor an existing session via the Runtimes debug panel (enableinterpreters.showSessionssetting to see it). The ID field in the table is the session ID.keybindings.jsonentries and press each key. Verify the session starts / becomes active with no picker opening:{ "key": "cmd+1", "command": "workbench.action.language.runtime.startNewConsoleSession", "args": "<runtimeId>" }, { "key": "cmd+2", "command": "workbench.action.language.runtime.selectSession", "args": "<sessionId>" }argsvalues to"does-not-exist"and press each key again. Verify each one fails with an error instead of opening a picker (a keybinding surfaces the thrown message as a warning notification).selectSessionbinding'sargsto that exited session's id. Verify it fails withSession '<id>' has exited and cannot be made the active session.and the active session does not change.