equivalent of session.is_running() / parameter to ...
# ask-ai
a
equivalent of session.is_running() / parameter to check if session is running to gaurd session.interrupt() when session is active
✅ 1
t
Thanks for reaching out, Harshita. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking whether there's an equivalent to
session.is_running()
(a way to check if a session is active) so you can safely call
session.interrupt()
only when appropriate. There isn't a direct
session.is_running()
API. Instead, track the session lifecycle / agent state and only call
session.interrupt()
when the session is in a running phase (i.e., not
initializing
or
closing
) — specifically when the agent state indicates it's active (for example
speaking
,
thinking
, or
listening
). Use the
agent_state_changed
event to monitor those state transitions and maintain a local flag (e.g.,
isRunning
) that you check before calling
session.interrupt()
. If you want, tell me which SDK/language you're using and I can show a short code example that listens for the
agent_state_changed
event and guards
session.interrupt()
. Sources: https://docs.livekit.io/agents/logic/sessions.md| | Agent session | LiveKit Documentation, with interactive elements
a
"generate_reply is not compatible with 'gemini-3.1-flash-live-preview' and will be ignored.", "level": "WARNING", "name": "livekit.plugins.google", "pid": 54096, "job_id": "AJ_hTrrmGedJfFL", "room_id": "RM_fHKpJhUfiodK", "timestamp": "2026-05-17T191850.370542+00:00"} {"message": "failed to generate a reply: generate_reply is not compatible with 'gemini-3.1-flash-live-preview'", "level": "ERROR", "name": "livekit.agents", "pid": 54096, "job_id": "AJ_hTrrmGedJfFL", "room_id": "RM_fHKpJhUfiodK", "timestamp": "2026-05-17T191850.370656+00:00"} {"message": what should be used instead
t
Thanks — you're asking what to use instead of
generate_reply()
when you get the error that it's not compatible with
gemini-3.1-flash-live-preview
. Short answer: •
generate_reply()
is not supported with
gemini-3.1-flash-live-preview
. Use one of these alternatives depending on your needs: Options • Switch to a compatible model that supports
generate_reply()
(for realtime audio): use a Gemini 2.5 realtime model such as
gemini-2.5-flash-native-audio-preview-12-2025
. • Use LiveKit Inference (the STT → LLM → TTS pipeline) with a Gemini LLM (e.g.,
google/gemini-3-flash-preview
) —
inference.LLM
supports
generate_reply()
and dynamic context updates. • Keep
gemini-3.1-flash-live-preview
for realtime audio but avoid `generate_reply()`; rely on built-in realtime behaviors (e.g.,
on_enter
lifecycle hooks) or normal conversational flow and tool calls supported by that realtime plugin. If you tell me which SDK/language and whether you need realtime audio or manual reply control, I can give a short code example or exact model name to switch to. Sources: Gemini Live API plugin | LiveKit Documentation | Bring your LangChain Agents to LiveKit | LiveKit | Agent speech and audio | LiveKit Documentation | Google Gemini LLM | LiveKit Documentation | Amazon Nova Sonic integration guide | LiveKit Documentation, with interactive elements
a
Copy code
session.chat_ctx.messages.append(
    llm.ChatMessage(
        role=llm.ChatRole.USER,  # or "user"
        text="Hello? Are you there?"  # Note: Use 'text' (or 'content' depending on your package version)
    )
)
correct way to append message
t
You're right to avoid mutating internal lists. Use the chat context API instead. Python (recommended):
Copy code
# add a user message to the session chat context
session.chat_ctx.add_message(role="user", content="Hello? Are you there?")
# then persist the update if needed
await agent.update_chat_ctx(session.chat_ctx)
Node.js:
Copy code
session.chatCtx.addMessage({ role: "user", content: "Hello? Are you there?" });
await agent.updateChatCtx(session.chatCtx);
This ensures the message is correctly formatted and integrated with the agent's history. If you tell me which SDK/version you're using, I can give a tailored snippet. Sources: Chat context | LiveKit Documentation, with interactive elements