Demonstrates conversation sessions with the Temporal OpenAI Agents integration using
WorkflowSafeMemorySession, whose history lives on the Workflow heap and is rebuilt by replay.
Scenarios (src/sessions/workflows.ts):
- multi-turn-chat — runs several prompts over one shared session; later turns see earlier history.
- carryover-chat — carries session history across a
continueAsNewboundary by capturingsession.getItems()and re-seeding the next run vianew WorkflowSafeMemorySession({ initialItems }).
Run these from the openai-agents/ root (run npm install there once first).
# In one terminal, start the Worker (requires a local Temporal server and OPENAI_API_KEY):
OPENAI_API_KEY=sk-... npx ts-node src/sessions/worker.ts
# In another terminal, start a scenario:
npx ts-node src/sessions/client.ts multi-turn-chat
npx ts-node src/sessions/client.ts carryover-chatnpx mocha --exit --require ts-node/register --require source-map-support/register "src/sessions/mocha/*.test.ts"Tests run a real Worker against TestWorkflowEnvironment with a scripted fake model, so no
OPENAI_API_KEY is required. They assert that a later turn's model input contains the prior
turn's history — including across the continue-as-new boundary.