plain-summer-46051
05/13/2025, 1:11 PMtall-airline-16756
05/13/2025, 1:11 PMtall-airline-16756
05/13/2025, 1:12 PMImportError: cannot import name 'AgentSession' from 'livekit.agents'
typically occurs if the module or class is not available in the version of the LiveKit library you are using. Based on the documentation, AgentSession
should be importable directly from livekit.agents
as shown below:
from livekit.agents import AgentSession
Please ensure that:
• You have installed the correct version of the LiveKit library that includes AgentSession
.
• There are no typos in your import statement.
• Your environment is using the expected version of the library (e.g., check for virtual environment conflicts).
If the issue persists, please let me know, and I can assist further.
Sources: Building voice agents | LiveKit Docsplain-summer-46051
05/13/2025, 1:13 PMtall-airline-16756
05/13/2025, 1:13 PMAgentSession
is not explicitly mentioned in the documentation. However, the installation command provided in the sources is:
pip install "livekit-agents[openai,silero,deepgram,cartesia,turn-detector]~=1.0"
This suggests that version 1.0 or a compatible version should work. If you have installed the latest version and are still encountering issues, you might want to try this specific version range. Let me know if you need further assistance!plain-summer-46051
05/13/2025, 1:41 PMtall-airline-16756
05/13/2025, 1:42 PMlk.chat
topic. If you need to disable it, you can use the following code:
# To disable text input
room_input_options = RoomInputOptions(text_enabled=False)
If you want to ensure it is enabled, no additional configuration is required as it is the default behavior.
Frontend Integration
On the frontend, you need to use text streams with the lk.chat
topic. The agent will automatically process text messages sent on this topic. When a user sends a text message, the agent will interrupt its current speech (if any) to process the message and generate a new response.
For JavaScript/TypeScript applications, you can use the InputTextContent
interface. Here is an example structure:
{
text: "Your message here",
type: "input_text"
}
Let me know if you need further clarification or assistance!
Sources: Text and transcriptions | LiveKit Docs | Agents 0.x migration guide | LiveKit Docs | InputTextContent | LiveKit Agentsplain-summer-46051
05/13/2025, 2:46 PMtall-airline-16756
05/13/2025, 2:47 PMAttributeError: 'EOUPlugin' object has no attribute 'supports_language'
, occurs because the _bounce_eou_task
function is attempting to call a method supports_language
on the EOUPlugin
object, but this method is not implemented in your current setup.
To resolve this issue, ensure that your EOUPlugin
class either:
• Inherits from EOUModelBase
, which implements the supports_language
method, or
• Implements the supports_language
method with the following signature:
def supports_language(self, language: str | None) -> bool:
return self.unlikely_threshold(language) is not None
This method is required by the _TurnDetector
Protocol, which defines the expected interface for turn detection. Let me know if you need further assistance with implementing this fix!
Sources: Tree View: | dse-workbenchplain-summer-46051
05/13/2025, 3:34 PMtall-airline-16756
05/13/2025, 3:34 PMvoice_id
, welcome_message
, or prompt
to a LiveKit agent by including it in the job metadata during explicit agent dispatch. This metadata will then be accessible to the agent in the JobContext
.
Here is an example of how to include metadata during dispatch:
import asyncio
from livekit import api
room_name = "my-room"
agent_name = "test-agent"
async def create_explicit_dispatch():
lkapi = api.LiveKitAPI()
dispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name=agent_name,
room=room_name,
metadata='{"user_id": "12345", "voice_id": "voice1", "welcome_message": "Hello!"}'
)
)
print("created dispatch", dispatch)
In your agent's entrypoint function, you can access this metadata as follows:
import json
async def entrypoint(ctx: JobContext):
metadata = json.loads(ctx.job.metadata)
voice_id = metadata["voice_id"]
welcome_message = metadata["welcome_message"]
# Use these values in your agent logic
This approach allows you to customize your agent's behavior with specific parameters for each dispatch. Let me know if you need further assistance!
Sources: Agent dispatch | LiveKit Docs | Job lifecycle | LiveKit Docsplain-summer-46051
05/13/2025, 5:23 PMtall-airline-16756
05/13/2025, 5:23 PMJSONDecodeError: Expecting value
occurs when the metadata you are trying to parse is either empty, malformed, or not valid JSON. In your case, it seems that ctx.job.metadata
is not containing valid JSON data.
To resolve this issue, please ensure the following:
1. When dispatching the agent, make sure you are passing valid JSON in the metadata field. For example:
metadata='{"user_id": "12345", "voice_id": "voice1", "welcome_message": "Hello!"}'
1. Add error handling in your code to handle cases where metadata might be empty or invalid. Here is an example:
import json
async def entrypoint(ctx: JobContext):
try:
metadata = json.loads(ctx.job.metadata) if ctx.job.metadata else {}
voice_id = metadata.get("voice_id", "default_voice")
welcome_message = metadata.get("welcome_message", "Welcome!")
# Use these values in your agent logic
except json.JSONDecodeError:
# Handle invalid JSON
metadata = {}
voice_id = "default_voice"
welcome_message = "Welcome!"
This will ensure that your code can handle cases where the metadata is not properly formatted or is missing. Let me know if you need further assistance!
Sources: External data and RAG | LiveKit Docs | Job lifecycle | LiveKit Docstall-airline-16756
05/13/2025, 5:30 PMplain-summer-46051
05/13/2025, 5:30 PMtall-airline-16756
05/13/2025, 5:31 PMmetadata
parameter when creating the agent dispatch. For example:
dispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name="test-agent",
room="my-room",
metadata='{"voice_id": "voice1", "welcome_message": "Hello!"}'
)
)
1. Validate Metadata Format: Ensure that the metadata is a valid JSON string. Invalid JSON will not be parsed correctly by the agent.
2. Check Agent Code: Confirm that your agent's entrypoint
function is correctly accessing the metadata using ctx.job.metadata
. For example:
metadata = json.loads(ctx.job.metadata) if ctx.job.metadata else {}
voice_id = metadata.get("voice_id")
welcome_message = metadata.get("welcome_message", "Welcome!")
1. Debug Logging: Add logging to verify that the metadata is being received by the agent. For example:
<http://logger.info|logger.info>(f"Received job metadata: {ctx.job.metadata}")
1. Verify Dispatch Success: Ensure that the dispatch request is successful and that the agent is being created in the specified room.
If you have verified all of the above and the issue persists, please let me know, and I can assist further!
Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | room(_:didUpdateMetadata:) | Documentationplain-summer-46051
05/13/2025, 5:35 PMtall-airline-16756
05/13/2025, 5:35 PM