Skip to content

feat: add deployment field to agent dispatch#1043

Merged
xianshijing-lk merged 2 commits into
mainfrom
shijing/agent-deployment
Jun 17, 2026
Merged

feat: add deployment field to agent dispatch#1043
xianshijing-lk merged 2 commits into
mainfrom
shijing/agent-deployment

Conversation

@xianshijing-lk

@xianshijing-lk xianshijing-lk commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add deployment field to RoomAgentDispatch for targeting specific agent deployments
  • Add agentDeployment to TokenRequestOptions to pass deployment through token requests

The deployment field allows targeting a specific agent deployment (e.g., "staging"). Leave empty to target the production deployment.

Related PRs:

Usage

let options = TokenRequestOptions(
    roomName: "my-room",
    agentName: "my-agent",
    agentDeployment: "staging"  // Optional: target specific deployment
)

Or directly via RoomAgentDispatch:

let dispatch = RoomAgentDispatch(
    agentName: "my-agent",
    metadata: "my-metadata",
    deployment: "staging"
)

Test plan

Unit Tests

swift test
# Or via Xcode
xcodebuild test -scheme LiveKit -destination "platform=iOS Simulator,name=iPhone 15"

Manual Verification

1. Verify JSON serialization includes deployment:

let dispatch = RoomAgentDispatch(
    agentName: "my-agent",
    deployment: "staging"
)
let encoder = JSONEncoder()
let data = try encoder.encode(dispatch)
let json = String(data: data, encoding: .utf8)!
print(json)  // Should include "deployment": "staging"

2. Verify TokenRequestOptions converts to request correctly:

let options = TokenRequestOptions(
    roomName: "test-room",
    agentName: "my-agent",
    agentDeployment: "staging"
)
let request = options.toRequest()
print(request.roomConfiguration?.agents?.first?.deployment)  // Should print "staging"

3. Verify token contains deployment (with TokenSource):

let response = try await tokenSource.fetch(TokenRequestOptions(
    roomName: "test-room",
    agentName: "my-agent",
    agentDeployment: "staging"
))
if let jwt = response.jwt(),
   let agents = jwt.roomConfiguration?.agents {
    print("Deployment: \(agents.first?.deployment ?? "nil")")
}

End-to-End Verification

  1. Use TokenSource to get credentials with deployment
  2. Connect to room - agent with matching deployment should join
  3. Verify only staging agent receives the dispatch

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

⚠️ This PR does not contain any files in the .changes directory.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xianshijing-lk xianshijing-lk merged commit c824dd6 into main Jun 17, 2026
39 of 42 checks passed
@xianshijing-lk xianshijing-lk deleted the shijing/agent-deployment branch June 17, 2026 09:34
xianshijing-lk added a commit to livekit/client-sdk-flutter that referenced this pull request Jun 17, 2026
## Summary
- Add `deployment` field to `RoomAgentDispatch` for targeting specific
agent deployments
- Add `agentDeployment` to `TokenRequestOptions` to pass deployment
through token requests
- Update generated JSON serialization code

The `deployment` field allows targeting a specific agent deployment
(e.g., "staging"). Leave empty to target the production deployment.

Related PRs:
- node-sdks: livekit/node-sdks#675
- python-sdks: livekit/python-sdks#722
- rust-sdks: livekit/rust-sdks#1176
- client-sdk-swift:
livekit/client-sdk-swift#1043
- client-sdk-js: livekit/client-sdk-js#1971

## Usage
```dart
final options = TokenRequestOptions(
  roomName: 'my-room',
  agentName: 'my-agent',
  agentDeployment: 'staging',  // Optional: target specific deployment
);
```

Or directly via `RoomAgentDispatch`:
```dart
final dispatch = RoomAgentDispatch(
  agentName: 'my-agent',
  metadata: 'my-metadata',
  deployment: 'staging',
);
```

## Test plan

### Unit Tests
```bash
flutter test
flutter test test/token/token_source_test.dart -v
```

### Manual Verification

**1. Verify JSON serialization includes deployment:**
```dart
final dispatch = RoomAgentDispatch(
  agentName: 'my-agent',
  deployment: 'staging',
);
final json = dispatch.toJson();
print(json);  // Should include 'deployment': 'staging'
```

**2. Verify TokenRequestOptions converts to request correctly:**
```dart
final options = TokenRequestOptions(
  roomName: 'test-room',
  agentName: 'my-agent',
  agentDeployment: 'staging',
);
final request = options.toRequest();
print(request.roomConfiguration?.agents?.first?.deployment);  // Should print 'staging'
```

**3. Verify JSON round-trip:**
```dart
final original = RoomAgentDispatch(
  agentName: 'my-agent',
  deployment: 'staging',
);
final json = original.toJson();
final restored = RoomAgentDispatch.fromJson(json);
assert(restored.deployment == 'staging');
```

### End-to-End Verification
1. Use TokenSource to get credentials with agentDeployment set
2. Connect to room - agent with matching deployment should join
3. Verify only staging agent receives the dispatch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants