lk agent simulate: pass --deployment through SimulationRun create - #966
Open
rdysell wants to merge 3 commits into
Open
lk agent simulate: pass --deployment through SimulationRun create#966rdysell wants to merge 3 commits into
rdysell wants to merge 3 commits into
Conversation
Omitted AgentDispatch deployment defaults to production. Shared Cloud agent names cannot pin staging/dev until create carries field 14 and the simulation service copies it onto the dispatch. Fixes livekit#965 Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Sep 8, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The --deployment validation currently allows --deployment= without --agent-name, which contradicts the documented CLI requirement that using --deployment requires --agent-name.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds Cloud agent deployment pinning support to lk agent simulate so simulations targeting a live Cloud agent (--agent-name) can safely dispatch to non-production deployments (staging/dev) instead of defaulting to production.
Changes:
- Add
--deployment/-dtolk agent simulate(and inheritedsimulate audio) with the same wording aslk dispatch create. - Thread the deployment value into
SimulationRun.Create.Requestvia a helper that uses a generated field when available, otherwise encodes protobuf field14as unknown bytes for compatibility with older vendored protocol code. - Add unit tests to validate field-14 emission and omission on empty deployment.
File summaries
| File | Description |
|---|---|
| cmd/lk/simulate.go | Adds the --deployment flag, validates flag combinations, and wires deployment into simulation run creation. |
| cmd/lk/simulate_deployment.go | Implements protocol-compatible setting of deployment on the create request (generated field preferred; unknown-field fallback). |
| cmd/lk/simulate_deployment_test.go | Tests marshaled protobuf output contains field 14 for deployment and that empty deployment is omitted. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+348
to
+351
| agentDeployment := cmd.String("deployment") | ||
| if cmd.IsSet("deployment") && agentDeployment != "" && !cmd.IsSet("agent-name") { | ||
| return fmt.Errorf("--deployment requires --agent-name (a locally spawned worker is not a Cloud deployment)") | ||
| } |
CI failed to compile: ConsumeFieldValue returns one int, not two. Co-authored-by: Cursor <cursoragent@cursor.com>
Ubuntu CI compares this file to generate-fish-completion output. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
lk agent simulateagainst a live Cloud agent (--agent-name) had no way to select a non-production deployment. Omitted dispatchdeploymentdefaults to production. Shared agent names (one Cloud agent with production + staging + dev) make staging simulations unsafe: they silently hit production workers.lk dispatch createalready has--deployment.cmd/lk/simulate.gostill had:Docs: Non-production deployments — omit the flag / empty string = production.
Fixes #965
Protocol: livekit/protocol#1780 (livekit/protocol#1778)
CLI change
--deployment/-donlk agent simulate(inherited bysimulate audio), same wording aslk dispatch create.--deploymentrequires--agent-name. A locally spawned worker is not a Cloud deployment.SimulationRun.Create.Requestfield 14 (deployment).Because this module still vendors a protocol revision without the generated Go field, the create helper prefers
Fields().ByName("deployment")when present and otherwise emits protobuf field 14 as unknown bytes. Cloud can pin as soon as the simulation service honors that field; a later protocol bump can drop the unknown-bytes path.Cloud backend (required for the pin)
A CLI flag discarded by the create API, or honored only in room metadata, is not a pin. The Cloud simulation service must set
CreateAgentDispatchRequest.deploymentso the simulated user waits on the same room the pinned worker joins.Rewriting
--agent-nameto a placeholder and callinglk dispatch create --deployment stagingdoes not work: Cloud simulate waits for the original--agent-namein its own room.Test plan
lk agent simulate --helpdocuments--deploymentlk agent simulate --deployment stagingwithout--agent-nameerrorslk agent simulate --agent-name <name> --deployment staging --scenarios <file>dispatches to the staging workers (LIVEKIT_AGENT_DEPLOYMENT=staging), not production