import { Agent, AgentInputItem, run } from '@openai/agents'; let thread: AgentInputItem[] = []; const agent = new Agent({ name: 'Assistant', }); async function userSays(text: string) { const result = await run( agent, thread.concat({ role: 'user', content: text }), ); thread = result.history; // Carry over history + newly generated items return result.finalOutput; } await userSays('What city is the Golden Gate Bridge in?'); // -> "San Francisco" await userSays('What state is it in?'); // -> "California"