runAgent()
Execute an AI agent with a natural language instruction.Signature
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Natural language instruction |
context | BrowserContext | Yes | Playwright browser context |
options | object | No | Configuration options |
Options
| Option | Type | Default | Description |
|---|---|---|---|
verbose | boolean | true | Enable console logging |
agentType | string | 'claude' | Agent backend: 'claude' or 'langchain' |
provider | string | 'anthropic' | LLM provider: 'anthropic', 'openai', 'google' |
model | string | - | Override default model name |
recursionLimit | number | 100 | Max agent recursion depth |
returnUsage | boolean | false | Return usage statistics |
modelConfig | object | - | Additional model configuration |
Returns
- Default:
Promise<string>— Final agent response - With
returnUsage: true:Promise<{ result: string, usage: object }>— Response with token usage
Examples
Basic Usage
With Options
Using Different Agents
- Claude (Default)
- LangChain

