Amazon Nova 2 Sonic を用いたテキストエージェントから音声アシスタントへの移行
AWS は、テキストエージェントから音声アシスタントへの移行において必要な設計変更やアーキテクチャの違いを解説し、Amazon Nova 2 Sonic を活用した具体的な実装ガイドを提供している。
キーポイント
テキストと音声のエージェントの根本的な違い
入力(タイピング対リアルタイム音声ストリーム)、レスポンス形式(リッチフォーマット対短縮フレーズ)、レイテンシ要件(中程度対超低遅延)において、両者は異なる設計原則を必要とする。
Amazon Nova 2 Sonic の活用と実装
金融や医療など多様な業界でリアルタイム音声対話を可能にする Amazon Nova 2 Sonic を使用し、既存のテキストロジックをそのまま適用できないことを強調している。
自動化ツールによる移行支援
AI IDE(Kiro や Claude Code)と連携するサンプルスキルを提供し、テキストエージェントから音声エージェントへの変換プロセスを自動化・簡素化できる仕組みを紹介している。
音声エージェントの設計要件
音声ユーザーは遅延に敏感であるため、低レイテンシ、ストリーミング、非同期ツール呼び出しが必須であり、テキストエージェントとは異なるアーキテクチャが必要となる。
Amazon Nova 2 Sonic の統合機能
同モデルは音声認識、推論、ツール使用、音声合成を単一の双方向ストリーミングモデルに統合し、従来の ASR-LLM-TTS チェーンを不要にしてレイテンシを削減する。
クライアントとオーケストレータの移行
音声化には永続的な双方向接続(WebSocket など)を持つクライアントへの書き換えが必要だが、Strands などのフレームワークではテキスト用と同じコードスタイルでツール定義を再利用できる。
音声向けシステムプロンプトの最適化
テキスト用プロンプトを音声用に適応させる際は、短く明確な応答を求め、データ取得時のacknowledgementを含め、リアルタイム性や遅延を考慮した会話形式に調整する必要があります。
影響分析・編集コメントを表示
影響分析
この記事は、テキストベースの AI エージェントを音声インターフェースへ拡張しようとする企業にとって、技術的・設計的な障壁を明確に示す重要な指針となる。特に超低遅延要件や対話設計の違いを具体的に比較しているため、実装失敗を防ぐための実践的な価値が高く、業界全体の音声 AI 導入の質向上に寄与する。
編集コメント
音声 AI の実装において、単なる「音声化」ではなく「設計思想の転換」が必要であることを示唆しており、開発者にとって非常に示唆に富む内容です。AWS が提供する自動化ツールとの組み合わせにより、実用レベルでの導入ハードルが下がる可能性があります。
テキストエージェントから音声アシスタントへの移行は、ユーザーがより高速で自然な対話を求めるようになっているため、ますます重要になっています。入力する代わりに、顧客はリアルタイムで話し、理解することを望んでいます。金融、医療、教育、ソーシャルメディア、小売などの業界では、Amazon Nova 2 Sonic を活用したソリューションを検討しており、大規模な自然なリアルタイム音声対話を実現しようとしています。
本稿では、Amazon Nova 2 Sonic を用いて従来のテキストエージェントを会話型音声アシスタントへ移行するために必要な要素を探ります。テキストと音声の要件を比較し、異なるユースケースにおける設計上の優先事項を強調するとともに、エージェントアーキテクチャを分解し、再利用のためのツールやサブエージェント、システムプロンプトの適応などに関する一般的な懸念点についても取り上げます。本稿は、移行プロセスをナビゲートし、よくある落とし穴を回避するための指針となります。
また、Nova サンプルリポジトリには、Kiro や Claude Code といった AI IDE と連携して、テキストエージェントを自動的に音声エージェントに変換する Skill も用意されています。
テキストエージェントと音声アシスタントは異なる課題である
テキストエージェントから音声アシスタントへの移行は、ビジネスロジックを変更せずに音声インターフェースを追加するだけのように思えるかもしれませんが、以下の観点からその違いを理解することが重要です。
側面
テキストエージェント
音声アシスタント
ユーザー入力
タイプされたテキスト:ユーザーが自分のペースで読み、スクロールし、コピー&ペーストを行う
音声ストリーム:リアルタイム、割り込み可能(バーギン)、一時停止の意味も重要
応答スタイル
段落、リスト、テーブル、リンク:豊富な書式設定、すべての情報を一度に提供
短い発話、一度に一つのこと:「続けますか?」という確認ループ付き
レイテンシ予算
ミドルレイテンシ許容範囲:タイピングインジケーターが待ち時間を隠す
超低レイテンシ必須:沈黙は何か壊れていると感じさせる
ターン交替(やり取りの切り替え)
厳格な要求→応答:ユーザーが入力し、Enter キーを押し、待つ
流れるような、重なり合う、割り込み可能な:音声活動検出(VAD)+ターン検出、バーギン機能が必要
転送プロトコル
HTTP / REST / サーバーサイドイベント:ステートレスな要求応答モデル
双方向ストリーミング:永続的な接続、双方向のリアルタイム音声通信
これらの課題をよりよく乗り越えるために、テキストエージェントと音声アシスタントの主な違いとその違いが設計と実装にどう影響するかを分解してみましょう。
応答デザイン
テキストエージェントは、ユーザーが自分のペースで読めるように段落を提供するために構築されています。必要に応じて戻り読みし、コンテンツをコピーし、リンクを追跡します。一方、音声エージェントは根本的に異なる媒体で動作します。応答は会話的であり、簡潔で、読むためではなく聴くために注意深く構造化される必要があります。
銀行の顧客対応エージェントが口座情報を返す例を考えてみましょう:
テキストエージェントの応答:
アカウントの概要はこちらです:
- 普通預金(****4521):3,245.67 ドル
- 貯蓄口座(****8903):12,450.00 ドル
- クレジットカード(****2187):-1,823.45 ドル(支払期限:3月15日)
どのアカウントをクリックしても、詳細な取引履歴を確認できます。
音声エージェントの応答:
「お持ちの口座は3つあります。普通預金は末尾が4521で、残高は3,245ドルです。他の口座もご説明しましょうか、それともこの口座の詳細をお求めですか?」
音声エージェントは情報を理解しやすい断片に分割し、続行する前に確認を求めます。これは*自律的な会話スタイル***であり、一度にすべてを押し付けるのではなく、ユーザーを先導します。
レイテンシ・バジェット(遅延許容範囲)
テキスト利用者は中程度のレイテンシ(遅延)に耐性があります。タイピングインジケーターが表示されれば待機できますが、音声利用者は遅延を即座に感知します。会話中に沈黙が生じると、通話線が切れたように感じられます。このため、エージェントのアーキテクチャ設計は以下のように変化します:
| 要因 | テキストエージェント | 音声エージェント |
|---|---|---|
| 許容応答時間 | 中程度のレイテンシ耐性:ロードインジケーター表示中に数秒待機することは許容される。 | 低レイテンシ耐性:会話は数百ミリ秒以内で、最初の音声はできるだけ早く提供されるべきです。特にツール呼び出し中の数秒の遅延は、応答がないように感じられます。 |
| ツール呼び出しへの耐性 | 複数の連続呼び出しは問題なし | 各呼び出しごとに目立つ沈黙が生じる |
| ストリーミング | あれば望ましい | 必須 |
技術用語注記:
- レイテンシ(Latency):処理や通信における遅延時間。
- ツール呼び出し(Tool call):外部機能やデータソースへのリクエスト実行。
- ストリーミング(Streaming):データを断続的に送信・受信する方式。
非同期ツールハンドリング
あれば望ましい機能
必須機能
Amazon Nova 2 Sonic は 非同期ツール呼び出し をサポートしており、バックグラウンドでツールが実行されている間も会話が自然に続きます。入力を受け付け続け、複数のツールを並列で実行可能であり、ユーザーが処理中にリクエストを変更しても柔軟に対応し、関連する情報に焦点を当てながらすべての結果を提供します。
話者交代と割り込み
テキスト会話には本質的にターンベースの性質があります。ユーザーが入力して Enter キーを押すと、応答を待機します。一方、音声会話は流動的です。ユーザーは途中で割り込み(バージイン)、文の途中でも一時停止し、エージェントが重なる発話を自然に処理することを期待します。Amazon Nova 2 Sonic などのネイティブ音声対音声モデルは、組み込まれた音声活動検出 (VAD: Voice Activity Detection) と話者交代検出を内部で活用してこれを処理します。Nova 2 Sonic は会話の文脈を管理し、各ターンごとに完全な履歴を送信する必要はありません。
アーキテクチャからの移行
これらの違いを念頭に置き、システムを3 つの主要コンポーネントに分割し、それぞれがどのように進化するかを検討することで、アーキテクチャの観点から移行を分解してみましょう。テキストエージェントの概念設計は、以下の 3 つのコンポーネントで構成されます:
- クライアントアプリケーション(Web、モバイル、または IoT インターフェースなど)。
- システムプロンプト、ツール、会話の文脈を管理するテキストオーケストレーター。
- API、データベース、ワークフロー、検索拡張生成(RAG: Retrieval Augmented Generation)パイプライン、またはサブエージェントなど、お客様のシステムに接続するツール統合機能。
このアーキテクチャを音声エージェントへ移行する場合、これらのコンポーネントはそのまま残りますが、それぞれが音声固有のロジックをサポートするために異なる変更を必要とします。
クライアントアプリケーション
エージェントクライアントは、通常、デプロイメントの文脈に応じて、Web ブラウザ、モバイルアプリ、または IoT デバイスで使用されるプログラミング言語およびシステムで実装されます。音声エージェントクライアントには、永続的な双方向接続(WebSocket または WebRTC など)が必要であり、オーディオのエンコーディング/デコーディング、クライアントイベント、バージインロジック、ノイズ制御、文字起こしの表示を処理します。これは通常、ステートレスな REST または一方通行の HTTPS ストリーミングインターフェースを通じてエージェントと通信するテキストクライアントよりもはるかに複雑です。
その結果、このコンポーネントにはリファクタリングまたは完全な書き換えが必要になることが一般的です。例えば、Streamlit フロントエンドで構築された概念実証(PoC)では、双方向接続をサポートするために React などの JavaScript フレームワークを使用して再構築する必要がある可能性が高いです。
WebSocket を使用した軽量な音声エージェント Web クライアントアプリケーションについては、こちらの手本を参照してください。
オーケストレーター
エージェントオーケストレーターは、テキストまたは音声エージェントを構築する際の中心的なハブです。システムプロンプトの管理、ツールやサブエージェントの選択とルーティング、会話コンテキストの維持を行い、相互作用の一貫性を保ちつつエージェントの役割に整合させる役割を果たします。テキストエージェントでは、オーケストレーターはクライアントと推論モデル間のリクエストとレスポンスを処理し、ビジネスロジックを発動するためのツールを統合します。音声オーケストレーターも同様の原則に従いますが、オーディオストリーミング、音声活動検出(Voice Activity Detection: VAD)、自動音声認識(Automatic Speech Recognition: ASR)、推論、およびテキスト読み上げ(Text-to-Speech: TTS)の機能を追加します。Amazon Nova 2 Sonic はこれらの機能を統合した双方向ストリーミングインターフェースを提供しており、ユーザーはテキストエージェントから推論プロンプトやツールトリガーを移行することで、音声へのスムーズな移行を実現できます。
従来のテキストエージェントアーキテクチャとの重要な違いの一つは、Amazon Nova 2 Sonic が同じモデルインターフェースでテキストと音声の両方の入力を接受できる点です。これは、Sonic がテキストオーケストレーターで通常使用されるスタンドアロンの推論用言語モデルを直接置き換えられることを意味します。個別の ASR(音声認識)→ LLM(大規模言語モデル)→ TTS(音声合成)コンポーネントを連鎖させるのではなく、Sonic は音声認識、推論、ツール利用、音声合成を単一の双方向モデルに統合しています。これにより、チームは既存のプロンプトやツールを再利用しながらアーキテクチャを簡素化し、レイテンシを削減でき、音声スタック内で別個のテキスト推論モデルを管理する必要もなくなります。
以下のコードスニペットは、大規模言語モデル(LLM)として Amazon Nova 2 Lite を使用して Strands Agents で構築されたサンプルテキストエージェントを示しています。このエージェントは定義済みのツールを持ち、Strands BidiAgent と Nova 2 Sonic を組み合わせて WebSocket を介して利用可能な音声エージェントオーケストレーターを作成するサンプルも含まれています。Strands におけるテキストエージェントと音声エージェントのコーディングスタイルが非常に類似していることに気づくでしょう。このサンプルでは Strands が使用されていますが、テキストオーケストレーターから必要な主要な入力がシステムプロンプトとツールの定義であるため、LangChain、LangGraph、CrewAI などの他のフレームワークで構築されたテキストエージェントにも同じアプローチが適用されます。
以下のセクションのサンプルを実行する前に、Python と必要な依存関係(strands-agents および Boto3 を含む)をインストールし、IAM 設定に必要なサービスの権限が適切に設定されていることを確認してください。
from strands import Agent, tool
from strands.models import BedrockModel
---- モックツールはテキストエージェントと音声エージェントの両方で使用されます ----
@tool
def authenticate_customer(account_id: str, date_of_birth: str) -> str:
"""顧客の身元を確認し、認証トークンを返します。"""
# 実際の実装では、認証サービス / API を呼び出してください
if account_id == "123456":
return "AUTH_TOKEN_ABC123"
return "Authentication failed"
@tool
def get_account_balance(auth_token: str) -> str:
"""顧客の現在の口座残高を返します。"""
if auth_token == "AUTH_TOKEN_ABC123":
return "Your current checking account balance is $5,420."
return "Unauthorized request"
@tool
def get_recent_transactions(auth_token: str) -> str:
"""最近の取引を返します。"""
if auth_token == "AUTH_TOKEN_ABC123":
return "Recent transactions: $45 groceries, $120 utilities, $18 coffee."
return "Unauthorized request"
Strands Agents を使用すると、Nova 2 Lite を用いて以下に示すようなテキストエージェントのオーケストレーターを作成できます。
---- Nova 2 Lite モデル ----
model = BedrockModel(model_id="amazon.nova-2-lite-v1:0")
---- 銀行アシスタントテキストエージェント ----
bank_agent = Agent(
model=model,
system_prompt="""あなたは銀行アシスタントです。ユーザーの口座残高や最近の取引について正確に回答してください。機密情報を提供する前には、必ずユーザーの身元を確認してください。
""",
tools=[authenticate_customer, get_account_balance, get_recent_transactions],
)
Strands BidiAgent を使用すれば、Nova 2 Sonic モデルと同様のコーディングスタイルで音声エージェントオーケストレーターを構築し、同じツールを再利用できます:
voice_orchestrator.py — サブエージェントをツールとして使用する BidiAgent
from strands.experimental.bidi.agent import BidiAgent
from strands.experimental.bidi.models.nova_sonic import BidiNovaSonicModel
---- Nova 2 Sonic モデル ----
model = BidiNovaSonicModel(
region="us-east-1",
model_id="amazon.nova-2-sonic-v1:0",
provider_config={"audio": {"voice": "tiffany", "input_sample_rate": 16000, "output_sample_rate": 16000}},
)
---- 銀行アシスタント音声エージェント ----
agent = BidiAgent(
model=model,
system_prompt="""あなたは銀行アシスタントです。自然な口調で話し、口座残高や直近の取引に関する質問に答えてください。機密情報を共有する前に顧客の身元を確認してください。短く明確な回答を使用し、データ取得時にはその旨を示してください。
""",
tools=[authenticate_customer, get_account_balance, get_recent_transactions],
)
await agent.run(inputs=[ws_input], outputs=[ws_output])
システムプロンプトはテキストおよび音声の両方のエージェントの基盤です。これはエージェントの役割、トーン、およびガードレールを定義し、書面および口頭のやり取り全体を通じて、回答が一貫性があり、信頼性が高く、ビジネス目標やユーザーの期待と整合していることを保証します。テキストから音声へ移行する際は、リアルタイムオーディオに合わせてシステムプロンプトを適応させてください。簡潔で会話調に保ち、レイテンシ(遅延)と複数回の対話コンテキストを考慮し、複雑なガイダンスはより小さなステップに分割してください。
テキスト用プロンプト(元): "あなたは銀行アシスタントです。ユーザーの口座残高や直近の取引に関する質問に正確にお答えください。機密情報を提供する前に必ずユーザーの身元を検証してください。"
音声向けに適応させたプロンプト: "あなたは銀行アシスタントです。自然な口調で話し、口座残高や直近の取引に関する質問に答えてください。機密情報を共有する前に顧客の身元を確認してください。短く明確な回答を使用し、データ取得時にはその旨を示してください。"
Nova 2 Sonic を備えた音声オーケストレータにおいては、システムプロンプトやツール選択、セッションコンテキストの管理に、Sonic に組み込まれた推論機能(reasoning capability)を利用します。これにより、オーケストレーションレベルで独自の LLM(大規模言語モデル)を推論のために用意する必要はなくなります。
ビジネスロジック層
エージェント型アシスタントをビジネスレイヤーに接続する上で、ツール統合は重要な要素です。その際、Model Context Protocol (MCP) や Agent-to-Agent (A2A)、標準的な HTTP などのプロトコルが利用されます。テキストベースのエージェントでは、オーケストレータは REST API や RAG(検索拡張生成) システム、データベースといったツールへテキスト入力を送信し、テキスト応答を受け取ってユーザー向けの返信を生成します。
Strands Agents のサンプルでは、テキストエージェントで利用されている同じツールを、コード変更なしで音声エージェントでも再利用できます。ただし、ツールやサブエージェントを音声用に再利用する場合、実装の詳細以上の考慮が必要です。
すでにマルチエージェントアーキテクチャを採用している場合、専門的なビジネスロジックを持つエージェントは、いくつかの更新を加えることで音声用にも再利用できるケースがほとんどです。以下の図は、音声オーケストレータが認証や住宅ローン問い合わせのためにサブエージェントを呼び出す銀行アシスタントの例を示しています。
これらのサブエージェントには完全な書き換えは不要ですが、音声対応のために調整(チューニング)が必要です。
より短い回答 – テキスト用サブエージェントは詳細な段落を返す場合がありますが、音声用サブエージェントはオーケストレーターが自然に発話できる 1〜2 文の回答を返すべきです。例えば、サブエージェントのシステムプロンプトを「包括的な回答を提供する」から「1〜2 文で簡潔に要約する」と変更します。
レイテンシの改善 – サブエージェントには小さく高速なモデル(例:大規模モデルではなく Nova 2 Lite から開始)を選択します。音声
原文を表示
Migrating a text agent to a voice assistant is increasingly important because users expect faster, more natural interactions. Instead of typing, customers want to speak and understand in real time. Industries like finance, healthcare, education, social media, and retail are exploring solutions with Amazon Nova 2 Sonic to enable natural, real-time speech interactions at scale.
In this post, we explore what it takes to migrate a traditional text agent into a conversational voice assistant using Amazon Nova 2 Sonic. We compare text and voice agent requirements, highlight design priorities for different use cases, break down agent architecture, and address common concerns like tools and sub-agents for reuse and system prompt adaptation. This post helps you navigate the migration process and avoid common pitfalls.
You can also find a Skill in the Nova sample repo that works with AI IDEs like Kiro and Claude Code to automatically convert your text agent into a voice agent.
Text agents and voice agents aren’t the same problem
While migrating from a text agent to a voice assistant might seem like adding a voice interface while keeping the business logic unchanged, it’s important to understand the differences from the following perspectives.
Aspect
Text agent
Voice agent
User input
Typed text: user reads, scrolls, copy-pastes at own pace
Spoken audio stream: real time, can interrupt (barge-in), pauses matter
Response style
Paragraphs, lists, tables, links: rich formatting, all info delivered at once
Short spoken phrases, one thing at a time: “Want me to continue?” with confirmation loops
Latency budget
Mid-latency tolerance: typing indicator masks wait time
Ultra-low latency required: silence feels like something is broken
Turn-taking
Strict request → response: user types, hits enter, waits
Fluid, overlapping, interruptible: voice activity detection (VAD) + turn detection, barge-in required
Transport
HTTP / REST / Server-Sent Events: stateless request-response
Bidirectional streaming: persistent connection, real-time audio in both directions
To better navigate these challenges, let’s break down the key differences between text agents and voice assistants and how those differences impact design and implementation.
Response design
A text agent is built to deliver paragraphs that users can read at their own pace. Scrolling back, copying content, and following links as needed. A voice agent operates in a fundamentally different medium. Responses must be conversational, concise, and carefully structured for listening rather than reading.Consider a banking agent that returns account information:
Text agent response:
Here's your account summary:
- Checking (****4521): $3,245.67
- Savings (****8903): $12,450.00
- Credit Card (****2187): -$1,823.45 (payment due: March 15)
You can click on any account for detailed transactions.Voice agent response:
“You have three accounts. Your checking account ends in 4521 with a balance of three thousand two hundred forty-five dollars. Want me to go through the others or would you like details on this one?”.
The voice agent breaks information into digestible chunks and asks for confirmation before continuing. It uses an *autonomous conversation style*, proactively guiding the user rather than dumping everything at once.
Latency budget
Text users have mid-latency tolerance. They see a typing indicator and wait. Voice users notice delays almost immediately. Silence in a voice conversation feels like the line went dead. This changes how agents must be architected:
Factor
Text agent
Voice agent
Acceptable response time
Mid-latency tolerance: a few seconds wait with a loading indicator is acceptable.
Low-latency tolerance: conversation should be in the hundreds of milliseconds, with first audio ASAP; delays of a few seconds, especially during tool calls, feel unresponsive.
Tool call tolerance
Multiple sequential calls OK
Each call adds noticeable silence
Streaming
Nice to have
Essential
Asynchronized tool handling
Good to have
Critical to have
Amazon Nova 2 Sonic supports asynchronous tool calling, so the conversation continues naturally while tools run in the background. It keeps accepting input, can run multiple tools in parallel, and gracefully adapts if the user changes their request mid-process, delivering all results while focusing on what’s still relevant.
Turn-taking and interruption
Text conversations are inherently turn-based. The user types, hits enter, waits for a response. Voice conversations are fluid. Users interrupt (barge-in), pause mid-sentence, and expect the agent to handle overlapping speech naturally.Native speech-to-speech models like Amazon Nova 2 Sonic handle this internally with built-in voice activity detection (VAD) and turn detection. Nova 2 Sonic manages conversation context without requiring the full history to be sent on each turn.
Migration from an architectural view
With these differences in mind, let’s break down the migration from an architectural perspective by dividing the system into three major components and examining how each evolves.A conceptual design of a text agent consists of three components:
- A client application (such as web, mobile, or IoT interfaces).
- A text orchestrator that manages the system prompt, tools, and conversation context.
- The tool integrations that connect to your systems, such as APIs, databases, workflows, Retrieval Augmented Generation (RAG) pipelines, or sub-agents.
When migrating this architecture to a voice agent, these components remain the same, but each requires different changes to support voice-specific logic.
The client application
Agent clients are typically implemented in programming languages and systems used for web browsers, mobile apps, or IoT devices, depending on the deployment context.A voice agent client requires a persistent bidirectional connection (such as WebSocket or WebRTC) and handles audio encoding/decoding, client events, barge-in logic, noise control, and transcription display. This is significantly more complex than a text client, which typically communicates with the agent through a stateless REST or one-way HTTPS streaming interface.
As a result, this component usually requires refactoring or a full rewrite. For example, a PoC built with a Streamlit frontend would likely need to be rebuilt using a JavaScript framework like React to support bidirectional connections.
For a lightweight voice agent web client application in REACT using WebSocket, refer to this sample.
The orchestrator
An agent orchestrator is the central hub when building text or voice agents. It manages the system prompt, selects and routes tools or sub-agents, and maintains conversation context to keep interactions coherent and aligned with the agent’s role. In text agents, the orchestrator handles requests and responses between the client and the reasoning model while integrating tools to trigger business logic. Voice orchestrators follow the same principles but add audio streaming, Voice Activity Detection (VAD), Automatic Speech Recognition (ASR), reasoning, and Text-to-Speech (TTS). Amazon Nova 2 Sonic offers a bidirectional streaming interface that combines these features, so users can migrate reasoning prompts and tool triggers from text agents for a smoother transition to voice.
One key difference from a traditional text-agent architecture is that Amazon Nova 2 Sonic can accept both text and audio inputs in the same model interface. This means Sonic can directly replace the standalone text reasoning model typically used in a text orchestrator. Instead of chaining separate ASR → LLM → TTS components, Sonic unifies speech recognition, reasoning, tool use, and speech synthesis into a single bidirectional model. With this, teams can reuse existing prompts and tools while streamlining the architecture, reducing latency, and removing the need to manage a separate text reasoning model in the voice stack.
The following code snippets show a sample text agent built with Strands Agents using Amazon Nova 2 Lite as the large language model (LLM). It has defined tools and a sample using Strands BidiAgent and Nova 2 Sonic to create a voice agent orchestrator available through WebSocket. You will notice that the coding style for both text and voice agents in Strands is highly similar. While the sample uses Strands, the same approach applies to text agents built with other frameworks such as LangChain, LangGraph, or CrewAI, because the key inputs required from the text orchestrator are the system prompt and tool definitions.
Before running the samples in the following sections, install Python and the required dependencies, including strands-agents and Boto3, and make sure your IAM setup has the necessary permissions for the required services.
from strands import Agent, tool
from strands.models import BedrockModel
# ---- Mock tools will be used in both text and voice agents ----
@tool
def authenticate_customer(account_id: str, date_of_birth: str) -> str:
"""Verify customer identity and return an auth token."""
# In real implementation, call your auth service / API
if account_id == "123456":
return "AUTH_TOKEN_ABC123"
return "Authentication failed"
@tool
def get_account_balance(auth_token: str) -> str:
"""Return the customer’s current account balance."""
if auth_token == "AUTH_TOKEN_ABC123":
return "Your current checking account balance is $5,420."
return "Unauthorized request"
@tool
def get_recent_transactions(auth_token: str) -> str:
"""Return recent transactions."""
if auth_token == "AUTH_TOKEN_ABC123":
return "Recent transactions: $45 groceries, $120 utilities, $18 coffee."
return "Unauthorized request" Using Strands Agents, you can create a text agent orchestrator with Nova 2 Lite as shown in the following sample:
# ---- Nova 2 Lite model ----
model = BedrockModel(model_id="amazon.nova-2-lite-v1:0")
# ---- Banking assistant text agent ----
bank_agent = Agent(
model=model,
system_prompt="""You are a banking assistant. Answer user questions about account balances, recent transactions accurately. Always validate user identity before providing sensitive information.
""",
tools=[authenticate_customer, get_account_balance, get_recent_transactions],
) Using the Strands BidiAgent, you can build a voice agent orchestrator in a similar coding style with the Nova 2 Sonic model and reuse the same tools:
# voice_orchestrator.py — BidiAgent with sub-agents as tools
from strands.experimental.bidi.agent import BidiAgent
from strands.experimental.bidi.models.nova_sonic import BidiNovaSonicModel
# ---- Nova 2 Sonic model ----
model = BidiNovaSonicModel(
region="us-east-1",
model_id="amazon.nova-2-sonic-v1:0",
provider_config={"audio": {"voice": "tiffany", "input_sample_rate": 16000, "output_sample_rate": 16000}},
)
# ---- Banking assistant voice agent ----
agent = BidiAgent(
model=model,
system_prompt=""" You are a banking assistant. Speak naturally and answer questions about account balances, recent transactions. Confirm the customer’s identity before sharing sensitive details. Use short, clear responses and acknowledge when retrieving data.
""",
tools=[authenticate_customer, get_account_balance, get_recent_transactions],
)
await agent.run(inputs=[ws_input], outputs=[ws_output]) The system prompt is the foundation for both text and voice agents. It defines the agent’s role, tone, and guardrails, ensuring responses are consistent, reliable, and aligned with business goals and user expectations across written and spoken interactions.When moving from text to voice, adapt the system prompt for real-time audio. Keep it concise and conversational, consider latency and multi-turn context, and break complex guidance into smaller steps.
Text prompt (original):** *“You are a banking assistant. Answer user questions about account balances, recent transactions accurately. Always validate user identity before providing sensitive information.”*
Voice-adapted prompt:**** *“You are a banking assistant. Speak naturally and answer questions about account balances, recent transactions. Confirm the customer’s identity before sharing sensitive details. Use short, clear responses and acknowledge when retrieving data.”*
Note, that in a voice orchestrator with Nova 2 Sonic, you’re using the Sonic built-in reasoning capability to manage the system prompt and tool selection and session context. You no longer need to provide your own LLM for reasoning at the orchestrator level.
The business logic layer
Tool integration is a key aspect of connecting an agentic assistant to the business layer, using protocols like Model Context Protocol (MCP), Agent-to-Agent (A2A), and standard HTTP. In a text-based agent, the orchestrator sends text input to tools, like REST APIs, RAG system, or databases and receives text responses to generate user-facing replies.
In the Strands Agents samples, the same tools used for the text agent can be reused for the voice agent with no code changes. However, reusing tools and sub-agents for voice involves more than just implementation details.
If you already use a multi-agent architecture, your specialized business logic agents can often be reused for voice with some updates. The following diagram shows a banking assistant where a voice orchestrator calls sub-agents for authentication and mortgage inquiries.
Although these sub-agents don’t require a complete rewrite, they do need tuning for voice:
Shorter responses –** a text sub-agent might return a detailed paragraph. A voice sub-agent should return 1–2 sentences that the orchestrator can speak naturally. For example, you update the sub-agent’s system prompt to say, “Summarize in 1 to 2 concise sentences” instead of “Provide a comprehensive answer.”
Latency improvement – choose smaller, faster models for sub-agents (for example, starts from Nova 2 Lite instead of a larger model). In a voice
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み