Skip to content

lk agent simulate: pass --deployment through SimulationRun create - #966

Open
rdysell wants to merge 3 commits into
livekit:mainfrom
rdysell:feat/simulate-deployment-flag
Open

lk agent simulate: pass --deployment through SimulationRun create#966
rdysell wants to merge 3 commits into
livekit:mainfrom
rdysell:feat/simulate-deployment-flag

Conversation

@rdysell

@rdysell rdysell commented Sep 8, 2026

Copy link
Copy Markdown

Summary

lk agent simulate against a live Cloud agent (--agent-name) had no way to select a non-production deployment. Omitted dispatch deployment defaults to production. Shared agent names (one Cloud agent with production + staging + dev) make staging simulations unsafe: they silently hit production workers.

lk dispatch create already has --deployment. cmd/lk/simulate.go still had:

// TODO (steveyoon): add agent deployment support
// agentDeployment string

Docs: Non-production deployments — omit the flag / empty string = production.

Fixes #965
Protocol: livekit/protocol#1780 (livekit/protocol#1778)

CLI change

  • Add --deployment / -d on lk agent simulate (inherited by simulate audio), same wording as lk dispatch create.
  • --deployment requires --agent-name. A locally spawned worker is not a Cloud deployment.
  • Thread the value through SimulationRun.Create.Request field 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.deployment so the simulated user waits on the same room the pinned worker joins.

Rewriting --agent-name to a placeholder and calling lk dispatch create --deployment staging does not work: Cloud simulate waits for the original --agent-name in its own room.

Test plan

  • lk agent simulate --help documents --deployment
  • lk agent simulate --deployment staging without --agent-name errors
  • After protocol#1780 + Cloud wiring: lk agent simulate --agent-name <name> --deployment staging --scenarios <file> dispatches to the staging workers (LIVEKIT_AGENT_DEPLOYMENT=staging), not production

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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/-d to lk agent simulate (and inherited simulate audio) with the same wording as lk dispatch create.
  • Thread the deployment value into SimulationRun.Create.Request via a helper that uses a generated field when available, otherwise encodes protobuf field 14 as 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 thread cmd/lk/simulate.go
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)")
}
@CLAassistant

CLAassistant commented Sep 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

rdysell and others added 2 commits September 8, 2026 13:18
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>
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.

lk agent simulate: propagate --deployment through SimulationRun create into AgentDispatch

3 participants