Skip to content

Error in documentation about parameterized agent cache #1219

@loic-carbonne

Description

@loic-carbonne

Before submitting an issue, please:

The following paragraph in documentation appear to be wrong and should be removed
Using different instructions generate different cache keys. There is no shared cache between both instructions.

Parameterized Agent Workflows

Use variables to make cached workflows reusable with different inputs:

async function executeLogin(username: string, password: string) {
  const stagehand = new Stagehand({
    env: "BROWSERBASE",
    cacheDir: "cache/login"
  });

  await stagehand.init();
  const page = stagehand.context.pages()[0];

  await page.goto("https://example.com/login");

  const agent = stagehand.agent({
    model: "anthropic/claude-sonnet-4-20250514"
  });

  // Variables work with caching
  const result = await agent.execute({
    instruction: `Fill in username with "${username}" and password with "${password}", then click submit`,
    maxSteps: 5
  });

  await stagehand.close();
  return result.success;
}

// First user: Caches the workflow
await executeLogin("user1@example.com", "password123");

// Second user: Reuses cached workflow structure
await executeLogin("user2@example.com", "differentpass");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions