-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Before submitting an issue, please:
- Check the documentation for relevant information
- Search existing issues to avoid duplicates
Environment Information
Please provide the following information to help us reproduce and resolve your issue:
Stagehand:
- Language/SDK: TypeScript
- Stagehand version: 3.0.5
AI Provider:
- Provider: Anthropic
- Model: claude-sonnet-4-5-20250929
Issue Description
stagehand.history does not include extract actions in the result
Steps to Reproduce
- Start stagehand and navigate to a site, in this case one with editable fields
- Call
extractwith a prompt, in this case the prompt is asking for all fields that are editable - Access and store the stagehand history,
const history = await stagehand.history; - Filter the history looking for the entries where the method is
extract - Log out the result
Minimal Reproduction Code
const stagehand = new Stagehand({
env: "LOCAL",
model: {
modelName: "anthropic/claude-sonnet-4-5-20250929",
apiKey: process.env.ANTHROPIC_API_KEY,
}
});
await stagehand.init();
console.log(`Stagehand Session Started`);
const page = stagehand.context.pages()[0];
await page.goto("https://github.com/");
const extractResult = await stagehand.extract("Extract all editable fields on the page.");
const history = await stagehand.history;
console.log(`Extract result:\n`, extractResult);
const extractions = history.filter(e => e.method === 'extract');
console.log(`Extractions: ${extractions.length}`);
await fs.writeFile(
`workflow-report.json`,
JSON.stringify({
history,
totalOps: history.length,
totalTokens: metrics.totalPromptTokens + metrics.totalCompletionTokens
}, null, 2)
);
await stagehand.close();Error Messages / Log trace
[dotenv@17.2.3] injecting env (0) from .env -- tip: 🔄 add secrets lifecycle management: https://dotenvx.com/ops
[dotenv@17.2.3] injecting env (0) from .env -- tip: ⚙️ specify custom .env file path with { path: '/custom/path/.env' }
[2025-12-04 11:02:11.046 -0500] INFO: Launching local browser
category: "init"
Stagehand Session Started
[2025-12-04 11:02:14.242 -0500] INFO: Starting extraction using a11y snapshot
category: "extraction"
instruction: "Extract all editable fields on the page."
[2025-12-04 11:02:17.517 -0500] INFO: response
category: "aisdk"
response: {
"object": {
"extraction": "[0-5] textbox: Enter your email\n[0-10] textbox: Enter your email"
},
"usage": {
"inputTokens": 6753,
"outputTokens": 46,
"totalTokens": 6799,
"cachedInputTokens": 0
},
"finishReason": "stop"
}
Extract result:
{
extraction: '[0-5] textbox: Enter your email\n[0-10] textbox: Enter your email'
}
Extractions: 0
ReferenceError: metrics is not defined
at main (/Users/hunterbetz/workspace/sandbox/scripts/test.ts:39:20)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
[2025-12-04 11:02:20.502 -0500] INFO: response
category: "aisdk"
response: {
"object": {
"progress": "Found 2 textbox fields: one labeled \"[0-5] textbox: Enter your email\" and another labeled \"[0-10] textbox: Enter your email\"",
"completed": true
},
"usage": {
"inputTokens": 917,
"outputTokens": 77,
"totalTokens": 994,
"cachedInputTokens": 0
},
"finishReason": "stop"
}
[2025-12-04 11:02:20.503 -0500] INFO: Extraction completed successfully
category: "extraction"
prompt_tokens: "7670"
completion_tokens: "123"
inference_time_ms: "6260"
Screenshots / Videos
Related Issues
Metadata
Metadata
Assignees
Labels
No labels