Skip to content

Dispose non-PTY shell output resources after command completion #327178

Description

@anthonykim1

Related: microsoft/agent-host-protocol#352 and #327067

Runtime shell output is streamed through one agenthost-terminal://shell/<session>/<toolCall> output-only resource per shell tool call. These are not PTYs and do not create terminal processes.

The workbench subscription normally goes away when the turn ends, but the host keeps the completed resource and its buffered output in _outputTerminals / NonPtyShellTerminalStreams._streams until the Copilot session is idle-released, deleted, or shut down. For a long-lived open session, completed resources grow with every shell call.

AHP now carries the final preview, exitCode, and truncated state on TerminalCommandResult, and completed history already knows how to render that static result. Once the final result has been published, the live output channel should no longer be needed.

Would like the lifecycle to be:

  • create a unique output resource while a shell call is running;
  • stream through it while live;
  • publish the final terminal result;
  • switch completed rendering to the static result;
  • unsubscribe and dispose the output resource/remove its stream entry.

For isPty: false, completed history should not try to revive or recreate a terminal. Calls without authoritative completion metadata, such as a background shell handoff, should remain alive until a later completion signal or normal session teardown.

Metadata

Metadata

Assignees

Labels

agent-hostIssues for the agent-host implementation (not the protocol)debtCode quality issuesinsiders-releasedPatch has been released in VS Code InsidersterminalGeneral terminal issues that don't fall under another label

Type

No type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions