This walks through connecting a LiveKit Agents voice agent to sopops in Python. When you’re done, the agent gets its instructions from sopops when each call starts, and every finished call comes back to be checked against its procedures.
Install the SDK
pip install "sopops[livekit]"
Set two variables
Wherever the agent runs, set:
SOPOPS_URL: your workspace’s API URL.SOPOPS_TOKEN: a workspace token with both theruntimescope (to fetch instructions) and theingestscope (to send calls). Create it under Settings → Access.
On LiveKit Cloud, add both as the agent’s secrets and deploy again. The SDK can’t reach sopops without them.
Call attach
In your agent’s entrypoint, call attach after ctx.connect() and use the text it returns as the agent’s instructions:
from livekit.agents import Agent, AgentSession
from sopops.livekit import attach
FALLBACK = "You are the scheduling assistant for a clinic. Verify the caller before discussing any appointment."
async def entrypoint(ctx):
await ctx.connect()
session = AgentSession(...) # your STT, LLM and TTS, as before
ins = await attach(ctx, session, fallback=FALLBACK)
await session.start(agent=Agent(instructions=ins.text), room=ctx.room)
attach does three things:
- Fetches the agent’s live release from sopops. By default it identifies the agent by the job’s agent name.
- Notes the release and agent in the session’s user data, so the call is tied to the exact instructions it ran.
- Registers a shutdown callback that posts the finished call to sopops, with its transcript and tool calls.
If sopops doesn’t answer in time, attach uses the last good copy it cached on disk, or your fallback text if there’s nothing cached. Each result says where the text came from, which is worth logging.
Read the results
Open Sessions in sopops. Each call shows its transcript, its tool calls, and a result for each procedure that applied: followed, partly followed, deviated, or not measurable. The parts of the transcript that show each result are highlighted.
When the same miss shows up on several calls, it becomes a pattern under Review. Give it a verdict, and for a real mistake sopops drafts the fix to the agent’s instructions.
Optional: stream the call as it happens
Pass stream=True to also send each turn and tool call while the call runs, instead of only at the end:
ins = await attach(ctx, session, fallback=FALLBACK, stream=True)
The full docs cover pinning a release for an A/B test, filling placeholders per call, and the TypeScript version. Read the docs →
Questions
- What happens if sopops is down when a call starts?
- The call still starts. The SDK uses the last good copy of the instructions it cached, or the fallback text you pass, if nothing is cached yet.
- Can I check calls without serving instructions from sopops?
- Yes. On LiveKit you can capture calls with no code, using a project key and a webhook, or use record_session to post calls from an agent that gets its instructions some other way.
- Is there a TypeScript version?
- Yes. The sopops npm package has the same attach function in sopops/livekit.