Cap get_terminal_output first-poll and non-prefix responses to a tail#320140
Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @anthonykim1Matched files:
|
There was a problem hiding this comment.
Pull request overview
This PR further reduces get_terminal_output payload sizes (when chat.tools.terminal.outputDeltas is enabled) by tail-truncating the first poll and non-prefix fallback responses to ~8 KB (line-aligned), preventing Copilot SDK spillover thrash while keeping full-buffer snapshotting for delta detection.
Changes:
- Add an internal 8 KB “tail budget” and tail-formatting helper to cap first-poll and non-prefix-fallback outputs.
- Preserve full-buffer snapshot (length + hash) so unchanged/delta detection continues to work.
- Add unit tests for tail behavior on first poll and on non-prefix fallback.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.ts | Adds tail-capping helpers and applies them to first-poll and non-prefix fallback outputs under the output-deltas experiment. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/getTerminalOutputTool.test.ts | Adds tests validating tail truncation behavior for large outputs on first poll and non-prefix fallback. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.ts:117
- When output exceeds the tail budget, the first poll returns only a tail, but the unchanged-marker still says "(… characters already shown)". That text becomes inaccurate/misleading because the tool did not actually return the full buffer previously, only the tail. Consider adjusting the unchanged-marker when
output.lengthexceeds the tail budget so it doesn’t imply the full output was already shown.
if (currentOutputSnapshot.length === previousOutputSnapshot.length && currentOutputSnapshot.hash === previousOutputSnapshot.hash) {
return `Output of terminal ${id} unchanged since previous poll (${output.length} characters already shown). No new output.`;
}
- Files reviewed: 2/2 changed files
- Comments generated: 1
|
/requires-eval-assessment terminalbench2 gpt-5.4,claude-opus-4.6,claude-opus-4.7 |
|
⏳ Queued vscode build for
|
…l output was previously returned
|
⏳ Queued vscode build for
|
|
🚀 Queued eval-assessment publish build for
|
|
🔬 Queued eval-assessment benchmark for
Results will be posted back here when the run completes. |
|
✅ Eval-assessment build published.
|
|
📊 Eval-assessment benchmark complete.
🧪 Results |
|
📊 Eval-assessment benchmark complete.
🧪 Results |
|
📊 Eval-assessment benchmark complete.
🧪 Results |
Fixes the spillover side of microsoft/vscode-internalbacklog#7869.
PR #315543 already shrinks repeated
get_terminal_outputpolls by returning only the delta. But the first poll and the non-prefix fallback still returned the full buffer (up to the ~60 KB upstream cap inoutputHelpers.ts), which is well above the Copilot SDK's ~10 KB spillover threshold and causes the agent to thrash withread_filecalls on the spillover temp file.This change adds a second, tighter cap inside the tool itself: when the full output exceeds 8 KB, return only the last 8 KB (line-aligned). The truncation marker includes both the omitted character count and a hint telling the agent how to recover the head if it needs to: re-run the command and redirect output to a file, then read that file.
Snapshot tracking (length + hash) still uses the full buffer, so subsequent delta polls work unchanged.
Behavior
The tail cap applies on every code path (always on — not gated by an experiment), because the SDK spillover issue affects all users regardless of whether
chat.tools.terminal.outputDeltasis enabled. The delta-tracking semantics introduced by #315543 remain gated by that experiment.unchanged since previous pollmarker (no output).Risks / follow-ups
\nin the last 8 KB fall back to a raw character cut, which could land mid-ANSI-escape. Rare.Tests
getTerminalOutputTool.test.ts— all 11 tests pass, including two added for the new behavior:returns only the tail on first poll when output exceeds the tail budgetreturns only the tail on non-prefix fallback when output exceeds the tail budget