@runloop/api-client - v1.4.0
    Preparing search index...

    Class Scenario

    Object-oriented interface for working with Scenarios.

    The Scenario class provides a high-level API for managing scenarios and starting scenario runs. A scenario defines a repeatable task with a well defined starting environment, task evaluation scorer and an optional reference solution.

    Scenarios can be instantiated with runloop.scenario.fromId(scn_123):

    import { RunloopSDK } from '@runloop/api-client';

    const runloop = new RunloopSDK();
    const scenario = runloop.scenario.fromId('scn_123');

    // Get scenario details
    const info = await scenario.getInfo();
    console.log(info.name);

    // Start a run with agent mounted and wait for the devbox to be ready
    const run = await scenario.run({
    run_name: 'my-run',
    runProfile: {
    mounts: [{
    type: 'agent_mount',
    agent_id: 'agt_123',
    agent_name: null,
    agent_path: '/home/user/agent',
    }],
    },
    });

    // Execute your agent on the devbox
    await run.devbox.cmd.exec('python /home/user/agent/main.py');

    // Score and complete
    await run.scoreAndComplete();
    Index

    Accessors

    Methods

    Accessors

    Methods

    • Retrieve current scenario details.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<ScenarioView>

      Current scenario info

      const info = await scenario.getInfo();
      console.log(`Scenario: ${info.name}`);
      console.log(`Problem: ${info.input_context?.problem_statement}`);
    • Update the scenario.

      Only provided fields will be updated. Fields that are null will preserve existing values.

      Parameters

      • Optionalparams: ScenarioUpdateParams

        Update parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<ScenarioView>

      Updated scenario info

      const updated = await scenario.update({
      name: 'Updated Scenario Name',
      metadata: { version: '2.0' },
      });
    • Start a new scenario run without waiting for the devbox to be ready.

      Creates a new scenario run and returns immediately. The devbox may still be starting; call awaitEnvReady() on the returned ScenarioRun to wait for it to be ready.

      Parameters

      • Optionalparams: ScenarioRunParams

        Run parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<ScenarioRun>

      ScenarioRun instance for managing the run

      const run = await scenario.runAsync({ run_name: 'my-run' });

      // Do other work while devbox starts...

      // Wait for devbox when ready
      await run.awaitEnvReady();
    • Start a new scenario run and wait for the devbox to be ready.

      Convenience method that starts a run and waits for the devbox to be ready before returning.

      Parameters

      • Optionalparams: ScenarioRunParams

        Run parameters

      • Optionaloptions: RequestOptions<unknown> & { polling?: Partial<PollingOptions<DevboxView>> }

        Request options with optional polling config

      Returns Promise<ScenarioRun>

      ScenarioRun instance with ready devbox

      const run = await scenario.run({ run_name: 'my-run' });

      // Devbox is ready - execute your agent
      await run.devbox.cmd.exec('python /home/user/agent/main.py');

      // Score and complete
      await run.scoreAndComplete();