@@ -88,9 +88,7 @@ var simulateCommand = &cli.Command{
8888}
8989
9090// writeGeneratedScenariosTemp writes a generated run's scenarios to a temp
91- // scenarios.yaml and returns its path, so the simulate command can print where
92- // they landed (mirroring how it prints the agent log path). Returns "" when the
93- // run carries no generated scenarios.
91+ // scenarios.yaml; "" when the run carries none.
9492func writeGeneratedScenariosTemp (run * livekit.SimulationRun ) (string , error ) {
9593 group := run .GetScenarioGroup ()
9694 if group == nil || len (group .GetScenarios ()) == 0 {
@@ -137,9 +135,8 @@ func scenarioGroupToYAML(group *livekit.ScenarioGroup) ([]byte, error) {
137135 return yaml .Marshal (f )
138136}
139137
140- // scenariosFile mirrors a scenarios.yaml (the source of truth for scenarios).
141- // It maps field-for-field onto livekit.ScenarioGroup; `userdata` is written as a
142- // nested mapping here and JSON-encoded into the proto's string field.
138+ // scenariosFile mirrors a scenarios.yaml; `userdata` is a nested mapping here
139+ // and JSON-encoded into the proto's string field.
143140type scenariosFile struct {
144141 Name string `yaml:"name"`
145142 Scenarios []yamlScenario `yaml:"scenarios"`
@@ -153,7 +150,6 @@ type yamlScenario struct {
153150 Userdata map [string ]any `yaml:"userdata"`
154151}
155152
156- // simulateConfig holds all parameters needed to run a simulation in either TUI or CI mode.
157153type simulateConfig struct {
158154 ctx context.Context
159155 client * lksdk.AgentSimulationClient
@@ -169,16 +165,13 @@ type simulateConfig struct {
169165 scenariosPath string // path to the --scenarios file (empty when generating from source)
170166}
171167
172- // simulateMode represents how scenarios are sourced.
173168type simulateMode int
174169
175170const (
176171 modeScenarios simulateMode = iota
177172 modeGenerateFromSource
178173)
179174
180- // loadScenarioGroup reads a scenarios.yaml into a livekit.ScenarioGroup, JSON-encoding
181- // each scenario's nested `userdata` mapping into the proto's string field.
182175func loadScenarioGroup (path string ) (* livekit.ScenarioGroup , error ) {
183176 data , err := os .ReadFile (path )
184177 if err != nil {
@@ -239,9 +232,8 @@ func runSimulate(ctx context.Context, cmd *cli.Command) error {
239232 return err
240233 }
241234
242- // The scenarios file must be specified explicitly via --scenarios; we never
243- // auto-discover one. When provided, those scenarios are the source of truth;
244- // otherwise scenarios are generated from the agent's source.
235+ // never auto-discovered: an explicit --scenarios file is the source of
236+ // truth, otherwise scenarios are generated from the agent's source
245237 scenariosPath := cmd .String ("scenarios" )
246238
247239 var scenarioGroup * livekit.ScenarioGroup
@@ -259,8 +251,6 @@ func runSimulate(ctx context.Context, cmd *cli.Command) error {
259251 mode = modeGenerateFromSource
260252 }
261253
262- // Generating from source uploads the agent's code to LiveKit Cloud, so make
263- // the user agree to it explicitly before anything is sent.
264254 if mode == modeGenerateFromSource {
265255 if err := confirmSourceUpload (cmd , projectDir ); err != nil {
266256 return err
@@ -297,8 +287,8 @@ func isInteractive() bool {
297287 return isatty .IsTerminal (os .Stdin .Fd ()) && isatty .IsTerminal (os .Stdout .Fd ())
298288}
299289
300- // confirmSourceUpload makes the user explicitly agree that their agent's source
301- // code will be uploaded to LiveKit Cloud before generating scenarios from it .
290+ // confirmSourceUpload makes the user agree before their agent's source is
291+ // uploaded to LiveKit Cloud.
302292func confirmSourceUpload (cmd * cli.Command , projectDir string ) error {
303293 if cmd .Bool ("yes" ) {
304294 return nil
@@ -333,9 +323,9 @@ func confirmSourceUpload(cmd *cli.Command, projectDir string) error {
333323
334324// --- Shared lifecycle functions used by both TUI and CI modes ---
335325
336- // agentLauncher owns the agent subprocess lifecycle around the TUI, which only
337- // observes the start via Wait. Stop kills the worker even when the TUI quits
338- // mid-start; a leaked worker keeps its port bound and breaks the next run.
326+ // agentLauncher owns the agent subprocess lifecycle around the TUI. Stop kills
327+ // the worker even when the TUI quits mid-start; a leaked worker keeps its port
328+ // bound and breaks the next run.
339329type agentLauncher struct {
340330 done chan struct {}
341331 proc * AgentProcess
@@ -351,14 +341,13 @@ func launchSimulationAgent(c *simulateConfig) *agentLauncher {
351341 return l
352342}
353343
354- // Wait blocks until the start attempt finishes and returns its result.
355344func (l * agentLauncher ) Wait () (* AgentProcess , error ) {
356345 <- l .done
357346 return l .proc , l .err
358347}
359348
360- // Stop kills the agent once the start attempt finishes (bounded so a stuck
361- // start can't hang the exit path) and returns it for post-exit reporting.
349+ // Stop kills the agent once the start attempt finishes (bounded wait) and
350+ // returns it for post-exit reporting.
362351func (l * agentLauncher ) Stop () * AgentProcess {
363352 select {
364353 case <- l .done :
@@ -395,9 +384,8 @@ func startSimulationAgent(c *simulateConfig, forwardOutput io.Writer) (*AgentPro
395384 "--simulation" ,
396385 },
397386 Env : []string {
398- // force the agent to register under the dispatch name regardless of any
399- // agent_name hardcoded in the user's code (see LIVEKIT_AGENT_NAME_OVERRIDE
400- // precedence in livekit-agents worker.py).
387+ // register under the dispatch name regardless of any agent_name
388+ // hardcoded in the user's code
401389 "LIVEKIT_AGENT_NAME_OVERRIDE=" + c .agentName ,
402390 "LIVEKIT_URL=" + c .pc .URL ,
403391 "LIVEKIT_API_KEY=" + c .pc .APIKey ,
@@ -417,8 +405,6 @@ func createSimulationRun(ctx context.Context, c *simulateConfig) (string, *livek
417405 req .Concurrency = & c .concurrency
418406 }
419407 if c .mode == modeScenarios {
420- // Run the scenarios from the yaml. When unset, the server generates
421- // num_simulations scenarios from the uploaded source.
422408 req .ScenarioGroup = c .scenarioGroup
423409 }
424410
0 commit comments