Nova Sonic Tool Response Parsing Bug
Summary
Amazon Nova Sonic's RealtimeModel fails to parse tool responses from @function_tool methods, causing "Tool Response parsing error" even with simple string returns.
Environment
- LiveKit Agents Framework: Latest version
- Plugin:
livekit-plugins-aws[realtime] - Model:
amazon.nova-sonic-v1:0 - AWS Region: us-east-1
Problem Description
Nova Sonic's RealtimeModel cannot parse ANY tool responses, regardless of format or complexity. This blocks all function tool implementations and prevents production deployment.
Error Pattern
Validation error: RequestId=... : Tool Response parsing error
Evidence
1. Tool Execution Success
# Tool executes successfully
tool_result="OK" is_error=False
2. Response Sent Successfully
# Nova Sonic receives the string
Sending tool result: OK
3. AWS Validation Failure
# AWS validation fails despite successful execution
Tool Response parsing error
Attempted Solutions
1. Simple String Returns
@function_tool()
async def test_tool(self, context: RunContext):
return "OK" # Still fails
2. JSON Format Returns
@function_tool()
async def test_tool(self, context: RunContext):
return {"status": "success"} # Still fails
3. Conditional Return Logic
@function_tool()
async def test_tool(self, context: RunContext):
if settings.enable_nova_sonic:
return "OK" # Nova Sonic mode - fails
else:
return (NextAgent(), "message") # Google LLM mode - works
Implementation Details
Working Architecture (Google LLM Mode)
class InitialTriageAgent(BaseAgent[TriageState]):
@function_tool()
async def process_initial_triage_complete(self, context: RunContext, user_narrative: str):
# Complex processing with LLM calls
# Returns agent handoff tuple
return SchemaIntakeAgent(), "Let's explore your symptoms"
Dual-LLM Pattern for Nova Sonic Compatibility
@property
def tool_llm(self):
if self._tool_llm is None:
if settings.enable_nova_sonic:
# Separate Google LLM instance for tool processing
self._tool_llm = llm.FallbackAdapter([
google.LLM(
model=settings.llm_model,
vertexai=True,
project=settings.google_cloud_project,
location=settings.google_cloud_location
)
])
else:
# Use session LLM for traditional mode
self._tool_llm = self.session.llm
return self._tool_llm
Root Cause Analysis
This is NOT an implementation issue but a bug in the AWS Nova Sonic plugin itself:
- ✅ Tool Logic: Executes successfully with proper results
- ✅ Response Format: Follows LiveKit function tool patterns
- ✅ Plugin Communication: Successfully sends response to AWS
- ❌ AWS Validation: Fails to parse any tool response format
Impact
- Production Blocked: Cannot deploy Nova Sonic in production
- Feature Limitation: All function tool capabilities disabled
- Workaround Required: Must use traditional STT→LLM→TTS pipeline
Expected Behavior
Nova Sonic should successfully parse tool responses in the same formats that work with other LLM providers:
- String returns:
return "OK" - Tuple returns:
return (NextAgent(), "message") - JSON returns:
return {"status": "success"}
Workaround
Currently using dual-LLM architecture where:
- Nova Sonic: Handles conversation flow
- Google LLM: Handles tool processing
- Result: Functional but not optimal
Request
Please investigate and fix the tool response parsing mechanism in the Nova Sonic plugin to support standard LiveKit function tool patterns.
Additional Context
- All code changes tested and working in Google LLM mode
- Issue affects all function tool implementations, not specific to our use case
- Performance impact: +400MB memory for dual-LLM workaround
Configuration for Reproduction
ENABLE_NOVA_SONIC=true
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=us-east-1
NOVA_SONIC_VOICE=tiffany
Test Case
@function_tool()
async def minimal_test_tool(self, context: RunContext):
"""Minimal test case that should work but fails"""
return "OK"
Expected: Tool response processed successfully Actual: "Tool Response parsing error"
hi @asdkjasdfla, thanks for trying out Nova Sonic. Can you specify which version of LiveKit Agents you're using? Because tool calling works on my end.
One possible mistake that you may be making is that if you don't supply the raw_schema for function tools, you really should have a docstring. Also, don't return function tool responses as strings-- return as dicts.
See this example for how to implement and bind function tools to Nova Sonic: https://github.com/livekit/agents/blob/main/examples/voice_agents/realtime_joke_teller.py
Closing this issue-- feel free to reopen if you continue to have problems