Hosted agents

View as Markdown

Hosted agents are invocations that BCTRL runs inside a runtime. Describe the task in natural language and BCTRL drives the browser for you. No CDP connection required. The work ranges from a single Stagehand action to a structured extraction to a multi-step browser-use agent.

Stagehand

Stagehand exposes four hosted actions through a typed helper.

1import { z } from "zod";
2
3// One natural-language action
4await bctrl.runtimes.invocations.stagehand.act(runtime.id, {
5 instruction: "Click the export button.",
6});
7
8// Inspect the page
9await bctrl.runtimes.invocations.stagehand.observe(runtime.id, {
10 instruction: "What filters are available?",
11});
12
13// Structured extraction
14const result = await bctrl.runtimes.invocations.stagehand.extract(runtime.id, {
15 instruction: "Extract the invoice total.",
16 schema: z.object({ total: z.number() }),
17});
18
19// Multi-step agent flow
20await bctrl.runtimes.invocations.stagehand.agent(runtime.id, {
21 instruction: "Download every invoice from the last quarter.",
22 maxSteps: 30,
23});

browser-use

1await bctrl.runtimes.invocations.browserUse.agent(runtime.id, {
2 instruction: "Find the cheapest flight to Lisbon and add it to the cart.",
3 maxSteps: 50,
4 useVision: "auto",
5});

browser-use exposes deeper controls when you need them: enablePlanning, maxFailures, stepTimeoutMs, sensitiveData, and more.

Wait for the result

The helpers return an invocation immediately. To run and block on the answer, use createAndWait:

1const invocation = await bctrl.runtimes.invocations.createAndWait(
2 runtime.id,
3 { action: "browserUse", instruction: "Reconcile this month's transactions." },
4 { timeoutMs: 120_000 }
5);
6
7console.log(invocation.status, invocation.output);

Choosing a model

Point an agent at a saved AI provider and tune the call.

1await bctrl.runtimes.invocations.stagehand.agent(runtime.id, {
2 instruction: "Summarize the dashboard.",
3 aiProviderId: "aip_123",
4 model: "claude-opus-4-8",
5 temperature: 0.2,
6});

Agents can also be given tools and toolsets with toolsetId and toolIds.

Next