|
| 1 | +--- |
| 2 | +title: "OpenAI Agents SDK for Typescript + Trigger.dev playground" |
| 3 | +sidebarTitle: "OpenAI Agents SDK for Typescript playground" |
| 4 | +description: "Build production-ready AI agents with OpenAI Agents SDK for Typescript and Trigger.dev. Explore 7 examples covering streaming, multi-agent systems, and tool integration." |
| 5 | +tag: "v4" |
| 6 | +--- |
| 7 | + |
| 8 | +import RealtimeLearnMore from "/snippets/realtime-learn-more.mdx"; |
| 9 | + |
| 10 | +<Info> |
| 11 | + This is a v4 project. If you are using v3 and want to upgrade, please refer to our [v4 upgrade |
| 12 | + guide](/docs/v4-upgrade-guide). |
| 13 | +</Info> |
| 14 | + |
| 15 | +## Overview |
| 16 | + |
| 17 | +7 production-ready patterns built with the OpenAI Agents SDK and Trigger.dev. Clone this repo to experiment with everything from basic calls to workflows with tools, streaming, guardrails, handoffs, and more. |
| 18 | + |
| 19 | +By combining the OpenAI Agents SDK with Trigger.dev, you can create durable agents that can be deployed to production and scaled to any size, with retries, queues, and full observability built-in. |
| 20 | + |
| 21 | +## Video |
| 22 | + |
| 23 | +<video |
| 24 | + controls |
| 25 | + className="w-full aspect-video" |
| 26 | + src="https://github.com/user-attachments/assets/d3a1c709-412f-48e8-a4aa-f0ef50dce5c8" |
| 27 | +></video> |
| 28 | + |
| 29 | +## Tech stack |
| 30 | + |
| 31 | +- [Node.js](https://nodejs.org) runtime environment |
| 32 | +- [OpenAI Agents SDK for Typescript](https://openai.github.io/openai-agents-js/) for creating and managing AI agents |
| 33 | +- [Trigger.dev](https://trigger.dev) for task orchestration, batching, scheduling, and workflow management |
| 34 | +- [Zod](https://zod.dev) for payload validation |
| 35 | + |
| 36 | +## GitHub repo |
| 37 | + |
| 38 | +<Card |
| 39 | + title="View the OpenAI Agents SDK TypeScript playground repo" |
| 40 | + icon="GitHub" |
| 41 | + href="https://github.com/triggerdotdev/examples/tree/main/openai-agents-sdk-with-trigger-playground" |
| 42 | +> |
| 43 | + Click here to view the full code for this project in our examples repository on GitHub. You can |
| 44 | + fork it and use it as a starting point for your own project. |
| 45 | +</Card> |
| 46 | + |
| 47 | +## Agent tasks |
| 48 | + |
| 49 | +- **Basic Agent Chat**: Personality-based conversations with strategic model selection |
| 50 | +- **Agent with Tools**: A simple agent that can call tools to get weather data |
| 51 | +- **Streaming Agent**: Real-time content generation with progress tracking |
| 52 | +- **Agent Handoffs**: True multi-agent collaboration using the [handoff pattern](https://openai.github.io/openai-agents-js/guides/handoffs/) where agents can dynamically transfer control to specialists |
| 53 | +- **Parallel Agents**: Concurrent agent processing for complex analysis tasks |
| 54 | +- **Scheduled Agent**: Time-based agent workflows for continuous monitoring |
| 55 | +- **Agent with Guardrails**: Input guardrails for safe AI interactions |
| 56 | + |
| 57 | +## Relevant code |
| 58 | + |
| 59 | +- **[basicAgentChat.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/basicAgentChat.ts)** - Strategic model selection (GPT-4, o1-preview, o1-mini, gpt-4o-mini) mapped to personality types with Trigger.dev task orchestration |
| 60 | +- **[agentWithTools.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/agentWithTools.ts)** - OpenAI tool calling with Zod validation integrated into Trigger.dev's retry and error handling mechanisms |
| 61 | +- **[streamingAgent.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/streamingAgent.ts)** - Native OpenAI streaming responses with real-time progress tracking via Trigger.dev metadata |
| 62 | +- **[scheduledAgent.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/scheduledAgent.ts)** - Cron-scheduled OpenAI agents running every 6 hours with automatic trend analysis |
| 63 | +- **[parallelAgents.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/parallelAgents.ts)** - Concurrent OpenAI agent execution using Trigger.dev batch operations (`batch.triggerByTaskAndWait`) for scalable text analysis |
| 64 | +- **[agentWithGuardrails.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/agentWithGuardrails.ts)** - OpenAI classification agents as input guardrails with structured validation and exception handling |
| 65 | +- **[agentHandoff.ts](https://github.com/triggerdotdev/examples/blob/main/openai-agents-sdk-with-trigger-playground/src/trigger/agentHandoff.ts)** - OpenAI Agents SDK handoff pattern with specialist delegation orchestrated through Trigger.dev workflows |
| 66 | + |
| 67 | +## Learn more |
| 68 | + |
| 69 | +- [OpenAI Agents SDK docs](https://openai.github.io/openai-agents-js/) - learn about creating and managing AI agents |
| 70 | +- [OpenAI Agents SDK handoffs](https://openai.github.io/openai-agents-js/guides/handoffs/) - learn about agent-to-agent delegation patterns |
| 71 | +- [Batch triggering](/triggering#batch-trigger) - learn about parallel task execution |
| 72 | +- [Scheduled tasks (cron)](/tasks/scheduled#scheduled-tasks-cron) - learn about cron-based task scheduling |
0 commit comments