From dee1ef35b9759c02b4627e0dd106463e219a4d57 Mon Sep 17 00:00:00 2001 From: shijing xian Date: Wed, 17 Jun 2026 11:36:23 +0800 Subject: [PATCH 1/2] feat: add deployment field to agent dispatch Add `deployment` field to `RoomAgentDispatch` and `agentDeployment` to `TokenRequestOptions` for targeting specific agent deployments. Leave empty to target the production deployment. Co-Authored-By: Claude Opus 4.5 --- Sources/LiveKit/Token/TokenSource.swift | 8 ++++++-- Sources/LiveKit/Types/RoomConfiguration.swift | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/LiveKit/Token/TokenSource.swift b/Sources/LiveKit/Token/TokenSource.swift index adbe7e22e..5845aac61 100644 --- a/Sources/LiveKit/Token/TokenSource.swift +++ b/Sources/LiveKit/Token/TokenSource.swift @@ -60,6 +60,8 @@ public struct TokenRequestOptions: Sendable, Equatable { public let agentName: String? /// Metadata passed to the agent job public let agentMetadata: String? + /// Optional deployment to target. Leave empty to target the production deployment. + public let agentDeployment: String? public init( roomName: String? = nil, @@ -69,6 +71,7 @@ public struct TokenRequestOptions: Sendable, Equatable { participantAttributes: [String: String]? = nil, agentName: String? = nil, agentMetadata: String? = nil, + agentDeployment: String? = nil ) { self.roomName = roomName self.participantName = participantName @@ -77,11 +80,12 @@ public struct TokenRequestOptions: Sendable, Equatable { self.participantAttributes = participantAttributes self.agentName = agentName self.agentMetadata = agentMetadata + self.agentDeployment = agentDeployment } func toRequest() -> TokenSourceRequest { - let agents: [RoomAgentDispatch]? = if agentName != nil || agentMetadata != nil { - [RoomAgentDispatch(agentName: agentName, metadata: agentMetadata)] + let agents: [RoomAgentDispatch]? = if agentName != nil || agentMetadata != nil || agentDeployment != nil { + [RoomAgentDispatch(agentName: agentName, metadata: agentMetadata, deployment: agentDeployment)] } else { nil } diff --git a/Sources/LiveKit/Types/RoomConfiguration.swift b/Sources/LiveKit/Types/RoomConfiguration.swift index d02e3965c..a12208668 100644 --- a/Sources/LiveKit/Types/RoomConfiguration.swift +++ b/Sources/LiveKit/Types/RoomConfiguration.swift @@ -89,16 +89,22 @@ public struct RoomAgentDispatch: Encodable, Sendable, Equatable { /// Metadata for the agent public let metadata: String? + /// Optional deployment to target. Leave empty to target the production deployment. + public let deployment: String? + enum CodingKeys: String, CodingKey { case agentName = "agent_name" case metadata + case deployment } public init( agentName: String? = nil, metadata: String? = nil, + deployment: String? = nil ) { self.agentName = agentName self.metadata = metadata + self.deployment = deployment } } From 6c6e769cd70d3e6ab15dda451141d296eb84128b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82az=CC=87ej=20Pankowski?= <86720177+pblazej@users.noreply.github.com> Date: Wed, 17 Jun 2026 08:37:48 +0200 Subject: [PATCH 2/2] style: add trailing commas to satisfy swiftformat Co-Authored-By: Claude Opus 4.8 (1M context) --- Sources/LiveKit/Token/TokenSource.swift | 2 +- Sources/LiveKit/Types/RoomConfiguration.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/LiveKit/Token/TokenSource.swift b/Sources/LiveKit/Token/TokenSource.swift index 5845aac61..10d069dd3 100644 --- a/Sources/LiveKit/Token/TokenSource.swift +++ b/Sources/LiveKit/Token/TokenSource.swift @@ -71,7 +71,7 @@ public struct TokenRequestOptions: Sendable, Equatable { participantAttributes: [String: String]? = nil, agentName: String? = nil, agentMetadata: String? = nil, - agentDeployment: String? = nil + agentDeployment: String? = nil, ) { self.roomName = roomName self.participantName = participantName diff --git a/Sources/LiveKit/Types/RoomConfiguration.swift b/Sources/LiveKit/Types/RoomConfiguration.swift index a12208668..dd79d6836 100644 --- a/Sources/LiveKit/Types/RoomConfiguration.swift +++ b/Sources/LiveKit/Types/RoomConfiguration.swift @@ -101,7 +101,7 @@ public struct RoomAgentDispatch: Encodable, Sendable, Equatable { public init( agentName: String? = nil, metadata: String? = nil, - deployment: String? = nil + deployment: String? = nil, ) { self.agentName = agentName self.metadata = metadata