busy-spoon-35253
12/11/2025, 5:28 PMtall-airline-16756
12/11/2025, 5:28 PMtall-airline-16756
12/11/2025, 5:29 PMlk agent logs --log-type deploy).
2. The handoff code you use (either the session.update_agent() call or the function/tool return that triggers the handoff).
3. Whether the target agent uses different plugins/tools or credentials than the source agent.
4. Your deployment region and plan type.
5. Confirmation that required secrets (for example OPENAI_API_KEY or other provider keys) are set in the cloud deployment.
If you prefer, paste the log and code here and I’ll review them and provide specific steps (config fixes, environment checks, or code adjustments) to resolve the _update_activity_task error.
Sources: Agents and handoffs | LiveKit docs | Deploying to production | LiveKit Docs | Agents Framework | livekit/livekit_composite | DeepWiki | Events and error handling | LiveKit docs | Agent deployment CLI reference | LiveKit docsbusy-spoon-35253
12/11/2025, 5:29 PMtall-airline-16756
12/11/2025, 5:30 PMlk agent logs
Note: this shows only the newest agent server instance, not all instances.
1. Ensure full detail is being captured
• Set the agent log level to DEBUG in start command or Dockerfile:
CMD ["python", "agent.py", "start", "--log-level=DEBUG"]
• Confirm Agent Observability is enabled in your project’s Data & privacy settings and your SDK version supports observability (Python ≥ 1.3.0, Node ≥ 1.0.18).
1. Download or copy the trace/log
• In Agent insights you can expand traces and download session data (transcript, trace, logs) for offline analysis. Observability data is retained for 30 days.
If you paste the trace or the Logs output here (or the lk agent logs output), I’ll review the full stack trace and point to the likely cause and next steps.
Sources: Agent insights in LiveKit Cloud | LiveKit docs | https://blog.livekit.io/streamline-troubleshooting-with-agent-observability/#/portal| | Log collection | LiveKit Docsbusy-spoon-35253
12/11/2025, 5:51 PMtall-airline-16756
12/11/2025, 5:51 PMlk agent logs
• Reproduce the handoff or scroll back to the timestamp (2025-12-11T175041). Copy the full error block including traceback lines that follow ERROR:livekit.agents:Error in _update_activity_task.
3) If observability isn’t enabled or you prefer downloading
• In Agent insights you can download the session data (transcript, trace, logs) and paste the trace/log file contents here.
What to include when you paste logs:
• The full traceback lines (stack frames and exception message)
• A few log lines before and after the error for context
• The trace span metadata if available (span name, timestamps, any attached error fields)
If you paste the full trace here I’ll review it and point to the likely cause and next steps.busy-spoon-35253
12/11/2025, 5:56 PMtall-airline-16756
12/11/2025, 5:56 PMERROR:livekit.agents:Error in _update_activity_task even after streaming logs. To help find the hidden traceback, please try the following short checks and share the results you get:
1. Confirm SDK & agent runtime
• Which agent SDK are you running (Python or Node)? Give the exact LiveKit Agents SDK version.
1. Increase log verbosity and restart the agent
• Start the agent with DEBUG or TRACE so exceptions and tracebacks are emitted.
• Examples:
◦ If running via CLI:
lk agent run --log-level=DEBUG
• If running in Docker, set the CMD to include `--log-level=DEBUG`:
CMD ["python", "agent.py", "start", "--log-level=DEBUG"]
• After restart, reproduce the handoff and paste the logs for ~30s around the error timestamp.
1. Verify observability is enabled (dashboard)
• In the LiveKit Cloud project, under Data & privacy, ensure Agent Observability is enabled. Then open the session → Agent insights → Trace and Logs to copy the expanded handoff span and log entries.
1. Check for swallowed exceptions in your code
• If your handoff code or lifecycle hooks use broad try/except blocks, they may catch and re-log without stack traces. Search for except Exception or generic catches around handoff and temporarily log the exception with exc_info=True (Python) or include the error stack (Node) to surface the traceback.
1. Confirm environment differences
• Tell me how you deploy (lk agent deploy, custom container, etc.), and whether the deployed image matches your local one (same dependencies / commit).
• Verify required secrets (e.g., provider API keys) are present in the cloud deploy.
If you prefer, paste:
• The agent start command or Docker CMD,
• The handoff code snippet,
• The output you see after starting with --log-level=DEBUG.
I’ll review those and point to the exact line that should produce the full traceback or the specific fix to surface it.busy-spoon-35253
12/11/2025, 5:58 PMtall-airline-16756
12/11/2025, 5:58 PMlogger.exception("...") or logger.error("...", exc_info=True) where you catch exceptions in lifecycle hooks, handoff logic, or `on_enter`/`on_exit`.
• If you have generic except Exception: blocks around handoff or tool calls, temporarily re-raise after logging to surface the traceback.
1. Reproduce with a single-instance run (if possible)
• Run the agent container locally or via lk agent run --local with the same image and env vars and trigger the exact handoff. Local runs often show full tracebacks that get lost in multi-instance cloud logging.
1. Confirm no worker/process is exiting early
• Check your Docker/container entrypoint and supervisor: ensure Python isn’t swallowing exceptions because a child process exits. In logs, look for process restarts or termination messages immediately after the ERROR line.
If you still only have the single error line after steps 1–2, please paste:
• The expanded Trace span error details (from Agent Insights) OR the downloaded logs (50 lines before/after the ERROR).
• Your SDK (Python/Node) and exact SDK version.
• The handoff code snippet and any `on_enter`/`on_exit` hooks involved.
I’ll analyze the trace/log block and the handoff code and point to the exact cause and fix.busy-spoon-35253
12/11/2025, 6:25 PMtall-airline-16756
12/11/2025, 6:26 PMbusy-spoon-35253
12/11/2025, 6:26 PMtall-airline-16756
12/11/2025, 6:26 PMlk agent list
1. Delete the agent (removes the deployed container and its secrets for that deployment):
lk agent delete --id <agent_id>
1. Confirm deletion (optional):
lk agent list
1. Create/deploy a fresh agent:
• Interactive create:
lk agent create
• Or deploy from a config:
lk agent deploy -f agent.yml
1. Re-add required secrets (they are not retained after delete):
lk secret set --agent-id <new_agent_id> OPENAI_API_KEY=<your_key>
# repeat for other secrets
1. Re-enable Agent Observability if needed:
• Console → Project Settings → Data & Privacy → toggle Agent Observability on.
If you want, tell me the agent ID and I’ll confirm the exact delete/create commands for your setup, or paste any error you see while running these commands.busy-spoon-35253
12/12/2025, 3:40 AMtall-airline-16756
12/12/2025, 3:40 AMconversation_item is referenced before being assigned in livekit/plugins/openai/realtime/utils.py. That means the plugin code expects a value that isn’t being created for some chat item during the handoff.
What you can do next (quick, prioritized steps):
1. Tell me your LiveKit Agents SDK and OpenAI plugin versions (exact package versions).
2. Patch/workaround to get a quick repro and avoid the crash:
◦ In livekit/plugins/openai/realtime/utils.py around the function that defines conversation_item, add a safe guard so conversation_item is always initialized before being referenced. For example (conceptual):
▪︎ Ensure conversation_item = None before conditionals that may set it.
▪︎ Before conversation_item.id = item.id, check if conversation_item is None: create or skip and log the unexpected item shape.
◦ If you don’t want to change vendor code in production, run your agent locally with the same data and add logging around chat items to see which item shape is missing fields.
1. Verify incoming chat/context items:
◦ Inspect the chat items being passed during handoff (the chat_ctx contents). Look for any item lacking expected fields (id, type, etc.). Paste a representative chat item here and I’ll inspect it.
1. Recommended long-term fixes:
◦ Upgrade to the latest LiveKit Agents packages (SDK + plugins) if you can — this looks like a bug that may already be fixed in a newer release.
◦ If upgrading isn’t possible, I can give a minimal patch you can apply to realtime/utils.py to avoid the UnboundLocalError and log the problematic item so we can root-cause why it’s missing.
Which would you like to do first — share your package versions so I can check for a published fix, or I can provide the exact patch to add into realtime/utils.py now?busy-spoon-35253
12/12/2025, 4:19 AMtall-airline-16756
12/12/2025, 4:20 AMconversation_item is referenced before assignment inside livekit-plugins-openai (v1.3.6). Two practical fixes:
Option A — Recommended: upgrade packages and redeploy
1. Update packages and rebuild your image:
pip install --upgrade "livekit>=1.1" "livekit-agents>=1.4" "livekit-plugins-openai>=1.4"
1. Rebuild Docker, then in LiveKit Cloud:
lk agent delete --id <agent_id>
lk agent create # or lk agent deploy -f agent.yml
lk secret set --agent-id <new_agent_id> OPENAI_API_KEY=<your_key>
1. Enable Agent Observability and reproduce the handoff; trace/logs should no longer hit that UnboundLocalError.
Option B — Temporary workaround (if you cannot upgrade immediately) Add a small monkey-patch at startup (place in your main entry before agents start) to avoid the UnboundLocalError and log the offending item:
import logging
from livekit.plugins.openai.realtime import utils as openai_utils
_original = openai_utils.livekit_item_to_openai_item
def _patched(chat_item):
try:
return _original(chat_item)
except UnboundLocalError as e:
if "conversation_item" in str(e):
logging.warning("Missing conversation_item for chat_item %s; skipping.", getattr(chat_item, "id", None))
placeholder = type("P", (), {})()
placeholder.id = getattr(chat_item, "id", None)
placeholder.role = getattr(chat_item, "role", None)
placeholder.content = getattr(chat_item, "content", "")
return placeholder
raise
openai_utils.livekit_item_to_openai_item = _patched
Which path would you like to take — upgrade+redeploy now, or apply the monkey-patch so you can keep running while scheduling an upgrade? If you choose upgrade, paste the agent ID and I’ll confirm the exact deploy commands for your setup.
Sources: Agent deployment CLI reference | LiveKit docsbusy-spoon-35253
12/12/2025, 4:21 AMtall-airline-16756
12/12/2025, 4:21 AMpip install --upgrade "livekit>=1.1" "livekit-agents>=1.4" "livekit-plugins-openai>=1.4"
# keep others as specified:
pip install "livekit-blingfire==1.0.0" "livekit-plugins-silero==1.3.6" "livekit-plugins-noise-cancellation==0.2.5"
1. Rebuild your Docker image:
docker build -t my-agent:latest .
1. Delete the existing agent in LiveKit Cloud and create/deploy a fresh one:
lk agent list
lk agent delete --id <old_agent_id>
lk agent create # or: lk agent deploy -f agent.yml
1. Re-set secrets (they are not retained after delete):
lk secret set --agent-id <new_agent_id> OPENAI_API_KEY=<your_key>
# repeat for any other secrets
1. Enable/confirm Agent Observability and run a repro:
• Console → Project Settings → Data & Privacy → Agent Observability ON
• Reproduce the handoff and check Agent Insights → Trace and Logs for absence of the UnboundLocalError.
If you need, I can provide:
• The exact pip/pyproject snippet you should add, or
• The minimal monkey-patch (temporary) if you must avoid an immediate redeploy.
Which would you like?busy-spoon-35253
12/12/2025, 4:26 AMtall-airline-16756
12/12/2025, 4:26 AMbusy-spoon-35253
12/12/2025, 4:40 AMtyping_extensions.TypedDict instead of typing.TypedDict on Python < 3.12.
For further information visit https://errors.pydantic.dev/2.5/u/typed-dict-version