ℹ️ Note: This is a v4 project. If you are using v3 and want to upgrade, please refer to our v4 upgrade guide.
Get hands-on with AI agents by exploring 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.
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.
handoff-agent.mp4
- Node.js runtime environment
- OpenAI Agents SDK for Typescript for creating and managing AI agents
- Trigger.dev for task orchestration, batching, scheduling, and workflow management
- Zod for payload validation
- Basic Agent Chat: Personality-based conversations with strategic model selection
- Agent with Tools: A simple agent that can call tools to get weather data
- Streaming Agent: Real-time content generation with progress tracking
- Agent Handoffs: True multi-agent collaboration using the handoff pattern where agents can dynamically transfer control to specialists
- Parallel Agents: Concurrent agent processing for complex analysis tasks
- Scheduled Agent: Time-based agent workflows for continuous monitoring
- Agent with Guardrails: Input guardrails for safe AI interactions
- After cloning the repo, run
npm installto install the dependencies. - Set up your environment variables (see
.env.example) - If you haven't already, sign up for a free Trigger.dev account here and create a new project.
- Copy the project ref from the Trigger.dev dashboard and add it to the
trigger.config.tsfile. - In your terminal, run the Trigger.dev dev CLI command with
npx trigger.dev@v4-beta dev.
Now you should be able to visit your Trigger.dev dashboard and test any of the agent tasks with the example payloads provided in each task file.
Use the Trigger.dev dashboard to test each task:
- Navigate to your project dashboard
- Select any task from the list
- Click "Test"
- Use the example payload from the task file comments
- Run and observe the results in real-time
- 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
- src/trigger/agentWithTools.ts - OpenAI tool calling with Zod validation integrated into Trigger.dev's retry and error handling mechanisms
- src/trigger/streamingAgent.ts - Native OpenAI streaming responses with real-time progress tracking via Trigger.dev metadata
- src/trigger/scheduledAgent.ts - Cron-scheduled OpenAI agents running every 6 hours with automatic trend analysis
- src/trigger/parallelAgents.ts - Concurrent OpenAI agent execution using Trigger.dev batch operations (
batch.triggerByTaskAndWait) for scalable text analysis - src/trigger/agentWithGuardrails.ts - OpenAI classification agents as input guardrails with structured validation and exception handling
- src/trigger/agentHandoff.ts - OpenAI Agents SDK handoff pattern with specialist delegation orchestrated through Trigger.dev workflows
To learn more about the technologies used in this project, check out the following resources:
- OpenAI Agents SDK docs - learn about creating and managing AI agents
- OpenAI Agents SDK handoffs - learn about agent-to-agent delegation patterns
- Trigger.dev docs - learn about Trigger.dev and its features
- Trigger.dev batch operations - learn about parallel task execution
- Trigger.dev scheduled tasks (cron) - learn about cron-based task scheduling
- Multi-agent collaboration patterns - advanced agent orchestration examples