Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 1 addition & 38 deletions packages/docs/v3/best-practices/deterministic-agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -301,44 +301,7 @@ const stagehand = new Stagehand({
```

## Advanced Patterns

### Parameterized Agent Workflows

Use variables to make cached workflows reusable with different inputs:

```typescript
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");
```


### Fallback to Fresh Exploration

Combine caching with fallback for resilience:
Expand Down