agents icon indicating copy to clipboard operation
agents copied to clipboard

JobRequest ParticipantInfo Empty

Open Leandroglez39 opened this issue 1 year ago • 2 comments

Hi Everyone

We are using Livekit Agent Python SDK:

livekit==1.0.7 livekit-agents==1.0.21

We are trying to take control of the job acceptance process. But we can't get the participant information. We are using the request_fnc like this:

from livekit.agents import WorkerOptions, cli, JobRequest
from app.utils.prewarm import prewarm
from app.agent import entrypoint
from ecs_load import custom_load_fnc

async def request_fnc(req: JobRequest):
    
    print(req.room)

    print(req.publisher.__dict__)

    # Some logic to accept or reject the job depending on the publisher(participant)....
    
def main():
    cli.run_app(
        WorkerOptions(
            request_fnc=request_fnc,
            entrypoint_fnc=entrypoint,
            prewarm_fnc=prewarm,
            load_fnc=custom_load_fnc
        ),
    )

if __name__ == "__main__":
    main()

We got for req.room the following output:

sid: "RM_a2bVcbdkD42M"
name: "b8be9052-50a3-428a-9dcb-21ede409bb81"
empty_timeout: 300
creation_time: 1747814567
enabled_codecs {
  mime: "video/H264"
}
enabled_codecs {
  mime: "video/VP8"
}
enabled_codecs {
  mime: "video/VP9"
}
enabled_codecs {
  mime: "video/AV1"
}
enabled_codecs {
  mime: "audio/red"
}
enabled_codecs {
  mime: "audio/opus"
}
version {
  unix_micro: 1747814567811533
}
departure_timeout: 20
creation_time_ms: 1747814567766

But we are not able to get the participant information from req.publisher the information is not available:

{'AttributesEntry': <class 'models.AttributesEntry'>, 'DESCRIPTOR': <google._upb._message.Descriptor object at 0x7f71b1b0ae30>, '__module__': 'models', '__slots__': (), '__doc__': None}

Thank you for your help, and let me know if need more information.

Leandroglez39 avatar May 21 '25 09:05 Leandroglez39

Hi! I encountered the same issue and I can reproduce this using the voice agent example, see code below. This is a bug and not a question @Leandroglez39 in my opinion. Is there something we can do to resolve this?

agent.py

from dotenv import load_dotenv

from livekit import agents
from livekit.agents import AgentSession, Agent, RoomInputOptions
from livekit.plugins import (
    openai,
    noise_cancellation,
)
from livekit.agents import (
    JobRequest,
)

load_dotenv(".env.local")


class Assistant(Agent):
    def __init__(self) -> None:
        super().__init__(instructions="You are a helpful voice AI assistant.")


async def entrypoint(ctx: agents.JobContext):
    session = AgentSession(
        llm=openai.realtime.RealtimeModel(
            voice="coral"
        )
    )

    await session.start(
        room=ctx.room,
        agent=Assistant(),
        room_input_options=RoomInputOptions(
            # For telephony applications, use `BVCTelephony` instead for best results
            noise_cancellation=noise_cancellation.BVC(),
        ),
    )

    await session.generate_reply(
        instructions="Greet the user and offer your assistance. You should start by speaking in English."
    )

async def request_fnc(req: JobRequest) -> None:    
    # print("Rejecting job request")
    # await req.reject()

    print("JobRequest data:")
    print("Participant", req.job.participant)
    print("Participant identity", req.job.participant.identity)
    print("Room", req.job.room.name)
    if req.publisher:
        print("Publisher", req.publisher.identity)
    else:
        print("No publisher metadata")

    print("Accepting job request")
    await req.accept()

if __name__ == "__main__":
    agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint, request_fnc=request_fnc))

Result

All these fields should have been set. Only room works.

JobRequest data:
Participant identity
Participant
Room rene-2
Publisher
Accepting job request

filipre avatar Oct 23 '25 07:10 filipre

Could you provide a reason why this is not a bug and "not planned"?

filipre avatar Apr 24 '26 07:04 filipre