Fix get_terminal_output Invalid ID Handling and Clarify Background Terminal ID Contract#303255
Open
meganrogge wants to merge 3 commits intomainfrom
Open
Fix get_terminal_output Invalid ID Handling and Clarify Background Terminal ID Contract#303255meganrogge wants to merge 3 commits intomainfrom
get_terminal_output Invalid ID Handling and Clarify Background Terminal ID Contract#303255meganrogge wants to merge 3 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the terminal chat agent get_terminal_output tool to better communicate and enforce the “background terminal execution ID” contract and to return a recoverable error when an invalid/unknown ID is provided, reducing agent looping from unclear failures.
Changes:
- Clarifies
get_terminal_outputmodel description and input schema to require the exact opaque ID returned byrun_in_terminalwithisBackground=true(including UUID pattern). - Updates tool invocation to look up the active execution and return an explicit error message when the ID is unknown, avoiding a thrown “Invalid terminal ID”.
- Adds browser unit tests covering the updated schema/description and the new unknown-ID behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.ts | Tightens the ID contract via schema/description and returns explicit errors for unknown executions. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/getTerminalOutputTool.test.ts | Adds tests for the updated contract and runtime behavior. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.ts:28
- The parameter description mixes “ID” and “id” ("exact opaque id returned..."). For consistency with the rest of the text and common acronym capitalization, consider using “ID” throughout (e.g. “exact opaque ID returned…”).
description: `The ID of the background terminal to check (returned by ${TerminalToolId.RunInTerminal} when isBackground=true). This must be the exact opaque id returned by that tool; terminal names, labels, or integers are invalid.`,
pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'
Comment on lines
+56
to
+88
| test('returns explicit error for unknown terminal id', async () => { | ||
| RunInTerminalTool.getExecution = () => undefined; | ||
|
|
||
| const result = await tool.invoke( | ||
| createInvocation('pwsh'), | ||
| async () => 0, | ||
| { report: () => { } }, | ||
| CancellationToken.None, | ||
| ); | ||
|
|
||
| assert.strictEqual(result.content.length, 1); | ||
| assert.strictEqual(result.content[0].kind, 'text'); | ||
| const value = (result.content[0] as { value: string }).value; | ||
| assert.ok(value.includes('No active terminal execution found')); | ||
| assert.ok(value.includes('exact value returned by run_in_terminal')); | ||
| }); | ||
|
|
||
| test('returns output for active terminal id', async () => { | ||
| RunInTerminalTool.getExecution = () => createMockExecution('line1\nline2'); | ||
|
|
||
| const result = await tool.invoke( | ||
| createInvocation('abc'), | ||
| async () => 0, | ||
| { report: () => { } }, | ||
| CancellationToken.None, | ||
| ); | ||
|
|
||
| assert.strictEqual(result.content.length, 1); | ||
| assert.strictEqual(result.content[0].kind, 'text'); | ||
| const value = (result.content[0] as { value: string }).value; | ||
| assert.ok(value.includes('Output of terminal abc:')); | ||
| assert.ok(value.includes('line1\nline2')); | ||
| }); |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
fix #298433
GetTerminalOutputToolis for checking the output of background terminals.cc @Tyriar