Skip to content

Fix terminal progress for built-in SDK bash tool#320251

Open
roblourens wants to merge 4 commits into
mainfrom
agents/vsckb-implement-look-at-the-terminal-tool-for-7a64b2fd
Open

Fix terminal progress for built-in SDK bash tool#320251
roblourens wants to merge 4 commits into
mainfrom
agents/vsckb-implement-look-at-the-terminal-tool-for-7a64b2fd

Conversation

@roblourens
Copy link
Copy Markdown
Member

@roblourens roblourens commented Jun 6, 2026

Fix #318458

When the Custom Terminal tool is disabled and the Agent Host SDK's built-in bash tool runs commands, no Terminal content block is emitted. The live Running/Completed path in toolCallStateToInvocation only set terminal toolSpecificData when getTerminalContentUri returned a URI, so built-in bash invocations never got the terminal pill and fell back to the generic tool widget showing just the first line of the command.

Fix

Match the fallback already present in the history-replay path (completedToolCallToSerialized) and in finalizeToolInvocation: also treat the tool as a terminal tool when getToolKind(tc) === 'terminal'. AHP-only fields (terminalToolSessionId, terminalCommandUri) stay undefined for built-in bash where they don't apply.

Also extends updateRunningToolSpecificData to refresh terminalCommandOutput as text content streams in, spreading the existing toolSpecificData so the async _reviveTerminalIfNeeded population of AHP fields is preserved if a Terminal block does arrive.

Tests

Adds 3 new tests in stateToProgressAdapter.test.ts covering: built-in bash terminal toolSpecificData (no Terminal content block), CRLF output normalization on completion, streaming output refresh, and AHP-field preservation on refresh. All 60 stateToProgressAdapter and 514 agentSessions tests pass.

roblourens and others added 2 commits June 6, 2026 10:52
When the Custom Terminal tool is disabled and the Agent Host SDK's
built-in bash tool runs commands, no Terminal content block is emitted.
The live Running/Completed path in toolCallStateToInvocation only set
terminal toolSpecificData when getTerminalContentUri returned a URI,
so built-in bash invocations never got the terminal pill and fell back
to the generic tool widget showing just the first line of the command.

Match the fallback already present in the history-replay path and in
finalizeToolInvocation: also treat the tool as terminal when
getToolKind(tc) === 'terminal'. AHP-only fields (terminalToolSessionId,
terminalCommandUri) stay undefined for built-in bash.

Also extend updateRunningToolSpecificData to refresh terminalCommandOutput
as text content streams in, spreading the existing toolSpecificData so
the async _reviveTerminalIfNeeded population of AHP fields is preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 6, 2026 17:52
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

This PR fixes terminal progress rendering for the Agent Host SDK’s built-in bash tool when the Custom Terminal tool is disabled, ensuring terminal-style tool invocations still show the terminal pill (expandable command + output) even without an AHP Terminal content block.

Changes:

  • Treat tool calls as terminal invocations when getToolKind(tc) === 'terminal', even if no terminal content URI is present.
  • Refresh terminalCommandOutput during running updates as text content streams in, while preserving any asynchronously revived AHP terminal fields.
  • Add targeted unit tests covering built-in bash terminal toolSpecificData, CRLF normalization, streaming refresh, and AHP-field preservation.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts Ensures terminal tool invocations are created/updated based on toolKind === 'terminal' and keeps terminal output current during streaming.
src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts Adds test coverage for built-in bash terminal invocation behavior, output normalization, streaming refresh, and field preservation.

Copilot's findings

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

roblourens and others added 2 commits June 6, 2026 13:49
Five sites in stateToProgressAdapter were inlining nearly identical
IChatTerminalToolInvocationData payloads (pending confirmation, live
create, streaming refresh, finalize, history replay), each with subtly
different field-preservation rules and four near-duplicate isTerminal
predicates. Extract two helpers:

- isTerminalToolCall(tc,  single source of truth forexistingKind?)
  the three terminal-detection signals (existing kind, _meta.toolKind,
  Terminal content block) with rationale documented in JSDoc.
- buildTerminalToolSpecificData(tc, sessionResource,  buildsexisting?)
  the payload status-agnostically with consistent fallback semantics so
  AHP fields populated asynchronously by _reviveTerminalIfNeeded survive
  later refreshes. Completion-only fields (terminalCommandState) are
  layered on by the caller.

updateRunningToolSpecificData now takes a sessionResource: URI parameter
to thread through to the helper; the production caller in
agentHostSessionHandler passes opts.backendSession and the test wrapper
passes URI.file('/').

No behavior change. All 59 stateToProgressAdapter tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The dedupe refactor was dropping terminalCommandId (and would silently
drop any other field on IChatTerminalToolInvocationData not explicitly
handled by the helper). Spread `existing` into the returned object so
prior-pass fields survive unless we have a fresh value to override them
 this matches the original site-specific code that spreadwith
`existing` directly.

Also rename a misleading test ('picks up text output on completion')
that actually exercises the running-state codepath (per Copilot review
comment on PR #320251).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens marked this pull request as ready for review June 6, 2026 21:39
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.

AgentHost: issues with builtin SDK bash tool

3 participants