Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3990,6 +3990,20 @@ export class CopilotAgentSession extends Disposable {

this._register(wrapper.onToolPartialResult(e => {
this._logService.trace(`[Copilot:${sessionId}] Tool partial result: ${e.data.toolCallId} (${e.data.partialOutput.length} chars)`);
const tracked = this._activeToolCalls.get(e.data.toolCallId);
if (!tracked || !isShellTool(tracked.toolName)) {
return;
}
// TODO: Use terminal-specific AHP content once live shell output is modeled separately from terminalComplete.preview.
this._emitAction({
type: ActionType.ChatToolCallContentChanged,
turnId: this._turnId,
toolCallId: e.data.toolCallId,
content: [
...tracked.content.filter(content => content.type !== ToolResultContentType.Text),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would ideally want something like: ToolResultContentType.TerminalOutput or TerminalStreaming, etc. not Text.

@anthonykim1 anthonykim1 Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Perhaps I should need to revisit ToolResultContentType in ahp. Maybe add a new type like TerminalProgress / CommandProgress , TerminalSnapShot , or evolve the TerminalComplete after changing name.. and then adding status: 'running' | completed, etc

{ type: ToolResultContentType.Text, text: e.data.partialOutput },
],
}, tracked.parentToolCallId);
}));

this._register(wrapper.onToolProgress(e => {
Expand Down
76 changes: 76 additions & 0 deletions src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,82 @@ suite('CopilotAgentSession', () => {
assert.strictEqual((toolStart.action as ChatToolCallStartAction).intention, 'List files in the repo root');
});

test('tool partial results stream cumulative output as running content', async () => {
const { session, mockSession, signals, waitForSignal } = await createAgentSession(disposables);
session.resetTurnState('turn-stream');

mockSession.fire('tool.execution_start', {
toolCallId: 'tc-stream',
toolName: 'bash',
arguments: { command: 'print ticks', description: 'Print ticks' },
} as SessionEventPayload<'tool.execution_start'>['data']);
mockSession.fire('tool.execution_partial_result', {
toolCallId: 'tc-stream',
partialOutput: 'tick 1\n',
} as SessionEventPayload<'tool.execution_partial_result'>['data']);
mockSession.fire('tool.execution_partial_result', {
toolCallId: 'tc-stream',
partialOutput: 'tick 1\ntick 2\n',
} as SessionEventPayload<'tool.execution_partial_result'>['data']);
mockSession.fire('tool.execution_complete', {
toolCallId: 'tc-stream',
success: true,
result: { content: 'tick 1\ntick 2\n' },
} as SessionEventPayload<'tool.execution_complete'>['data']);
await waitForSignal(signal => isAction(signal, ActionType.ChatToolCallComplete));

assert.deepStrictEqual(getActions(signals)
.filter(action => action.type === ActionType.ChatToolCallContentChanged)
.map(action => ({
turnId: action.turnId,
toolCallId: action.toolCallId,
content: action.content,
})), [
{
turnId: 'turn-stream',
toolCallId: 'tc-stream',
content: [{ type: ToolResultContentType.Text, text: 'tick 1\n' }],
},
{
turnId: 'turn-stream',
toolCallId: 'tc-stream',
content: [{ type: ToolResultContentType.Text, text: 'tick 1\ntick 2\n' }],
},
]);
const completed = getActions(signals).find(action => action.type === ActionType.ChatToolCallComplete) as ChatToolCallCompleteAction;
assert.deepStrictEqual(completed.result.content, [
{ type: ToolResultContentType.Text, text: 'tick 1\ntick 2\n' },
]);
});

test('tool partial results for untracked tools are ignored', async () => {
const { mockSession, signals } = await createAgentSession(disposables);

mockSession.fire('tool.execution_partial_result', {
toolCallId: 'tc-untracked',
partialOutput: 'orphaned output',
} as SessionEventPayload<'tool.execution_partial_result'>['data']);

assert.deepStrictEqual(getActions(signals), []);
});

test('tool partial results for tracked non-shell tools are ignored', async () => {
const { mockSession, signals } = await createAgentSession(disposables);

mockSession.fire('tool.execution_start', {
toolCallId: 'tc-non-shell',
toolName: 'grep',
arguments: { pattern: 'needle' },
} as SessionEventPayload<'tool.execution_start'>['data']);
mockSession.fire('tool.execution_partial_result', {
toolCallId: 'tc-non-shell',
partialOutput: 'unexpected partial output',
} as SessionEventPayload<'tool.execution_partial_result'>['data']);

assert.deepStrictEqual(getActions(signals)
.filter(action => action.type === ActionType.ChatToolCallContentChanged), []);
});

test('live tool_start strips redundant cd prefix matching workingDirectory', async () => {
const wd = URI.file('/repo/project');
const { mockSession, signals } = await createAgentSession(disposables, { workingDirectory: wd });
Expand Down
Loading