{"message": ":studio_microphone: Setting up audio ...
# ask-ai
c
{"message": "🎙️ Setting up audio recording for room: outbound-call-3AJYV31U", "level": "INFO", "name": "outbound--caller-agent", "timestamp": "2025-08-26T131717.584563+00:00"} {"message": "unhandled exception while running the job task", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File \"D:\\conda\\envs\\voice_env\\Lib\\site-packages\\opentelemetry\\util\\_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"D:\\conda\\envs\\voice_env\\Lib\\site-packages\\livekit\\agents\\ipc\\job_proc_lazy_main.py\", line 240, in _traceable_entrypoint\n await self._job_entrypoint_fnc(job_ctx)\n File \"D:\\Voice\\Voice_Agent\\tier1_livekit_agent\\call_agent.py\", line 604, in entrypoint\n recording_req = api.RoomCompositeEgressRequest(\n room_name=ctx.room.name,\n audio_only=RecordingConfig.AUDIO_ONLY, # Record only audio for voice calls\n output=file_output, # Use 'output' field as per LiveKit Egress API\n )\nValueError: Expected a field name, but got oneof name output.", "timestamp": "2025-08-26T131717.584910+00:00"} {"mess
t
Thanks for reaching out, raj. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error happens because the
output
field in
RoomCompositeEgressRequest
is a
oneof
field, which means you can only set one of its options (
file
,
stream
, or
segments
) at a time. You can’t assign a value directly to the
output
field itself. To fix this, just pick one of these specific output fields to set: • For File Output: Use the
file
field and fill in details like file type and path. • For Stream Output: Use the
stream
field and provide the streaming protocol and URLs. • For Segmented File Output: Use the
segments
field, which works well for HLS or similar setups. Or, if you want to include multiple outputs in one request, you can use the newer
file_outputs
,
stream_outputs
, or
segment_outputs
fields. If you’d like, I’m happy to share some examples or help you troubleshoot further—just let me know! Sources: livekit-protocol/livekit/protocol/egress.pyi | livekit/livekit_egress.pb.go | Universal Egress
c
Problem: We're trying to implement audio recording using LiveKit Egress service, but the recording is not working despite the service being properly configured and running. Current Setup: 1. LiveKit Egress Service: Running via Docker Compose with Redis dependency 2. Agent Code: Modified to use file=file_output in RoomCompositeEgressRequest (correct oneof field usage) 3. Environment Variables: Set in terminal session (LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET) What's Happening: 1. Agent Logs Show: 🎙️ Setting up audio recording for room: [room-name] 2. No Recording Errors: The agent doesn't show any recording-related errors or success messages 3. No Recording Files: The recordings/ directory remains empty 4. Egress Service: Running and connected to Redis, logs show "service ready" Code Changes Made: python # Changed from: output=file_output # To: file=file_output # Use 'file' field within the 'output' oneof Questions for LiveKit Bot: 1. Why is the agent not connecting to the Egress service? The agent shows "Setting up audio recording" but then proceeds without any recording logs. 2. Does the agent need to be configured differently to connect to the Egress service? 3. Are there missing environment variables or configuration that the agent needs? 4. How should the agent authenticate with the Egress service? 5. Is there a network configuration issue preventing the agent from reaching the Egress service? # Changed from: output=file_output # To: file=file_output # Use 'file' field within the 'output' oneof recording_req = api.RoomCompositeEgressRequest( room_name=ctx.room.name, audio_only=RecordingConfig.AUDIO_ONLY, file=file_output, # Using 'file' field within 'output' oneof ) lkapi = api.LiveKitAPI() recording_response = await lkapi.egress.start_room_composite_egress(recording_req) The agent is running in a terminal session with these environment variables, but the recording setup appears to complete silently without actually starting the recording or showing any connection to the Egress service. + rm -rf '/home/egress/tmp/*' + rm -rf /var/run/pulse /var/lib/pulse /home/egress/.config/pulse /home/egress/.cache/xdgr/pulse + pulseaudio -D --verbose --exit-idle-time=-1 --disallow-exit I: [pulseaudio] main.c: Daemon startup successful. + exec /tini -- egress 2025-08-26T134518.215Z INFO egress redis/redis.go:142 connecting to redis {"nodeID": "NE_fYv6LMTCDo8u", "clusterID": "", "simple": true, "addr": "redis:6379"} 2025-08-26T134518.217Z INFO egress hwstats/cpu_linux.go:77 failed reading cgroup specific cpu stats, falling back to system wide implementation {"nodeID": "NE_fYv6LMTCDo8u", "clusterID": ""} 2025-08-26T134518.217Z INFO egress stats/monitor.go:145 cpu available: 8.000000 max cost: 4.000000 {"nodeID": "NE_fYv6LMTCDo8u", "clusterID": ""} 2025-08-26T134518.218Z INFO egress server/server.go:148 service ready {"nodeID": "NE_fYv6LMTCDo8u", "clusterID": ""}
t
The issue might be because the custom template page isn’t sending the
START_RECORDING
console signal that’s needed. When you call the
StartRoomCompositeEgress
API, the egress recorder opens a headless Chrome instance with a URL that includes things like the LiveKit server URL and an access token. But the recording will only kick off once the template page logs
START_RECORDING
to the console. Here’s how you can fix it: 1. Make sure your custom template calls
EgressHelper.startRecording()
so it sends out that
START_RECORDING
console log. 2. Try using the
test-template
subcommand in the LiveKit CLI to preview and debug your egress template before you start recording. 3. Double-check that the headless Chrome instance can actually load the page at the URL it’s given, including all the parameters like server URL, token, and layout. 4. Take a look at the egress logs and metrics for any connection hiccups, page load problems, or errors during track subscription that might stop the page from loading and sending that important signal. If you do see the
START_RECORDING
signal but recording still isn’t starting, it’s a good idea to confirm that the egress service is connected to the LiveKit room and has subscribed to the media tracks. Feel free to reach out if you want me to help you troubleshoot further! Sources: Custom Recording Template | LiveKit Docs | cmd/lk/egress.go | Egress & Recording | livekit/livekit_composite | DeepWiki
c
🚨 I Have a Clear Understanding of the Issue Now Based on the logs, I can see exactly what's happening: �� The Problem: 1. The file field approach works - we can create the RoomCompositeEgressRequest with file=file_output 2. But the API still expects an output field - we get TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400) 🤔 What I Don't Understand: The LiveKit Python SDK seems to have a mismatch between field names and API requirements: • We can use file=file_output to create the request object • But the underlying API call still expects an output field • This suggests the Python SDK might be incomplete or have a bug ❓ Questions for LiveKit Bot: 1. Field Structure: In the Python SDK, when creating a RoomCompositeEgressRequest, should we use: • file=file_output • output=file_output • Some other field name? 2. API Mismatch: Why does the Python SDK allow file=file_output but the API call fails with "missing output field"? 3. Correct Syntax: What is the exact correct way to create a recording request using the Python SDK? 4. SDK Version: Is this a known issue with the current Python SDK version? 💡 My Hypothesis: The Python SDK might be missing the proper field mapping, or there might be a version mismatch between the SDK and the API. I recommend asking the LiveKit bot these specific questions rather than me guessing at the correct syntax. The error patterns are too inconsistent for me to determine the right approach without official guidance.
t
The error happens because the
output
field in
RoomCompositeEgressRequest
is deprecated and shouldn’t be used anymore. Instead, try using the plural fields like
file_outputs
,
stream_outputs
, or
segment_outputs
to set up your output. Here’s the right way to create a recording request with the Python SDK:
Copy code
from livekit import api

req = api.RoomCompositeEgressRequest(
    room_name=ctx.room.name,
    audio_only=True,
    file_outputs=[api.EncodedFileOutput(
        file_type=api.EncodedFileType.OGG,
        filepath="livekit/my-room-test.ogg",
        s3=api.S3Upload(
            bucket="your-s3-bucket",
            region="your-s3-region",
            access_key="your-access-key",
            secret="your-secret-key",
        ),
    )]
)
Make sure you’re using the latest version of the Python SDK to keep things running smoothly. If you have any more questions or need a hand, just let me know! Sources: Universal Egress | livekit/livekit_egress.pb.go | Session recording and transcripts | LiveKit Docs | Session recording and transcripts | LiveKit Docs
c
Looking at the logs, I can see the issue clearly now. Let me analyze what's happening: 🔍 What's Working: ✅ The recording request is being created successfully with file_outputs=[file_output] ✅ The request structure shows: File outputs count: 1 ✅ No more ValueError about field names ❌ What's Still Failing: text ❌ Failed to start audio recording: TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400) �� The Problem: Even though we're using the correct file_outputs field, the LiveKit Egress service is still expecting an output field. This suggests there's a version mismatch or API incompatibility between: 1. The Python SDK (which accepts file_outputs) 2. The LiveKit Egress service (which still expects output) �� Summary for LiveKit Bot: Issue: Audio recording fails with TwirpError: request has missing or invalid field: output What we tried: • Used file_outputs=[file_output] as per current documentation • Request creates successfully in Python SDK • But Egress service rejects it saying output field is missing Questions for LiveKit Bot: 1. Version Compatibility: What version of the Python SDK should work with what version of the Egress service? 2. Field Mapping: Is there a different field name we should use, or does the Egress service need to be updated? 3. API Structure: Should we be using a different approach entirely for local file recording? 4. Service Requirements: Does the Egress service need specific configuration to accept the new field structure? Current Setup: • Python SDK: Latest version • Egress service: Running via Docker Compose • Recording type: Local file (not cloud storage) The error suggests the Egress service hasn't been updated to handle the new file_outputs field structure, or we need to use a different approach for local recording.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
c
got it: look at the following: Looking at your issue, you're experiencing a version compatibility problem between the Python SDK's
file_outputs
field and the LiveKit Egress service expecting the deprecated
output
field <cite/>. ## The Root Issue The LiveKit protocol supports both the new
file_outputs
array field and the deprecated singular `file`/`output` field for backward compatibility [1](#0-0) . However, your Egress service appears to be running an older version that only recognizes the deprecated fields. ## How the Field Migration Works The Egress service handles both field formats through backward compatibility logic [2](#0-1) . When
file_outputs
is empty, it falls back to checking the deprecated
file
field via the
EncodedOutputDeprecated
interface. The protocol definition shows that the old
file
field is marked as deprecated with
[deprecated=true]
[3](#0-2) . ## Solutions ### 1. Update Your Egress Service Your Docker Compose setup is likely running an outdated Egress service version. Update to a newer version that supports the
file_outputs
field. ### 2. Use Both Fields (Temporary Workaround) Several SDKs use both the new and deprecated fields simultaneously for compatibility [4](#0-3) . You can set both
file_outputs=[file_output]
and the deprecated
file=file_output
field. ### 3. Rust SDK Approach The Rust SDK explicitly sets the deprecated
output
field to
None
while using the new fields [5](#0-4) , indicating this is the intended migration path. ## Version Compatibility The test cases show that both field formats should work [6](#0-5) , but your service version predates the
file_outputs
support. Notes The error "missing or invalid field: output" suggests your Egress service is validating against an older protobuf schema. The solution is primarily updating your service version rather than changing your Python code, as the SDK is correctly using the current API format. livekit/livekit_composite livekit/python-sdks/livekit-protocol/livekit/protocol/egress.pyi segments: SegmentedFileOutput preset: EncodingOptionsPreset advanced: EncodingOptions file_outputs: _containers.RepeatedCompositeFieldContainer[EncodedFileOutput] stream_outputs: _containers.RepeatedCompositeFieldContainer[StreamOutput] segment_outputs: _containers.RepeatedCompositeFieldContainer[SegmentedFileOutput] image_outputs: _containers.RepeatedCompositeFieldContainer[ImageOutput] webhooks: _containers.RepeatedCompositeFieldContainer[_models.WebhookConfig] def __init__(self, room_name: _Optional[str] = ..., layout: _Optional[str] = ..., audio_only: bool = ..., audio_mixing: _Optional[_Union[AudioMixing, str]] = ..., video_only: bool = ..., custom_base_url: _Optional[str] = ..., file: _Optional[_Union[EncodedFileOutput, _Mapping]] = ..., stream: _Optional[_Union[StreamOutput, _Mapping]] = ..., segments: _Optional[_Union[SegmentedFileOutput, _Mapping]] = ..., preset: _Optional[_Union[EncodingOptionsPreset, str]] = ..., advanced: _Optional[_Union[EncodingOptions, _Mapping]] = ..., file_outputs: _Optional[_Iterable[_Union[EncodedFileOutput, _Mapping]]] = ..., stream_outputs: _Optional[_Iterable[_Union[StreamOutput, _Mapping]]] = ..., segment_outputs: _Optional[_Iterable[_Union[SegmentedFileOutput, _Mapping]]] = ..., image_outputs: _Optional[ ... (truncated) class WebEgressRequest(_message.Message): slots = ("url", "audio_only", "video_only", "await_start_signal", "file", "stream", "segments", "preset", "advanced", "file_outputs", "stream_outputs", "segment_outputs", "image_outputs", "webhooks") livekit/livekit_composite livekit/egress/pkg/config/output.go segments := req.GetSegmentOutputs() images := req.GetImageOutputs() // file output var file *livekit.EncodedFileOutput switch len(files) { case 0: if r, ok := req.(egress.EncodedOutputDeprecated); ok { file = r.GetFile() } case 1: file = files[0] default: return errors.ErrInvalidInput("multiple file outputs") } if file != nil { conf, err := p.getEncodedFileConfig(file) if err != nil { livekit/livekit_composite livekit/python-sdks/livekit-protocol/livekit/protocol/egress.py if _descriptor._USE_C_DESCRIPTORS == False: _globals['DESCRIPTOR']._options = None _globals['DESCRIPTOR']._serialized_options = b'Z#github.com/livekit/protocol/livekit\252\002\rLiveKit.Proto\352\002\016LiveKit::Proto' _globals['_ROOMCOMPOSITEEGRESSREQUEST'].fields_by_name['file']._options = None _globals['_ROOMCOMPOSITEEGRESSREQUEST'].fields_by_name['file']._serialized_options = b'\030\001' _globals['_ROOMCOMPOSITEEGRESSREQUEST'].fields_by_name['stream']._options = None _globals['_ROOMCOMPOSITEEGRESSREQUEST'].fields_by_name['stream']._serialized_options = b'\030\001' _globals['_ROOMCOMPOSITEEGRESSREQUEST'].fields_by_name['segments']._options = None _globals['_ROOMCOMPOSITEEGRESSREQUEST'].fields_by_name['segments']._serialized_options = b'\030\001' _globals['_WEBEGRESSREQUEST'].fields_by_name['file']._options = None _globals['_WEBEGRESSREQUEST'].fields_by_name['file']._serialized_options = b'\030\001' _globals['_WEBEGRESSREQUEST'].fields_by_name['stream']._options = None livekit/livekit_composite livekit/server-sdk-kotlin/src/main/kotlin/io/livekit/server/EgressServiceClient.kt audioMixing: AudioMixing = AudioMixing.DEFAULT_MIXING ): Call<LivekitEgress.EgressInfo> { @Suppress("DEPRECATION") val requestBuilder = LivekitEgress.RoomCompositeEgressRequest.newBuilder() .setFile(output) .addFileOutputs(output) return startRoomCompositeEgressImpl( requestBuilder, roomName, livekit/livekit_composite livekit/rust-sdks/livekit-api/src/services/egress.rs options.encoding.into(), )), custom_base_url: options.custom_base_url, file_outputs, stream_outputs, segment_outputs, image_outputs, output: None, // Deprecated ..Default::default() }, self.base .auth_header(VideoGrants { room_record: true, ..Default::default() }, None)?, ) livekit/livekit_composite livekit/protocol/egress/types_test.go ) func TestGetOutputType(t *testing.T) { roomReq := &livekit.RoomCompositeEgressRequest{ FileOutputs: []*livekit.EncodedFileOutput{ &livekit.EncodedFileOutput{}, }, } ot := GetOutputType(roomReq) require.Equal(t, OutputTypeFile, ot) roomReq = &livekit.RoomCompositeEgressRequest{ Output: &livekit.RoomCompositeEgressRequest_File{ File: &livekit.EncodedFileOutput{}, }, } ot = GetOutputType(roomReq) require.Equal(t, OutputTypeFile, ot) trackReq := &livekit.TrackCompositeEgressRequest{ SegmentOutputs: []*livekit.SegmentedFileOutput{
❌ What's Still Failing: text ❌ Failed to start audio recording: TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400) �� The Core Problem: Even though we're using the correct file_outputs field, the LiveKit Egress service is still expecting an output field. This confirms the version compatibility issue mentioned in the LiveKit analysis. �� Summary for LiveKit Bot: Problem: The Python SDK accepts file_outputs=[file_output] but the Egress service still requires the deprecated output field. What we've tried: 1. ✅ output=file_output → ValueError: Expected a field name, but got oneof name output 2. ✅ file=file_output → TwirpError: request has missing or invalid field: output 3. ✅ file_outputs=[file_output] → TwirpError: request has missing or invalid field: output Current state: Using both fields simultaneously: python recording_req = api.RoomCompositeEgressRequest( _room_name_=ctx.room.name, _audio_only_=True, _file_outputs_=[file_output], # New field file=file_output, # Deprecated field for compatibility ) Question for LiveKit Bot: • Why does the Egress service still require the output field even when file_outputs is provided? • Is this a known compatibility issue between the Python SDK and Egress service versions? • What's the correct way to handle this version mismatch? The agent is working perfectly otherwise - all database tables are populated, lead status updates correctly, and the conversation flow works. Only the audio recording is failing due to this API field compatibility issue