import { webSearchTool, Agent, AgentInputItem, Runner, withTrace } from "@openai/agents";
// Tool definitions
const webSearchPreview = webSearchTool({
searchContextSize: "medium",
userLocation: {
type: "approximate"
}
})
const homepageFaq = new Agent({
name: "Homepage FAQ",
instructions: "Bitte suche alle Informationen auf der Webseite https://permasale.de/",
model: "gpt-5.4-nano",
tools: [
webSearchPreview
],
modelSettings: {
reasoning: {
effort: "low",
summary: "auto"
},
store: true
}
});
type WorkflowInput = { input_as_text: string };
// Main code entrypoint
export const runWorkflow = async (workflow: WorkflowInput) => {
return await withTrace("Permasale FAQ", async () => {
const state = {
};
const conversationHistory: AgentInputItem[] = [
{ role: "user", content: [{ type: "input_text", text: workflow.input_as_text }] }
];
const runner = new Runner({
traceMetadata: {
__trace_source__: "agent-builder",
workflow_id: "wf_69bba93ea2c48190bfacdfaa07ca895908995bb27205edb4"
}
});
const homepageFaqResultTemp = await runner.run(
homepageFaq,
[
...conversationHistory
]
);
conversationHistory.push(...homepageFaqResultTemp.newItems.map((item) => item.rawItem));
if (!homepageFaqResultTemp.finalOutput) {
throw new Error("Agent result is undefined");
}
const homepageFaqResult = {
output_text: homepageFaqResultTemp.finalOutput ?? ""
};
});
}
Wf_69bba93ea2c48190bfacdfaa07ca895908995bb27205edb4
version="2"