Skip to content

Fix agent host SDK terminal tool rendering; disable custom terminal tool by default#318257

Merged
roblourens merged 3 commits into
mainfrom
agents/vsckb-implement-there-s-a-strange-problem-when-48238e14
May 26, 2026
Merged

Fix agent host SDK terminal tool rendering; disable custom terminal tool by default#318257
roblourens merged 3 commits into
mainfrom
agents/vsckb-implement-there-s-a-strange-problem-when-48238e14

Conversation

@roblourens
Copy link
Copy Markdown
Member

@roblourens roblourens commented May 25, 2026

Two related changes for the agent host SDK terminal tool experience.

1. Normalize LF to CRLF in agent host terminal tool output

The detached xterm used to render terminal tool output (DetachedTerminalSnapshotMirror.render() in chatTerminalCommandMirror.ts) calls terminal.xterm.write(text), which treats input as a raw TTY stream. A lone \n is just LF (cursor moves down, column unchanged), so subsequent lines start at whatever column the previous line ended producing a staircase.on

Example SDK output:

394:\tsshConfigHost: hostAlias,\n541:\tconst expectedKey = config.sshConfigHost\n542:\t\t? `ssh:${config.sshConfigHost}`\n

Rendered as:

394:                    sshConfigHost: hostAlias,
                                                 541:   const expectedKey = config.sshConfigHost
                                                                                                  542:            ? `ssh:${config.sshConfigHost}`

Why the custom terminal tool didn't hit this

xterm's serialize addon, which emits proper VT with \r\n. The agent host SDK path in stateToProgressAdapter.getTerminalOutput() just passed the SDK's plain text through unchanged.

Fix

\r\n in the adapter boundary where SDK content is shaped intoterminalCommandOutput. This:getTerminalOutput()

  • keeps the custom-tool path untouched (already VT-correct);
  • is co-located with the other SDK conversions;
  • is idempotent on already-CRLF input.

Added a regression test covering mixed \n / \r\n input and updated two existing assertions in agentHostChatContribution.test.ts that exercised the same path.

2. Disable agent host custom terminal tool by default

Changed the default of chat.agentHost.customTerminalTool.enabled from true to false, so Copilot SDK sessions use the SDK's default terminal behavior out of the box. Users who want the Agent Host terminal tool override can still opt in.

(Written by Copilot)

The detached xterm used to render terminal tool output treats input as a
raw TTY stream where a lone \n is just LF (cursor moves down without
column reset), producing a staircase rendering.

The custom terminal tool's output goes through xterm's serialize addon
which emits proper VT with \r\n line endings. The agent host SDK path,
however, was passing the SDK's plain text through unchanged, so multi-line
output rendered with each line starting at the column where the previous
one ended.

Normalize \n to \r\n in getTerminalOutput, the adapter boundary where SDK
content is shaped into terminalCommandOutput. The replace is idempotent
on already-CRLF input.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 25, 2026 22:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes staircase rendering of multi-line terminal tool output for agent-host SDK terminal tools by normalizing \n to \r\n in the adapter that produces terminalCommandOutput.text, so the detached xterm (which treats input as raw TTY) advances both row and column.

Changes:

  • Normalize lone LF to CRLF in getTerminalOutput at the SDK-to-protocol adapter boundary.
  • Add a regression test covering mixed \n / \r\n inputs.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts Replace \r?\n with \r\n in getTerminalOutput, with explanatory comment.
src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts New test asserting CRLF normalization in finalized terminal tool output.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Two assertions checked the previous raw \n output from getTerminalOutput;
update them to expect the normalized \r\n.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens marked this pull request as ready for review May 25, 2026 23:34
@roblourens roblourens enabled auto-merge (squash) May 25, 2026 23:34
Change the default of chat.agentHost.customTerminalTool.enabled from true
to false so Copilot SDK sessions use the SDK's default terminal behavior
out of the box.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens changed the title Normalize LF to CRLF in agent host terminal tool output Fix agent host SDK terminal tool rendering; disable custom terminal tool by default May 25, 2026
@roblourens roblourens merged commit 83020e6 into main May 26, 2026
25 checks passed
@roblourens roblourens deleted the agents/vsckb-implement-there-s-a-strange-problem-when-48238e14 branch May 26, 2026 00:51
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 26, 2026
anthonykim1 added a commit that referenced this pull request May 26, 2026
Squashed cherry-pick of 10 commits from main that are included in the
Insiders build (183159e) people are verifying:

- agentHost: show fetched URL for web_fetch (#318240)
- Fix SSH remote agent host passphrase auth (#318244)
- agentHost: add setting to disable worktreeCreated task auto-dispatch (#318243)
- Agent host: clearer worktree git timeout errors and 60s budget (#318242)
- Normalize LF to CRLF in agent host terminal tool output (#318257)
- sessions: restore X-button removal of SSH remote agent host entries (#318262)
- chat: fix duplicate command registration for agent-host-copilotcli (#318273)
- launch: build copilot in compile; wait for CDP in launch.sh (#318272)
- Preserve unread state across remote host disconnect (#318267)
- Add more codenotify for terminal (#318285)
dileepyavan pushed a commit that referenced this pull request May 27, 2026
Squashed cherry-pick of 10 commits from main that are included in the
Insiders build (183159e) people are verifying:

- agentHost: show fetched URL for web_fetch (#318240)
- Fix SSH remote agent host passphrase auth (#318244)
- agentHost: add setting to disable worktreeCreated task auto-dispatch (#318243)
- Agent host: clearer worktree git timeout errors and 60s budget (#318242)
- Normalize LF to CRLF in agent host terminal tool output (#318257)
- sessions: restore X-button removal of SSH remote agent host entries (#318262)
- chat: fix duplicate command registration for agent-host-copilotcli (#318273)
- launch: build copilot in compile; wait for CDP in launch.sh (#318272)
- Preserve unread state across remote host disconnect (#318267)
- Add more codenotify for terminal (#318285)
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.

3 participants