Skip to content

Commit 51da70e

Browse files
authored
Merge pull request #11 from christopherhwood/chris-fix-data-extraction
Fix stagehand_extract data unwrapping
2 parents 985b2c9 + 0de0f7a commit 51da70e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stagehand/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,16 @@ async function handleToolCall(
289289
instruction: args.instruction,
290290
schema: zodSchema,
291291
});
292-
log(`Data extracted successfully: ${JSON.stringify(data)}`);
292+
if (!data || typeof data !== "object" || !("data" in data)) {
293+
throw new Error("Invalid extraction response format");
294+
}
295+
const extractedData = data.data;
296+
log(`Data extracted successfully: ${JSON.stringify(extractedData)}`);
293297
return {
294298
content: [
295299
{
296300
type: "text",
297-
text: `Extraction result: ${JSON.stringify(data)}`,
301+
text: `Extraction result: ${JSON.stringify(extractedData)}`,
298302
},
299303
{
300304
type: "text",

0 commit comments

Comments
 (0)