agentHost: integrate terminals with tool call#308866
Merged
connor4312 merged 4 commits intomainfrom Apr 9, 2026
Merged
Conversation
We need proper command detection to make this work flawlessly, but this does the initial hookup replacing the copilot SDK's terminal tools with our tools which are backed by real PTY's.
Contributor
Screenshot ChangesBase: Changed (83)Added (8) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires agent-host tool calls to real, PTY-backed terminals by introducing a shared terminal service on the renderer side and overriding Copilot SDK shell tools on the agent-host side to use the agent host terminal manager.
Changes:
- Add
IAgentHostTerminalServiceto create/revive agent-host terminals and updateAgentHostPtyto support “attach-only” mode for tool-owned terminals. - Extend chat tool invocation rendering by introducing an observable
toolSpecificDataKind, and refactor agent-host session handling to revive/register terminals for tool calls and support “Continue in Background”. - Add PTY-backed shell tool overrides (
bash/powershell+ companion tools) using a per-sessionShellManager, and expose the agent-host terminal manager via DI.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts | Registers IAgentHostTerminalService singleton. |
| src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.ts | New service to create/revive terminals backed by AgentHostPty. |
| src/vs/workbench/contrib/terminal/browser/agentHostTerminalContribution.ts | Switches profile creation to use IAgentHostTerminalService. |
| src/vs/workbench/contrib/terminal/browser/agentHostPty.ts | Adds attachOnly option to avoid creating/disposing tool-owned terminals. |
| src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.ts | Tracks toolSpecificData.kind via observable to trigger re-render. |
| src/vs/workbench/contrib/chat/common/chatService/chatService.ts | Adds toolSpecificDataKind to IChatToolInvocation. |
| src/vs/workbench/contrib/chat/browser/widget/.../chatToolInvocationPart.ts | Re-renders tool invocation part when data kind changes. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts | Exposes terminal URI detection + adds terminal tool session id into terminal tool data. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Revives/registers agent-host terminals for tool calls; “continue in background” claim narrowing; refactors turn processing. |
| src/vs/platform/agentHost/node/agentHostTerminalManager.ts | Exposes terminal events/content APIs; supports specifying shell executable. |
| src/vs/platform/agentHost/node/agentService.ts | Exposes terminal manager instance for agent providers. |
| src/vs/platform/agentHost/node/agentHost{Main,ServerMain}.ts | Registers IAgentHostTerminalManager in DI. |
| src/vs/platform/agentHost/node/copilot/copilotShellTools.ts | New PTY-backed shell tool overrides + ShellManager. |
| src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts | Adds isShellTool and unwraps custom-tool shell args for display/input. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Creates ShellManager per session and injects shell tools into SDK session config. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Disposes ShellManager; normalizes permission kinds; includes terminal content refs for shell tools on completion. |
| src/vs/platform/agentHost/common/state/sessionReducers.ts | Removes VS Code-specific tool metadata helpers. |
| src/vs/workbench/contrib/chat/test/... | Updates mocks to satisfy new toolSpecificDataKind requirement. |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Adjusts session construction for new ctor parameter. |
| .vscode/launch.json | Improves agent-host attach debugging and adds compound config. |
Copilot's findings
- Files reviewed: 24/24 changed files
- Comments generated: 3
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
Outdated
Show resolved
Hide resolved
roblourens
previously approved these changes
Apr 9, 2026
mjbvz
previously approved these changes
Apr 9, 2026
mjbvz
approved these changes
Apr 9, 2026
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.
We need proper command detection to make this work flawlessly, but this does the initial hookup replacing the copilot SDK's terminal tools with our tools which are backed by real PTY's.