agentHost: adopt OTEL log channel, support logs from remote agent hosts#317876
Merged
Conversation
Wires up the new `channels-otlp/` protocol so the agent host's
`ILogService` is mirrored over an `ahp-otlp://logs/{level}` channel
and surfaced as a per-host Output channel in the workbench.
- Add `OtlpLogEmitter` / `OtlpEmitterLogger` (`platform/agentHost/common/otlp/`).
`LogService` is constructed with the OTLP logger as a secondary sink in both
`agentHostMain.ts` and `agentHostServerMain.ts` so every log call fans out
to subscribers.
- `ProtocolServerHandler` advertises `telemetry.logs` in
`InitializeResult`, routes `subscribe`/`unsubscribe` on `ahp-otlp:`
channels through a typed `ChannelSubscription` union, canonicalises the
channel URI per-level, and broadcasts `otlp/exportLogs` notifications
filtered per subscriber severity.
- `RemoteAgentHostProtocolClient` stores the full `InitializeResult`,
adds `subscribeStateless` and `onDidReceiveOtlpLogs`.
- New `RemoteAgentHostLogForwarder` in the workbench layer registers an
`Agent Host (${host})` Output channel via `IOutputChannelRegistry`,
subscribes at the workbench's `ILogService` level (re-subscribes on
change), and appends decoded records. Constructed from
`remoteAgentHost.contribution.ts::_setupConnection` so it covers
WebSocket, SSH and tunnel paths. Local agent host IPC logging is
unchanged.
- Existing remote IPC traffic channel renamed to `Agent Host IPC (${host})`
to disambiguate from the new OTLP-derived channel.
- Move `UriTemplate` from `workbench/contrib/mcp/common/` to
`base/common/` so the forwarder can use it for `{level}` expansion.
Tests: 8 unit tests for the emitter, 7 for the server-side OTLP routing
(including URI canonicalisation), 3 integration tests for the
end-to-end wire flow, and the existing protocol/handshake/reconnect
suites.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Yoyokrazy
approved these changes
May 21, 2026
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.
Wires up the new
channels-otlp/protocol so the agent host'sILogServiceis mirrored over anahp-otlp://logs/{level}channel and surfaced as a per-host Output channel in the workbench.What changed
Agent host (server)
OtlpLogEmitter/OtlpEmitterLoggerinplatform/agentHost/common/otlp/.LogServiceis constructed with the OTLP logger as a secondary sink in bothagentHostMain.tsandagentHostServerMain.tsso every log call fans out to subscribers.ProtocolServerHandleradvertisestelemetry.logsinInitializeResult, routessubscribe/unsubscribeonahp-otlp:channels through a typedChannelSubscriptiondiscriminated union, canonicalises the channel URI per-level, and broadcastsotlp/exportLogsnotifications filtered per subscriber severity.Workbench (client)
RemoteAgentHostProtocolClientcaptures the fullInitializeResult, exposessubscribeStateless, and firesonDidReceiveOtlpLogsfor inbound batches.RemoteAgentHostLogForwarder(insessions/contrib/providers/remoteAgentHost/browser/) registers a per-hostAgent Host (${host})Output channel viaIOutputChannelRegistry, subscribes at the workbench'sILogServicelevel (re-subscribes on change), and appends decoded records. Constructed fromremoteAgentHost.contribution.ts::_setupConnectionso it covers the WebSocket, SSH and tunnel paths uniformly. Local agent host IPC logging is unchanged.Agent Host IPC (${host})to disambiguate from the new OTLP-derived channel.Shared utilities
UriTemplatemoves fromworkbench/contrib/mcp/common/tobase/common/so the forwarder can useUriTemplate.parse(template).resolve({ level })for spec-conformant{level}expansion. MCP imports updated.Why
The remote agent host already produces structured logs via its
ILogService, but until now there was no path for clients to observe them. With this change a remote host's logs (whether spawned over WebSocket, SSH or a dev tunnel) automatically appear in the user's Output panel asAgent Host (${name}), alongside the existingAgent Host IPC (${name})wire-traffic channel.Notes for reviewers
LoggerChannel(out-of-bounds log forwarding) — only remote connections opt into the OTLP path. This avoids duplicating the existing local Output channel._attachshort-circuits while notConnectedso reconnect cycles don't leak stale subscriptions if the workbench log level changes mid-drop.Tests
OtlpLogEmitterand helpers (level mappings, payload encode/decode, template expansion).otlpLogs.integrationTest.ts).UriTemplatetests (moved alongside the file).Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com