🎤Micdrop

OpenAI Agents SDK Voice Agent in Node.js

@micdrop/openai-agents answers a call with an agent of the OpenAI Agents SDK, in a pipeline with the speech to text and the voice of your choice. It keeps everything the agent already has: its instructions, model, tools, guardrails and handoffs.

Installation

Terminal window
npm install @micdrop/openai-agents @openai/agents

Usage

import { Agent } from '@openai/agents'
import { OpenaiAgentsAgent } from '@micdrop/openai-agents'
import { endCallTool, MicdropServer } from '@micdrop/server'
const billing = new Agent({
name: 'Billing',
instructions:
'You answer questions about invoices, in short spoken sentences.',
})
const triage = new Agent({
name: 'Triage',
instructions: 'You greet the caller and route them.',
handoffs: [billing],
})
new MicdropServer(socket, {
stt,
tts,
agent: new OpenaiAgentsAgent({
agent: triage,
tools: [endCallTool()],
}),
})

The answer reaches the voice as the agent writes it. The SDK keeps its own history between turns, reasoning and handoffs included, and the tools and handoffs it runs are recorded in the conversation of the call.

Handoffs

After a handoff of the SDK, the agent it handed over to answers the next turns. currentAgent returns it. The tools of the call, such as endCallTool(), are added to whichever agent answers.

Micdrop’s own handoffTool() works too, to hand the call over to an agent of another kind, a Mistral or Mastra agent for instance.

Options

OptionTypeDescription
agentAgent of the SDKThe agent answering first
systemPromptstringGoes before its instructions for this call
runOptionsoptions of run()Any other option, such as context or maxTurns
toolsTool[]Tools of the call, added to the agent’s own
transformsAnswerTransform[]Rework the answers, see extract

A spoken answer starts sooner with reasoning off, through the modelSettings of the SDK agent, as its model accepts.