BedrockAgent

View as MarkdownOpen in Claude

BedrockAgent extends AgentBase to use Amazon Bedrock’s voice-to-voice model as the AI backend. It renders SWML with the amazon_bedrock verb instead of ai, and keeps every standard agent feature: text and POM prompts, skills, SWAIG functions, post-prompt, and dynamic configuration.

Extends AgentBase — inherits all parent properties and methods.

BedrockAgent generates SWML with the amazon_bedrock verb instead of ai. See the SWML bedrock reference for the full specification.

Constructor

import { BedrockAgent } from '@signalwire/sdk';
const agent = new BedrockAgent({
systemPrompt: 'You are a helpful voice assistant.',
voiceId: 'joanna',
});

The createBedrockAgent(config) factory function returns the same instance as new BedrockAgent(config).

Constructor parameters

name
stringDefaults to bedrock_agent

Agent name.

route
stringDefaults to /bedrock

HTTP route for the agent endpoint.

systemPrompt
string

Initial system prompt, set as raw text. Can be overridden later with setPromptText(). Leave it unset if you build the prompt from sections with promptAddSection(), because raw text takes precedence over sections.

voiceId
stringDefaults to matthew

Bedrock voice identifier (e.g., "matthew", "joanna").

temperature
numberDefaults to 0.7

Generation temperature. Range: 0 to 1.

topP
numberDefaults to 0.9

Nucleus sampling parameter. Range: 0 to 1.

maxTokens
numberDefaults to 1024

Maximum tokens to generate per response. Accepted for compatibility with the Python SDK. Not currently applied to the call.

agentOptions
Partial<AgentOptions>

Additional AgentBase constructor options (e.g., host, port, basicAuth).

Methods

Overridden behavior

BedrockAgent overrides several AgentBase methods to fit the Bedrock voice-to-voice model:

MethodBehavior
setLlmModel()Logs a warning and does nothing. Bedrock uses a fixed voice-to-voice model.
setLlmTemperature()Redirects to setInferenceParams(temperature).
setPromptLlmParams()Logs a warning. Use setInferenceParams() instead.
setPostPromptLlmParams()Logs a warning. The Bedrock post-prompt uses the LLM configured in the platform.

Parameters specific to text-based LLMs (barge_confidence, presence_penalty, frequency_penalty) are filtered out during SWML rendering and have no effect on Bedrock agents.

Prompt methods (setPromptText(), setPromptPom(), promptAddSection(), and so on) work normally. The prompt is built the same way as in AgentBase and then placed in the amazon_bedrock verb, with voice_id, temperature, and top_p added to the prompt object itself. Raw text set through systemPrompt or setPromptText() takes precedence: when it is present, sections added with promptAddSection() are not rendered. Use one style or the other for a given agent.

Examples

Basic Bedrock agent with a tool

import { BedrockAgent, FunctionResult } from '@signalwire/sdk';
const agent = new BedrockAgent({
name: 'bedrock-assistant',
route: '/assistant',
voiceId: 'joanna',
temperature: 0.5,
});
agent.promptAddSection('Role', { body: 'You are a helpful customer service representative.' });
agent.promptAddSection('Guidelines', { body: 'Be concise and professional.' });
agent.defineTool({
name: 'check_order',
description: 'Look up order status',
parameters: {
order_id: { type: 'string', description: 'Order ID' },
},
required: ['order_id'],
handler: async (args) => {
return new FunctionResult(`Order ${args.order_id} is shipped and arriving tomorrow.`);
},
});
agent.setVoice('matthew');
agent.setInferenceParams(0.3, 0.95);
await agent.run();

Multi-agent server with Bedrock

import { AgentBase, AgentServer, BedrockAgent } from '@signalwire/sdk';
// Standard agent
const standardAgent = new AgentBase({ name: 'standard', route: '/standard' });
standardAgent.setPromptText('You are a general assistant.');
// Bedrock voice-to-voice agent
const bedrockAgent = new BedrockAgent({
name: 'bedrock',
route: '/bedrock',
systemPrompt: 'You are a voice-optimized assistant.',
voiceId: 'matthew',
});
const server = new AgentServer();
server.register(standardAgent);
server.register(bedrockAgent);
await server.run();