fix(swift): advertise generated PROTOCOL_VERSION on initialize#232
Open
colbylwilliams wants to merge 3 commits into
Open
fix(swift): advertise generated PROTOCOL_VERSION on initialize#232colbylwilliams wants to merge 3 commits into
colbylwilliams wants to merge 3 commits into
Conversation
Remove the stale hard-coded `private let supportedProtocolVersion = "0.2.0"` constant from HostRuntime.swift. The comment attached to it claimed the Swift types library didn't ship a version constant yet — that was already false. The generated file Version.generated.swift has exported PROTOCOL_VERSION and SUPPORTED_PROTOCOL_VERSIONS since protocol 0.4.0 (and HostRuntime.swift already imports AgentHostProtocol, so those symbols were always in scope). Changes: - Replace both `protocolVersions: [supportedProtocolVersion]` call sites (lines 335 and 347, the fresh-connect and fall-back-from-reconnect paths) with `protocolVersions: SUPPORTED_PROTOCOL_VERSIONS`, so the client advertises the full negotiation list ["0.4.0", "0.3.0"] on every initialize call instead of the stale single version "0.2.0". - Delete the now-obsolete constant declaration and its TODO(codegen) comment. - Add MultiHostClientTests.testHostRuntimeAdvertisesSupportedProtocolVersionsOnInitialize which spins up a MultiHostClient with an InMemoryTransport fake host, captures the protocolVersions list sent in the initialize request, and asserts it equals SUPPORTED_PROTOCOL_VERSIONS and does not contain "0.2.0". - CHANGELOG: add Fixed bullet to clients/swift/CHANGELOG.md. Closes #224 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Swift MultiHostClient/HostRuntime protocol negotiation drift by removing a stale hard-coded protocol version and advertising the generated SUPPORTED_PROTOCOL_VERSIONS during initialize, with a regression test and changelog entry.
Changes:
- Updated
HostRuntimeto passSUPPORTED_PROTOCOL_VERSIONSintoAHPClient.initialize(...)(including the reconnect→initialize fallback path). - Added an integration test that captures the
initializerequest’sprotocolVersionsand asserts it matchesSUPPORTED_PROTOCOL_VERSIONS(and does not include"0.2.0"). - Added a Swift client changelog bullet under
## [Unreleased]→### Fixed.
Show a summary per file
| File | Description |
|---|---|
clients/swift/AgentHostProtocol/Sources/AgentHostProtocolClient/Hosts/HostRuntime.swift |
Replaces stale per-runtime version constant usage with generated SUPPORTED_PROTOCOL_VERSIONS during initialize. |
clients/swift/AgentHostProtocol/Tests/AgentHostProtocolClientTests/MultiHostClientTests.swift |
Adds a fake-host test harness to capture and assert advertised protocolVersions. |
clients/swift/CHANGELOG.md |
Documents the user-visible fix in the Swift package changelog. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 3
- CHANGELOG: remove hard-coded version list from Fixed bullet so it stays accurate if SUPPORTED_PROTOCOL_VERSIONS changes before release. - InitVersionCapture: use explicit hasStored flag so subsequent store() calls are no-ops regardless of whether the first went through the waiter or captured path. - testHostRuntimeAdvertises...: wrap capture.wait() in a 2-second timeout (withThrowingTaskGroup + TestTimeoutError) so the test fails quickly with a useful error rather than hanging indefinitely if the initialize params are never captured. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
C0deKing
approved these changes
Jun 16, 2026
…ift-advertise-protocol-version
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.
Problem
HostRuntime.swiftcontained a stale hard-coded constant:This was wrong on two counts:
"0.2.0"is stale — the protocol is now0.4.0.Version.generated.swiftalready exportsPROTOCOL_VERSIONandSUPPORTED_PROTOCOL_VERSIONS, andHostRuntime.swiftalreadyimport AgentHostProtocol, so those symbols were always in scope.Changes
HostRuntime.swift— replaced bothprotocolVersions: [supportedProtocolVersion]call sites (fresh-connect path at line 335, and the fall-back-from-reconnect path at line 347) withprotocolVersions: SUPPORTED_PROTOCOL_VERSIONS. Deleted the stale constant and its now-incorrect doc comment/TODO.MultiHostClientTests.swift— addedtestHostRuntimeAdvertisesSupportedProtocolVersionsOnInitialize: spins up aMultiHostClientwith anInMemoryTransportfake host, captures theprotocolVersionslist sent in theinitializerequest, and asserts it equalsSUPPORTED_PROTOCOL_VERSIONSand does not contain"0.2.0".clients/swift/CHANGELOG.md— added a### Fixedbullet under## [Unreleased].This is not a codegen change — no
*.generated.swiftfile was modified andscripts/generate-swift.tswas not touched.Validation
Closes #224