session.interrupt() can stop the agent from genera...
# ask-ai
i
session.interrupt() can stop the agent from generating audio. But does it still commit ongoing text message? How to prevent text message from being committed.
t
Thanks for reaching out, Jan. 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
session.interrupt()
prevents an ongoing text message from being committed, and how to avoid committing text. Short answer: •
session.interrupt()
stops audio playback and does not commit an incomplete agent response to chat history. Any unspoken or partially generated response is discarded; only the portion actually spoken before the interruption may be committed. • If you need explicit control (for
session.say()
calls with pre-supplied text), use
add_to_chat_ctx=False
to prevent that text from being added to chat history. Follow-up question: • Are you interrupting agent-generated speech (the agent composing a response) or calls to
session.say()
with a supplied
text
string? I can give exact code snippets for the scenario you use. Sources: Turns overview | LiveKit docs | Text and transcriptions | LiveKit docs | Agent speech and audio | LiveKit docs
i
I am seeing an agent performs function calling consecutively
t
Thanks — you're seeing the agent perform function calls consecutively. I can help, but I need one quick clarification first so I give the right guidance: Which of these matches your situation? • Multiple tool/function calls run in sequence with no agent reply between them. • The agent calls the same function repeatedly (looping). • Calls run in parallel and you want them serialized (or vice versa). • This behavior is causing issues with interruptions, turn detection, or message commitment. Also tell me: • Are you using
parallel_tool_calls=True
or
False
? • What are your
max_tool_steps
(if set)? • A short example (logs or sequence) of the consecutive calls you observe. With that I’ll explain why it’s happening and give exact settings or code changes to control the flow. Sources: Anthropic Claude LLM plugin guide | LiveKit docs | Agent session | LiveKit docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki
i
Where's
parallel_tool_calls=True
or
max_tool_steps
are set?
t
You're asking where to set
parallel_tool_calls
and
max_tool_steps
. Quick answer and examples: •
parallel_tool_calls
is passed to the LLM constructor (controls whether multiple tool calls can be emitted/executed in a single LLM turn). •
max_tool_steps
is passed to the
AgentSession
constructor (limits consecutive tool-call turns the agent can take). Example (Python):
Copy code
session = AgentSession(
    llm=openai.LLM(
        model="your-model",
        parallel_tool_calls=True,  # or False to serialize tool calls
    ),
    max_tool_steps=3,  # max consecutive tool-call turns before producing a response
    # ... tts, stt, tools, etc.
)
If you want to stop the agent from chaining many tool calls, set
parallel_tool_calls=False
and lower
max_tool_steps
(e.g., 1–3). Would you like a snippet for your specific LLM plugin or an example showing tool definitions and a sample run? Sources: Cerebras LLM plugin guide | LiveKit docs | Agent session | LiveKit docs | Anthropic Claude LLM plugin guide | LiveKit docs | Groq LLM plugin guide | LiveKit docs
i
I don't see it in
openai.realtime.RealtimeModel
option
t
You're right —
parallel_tool_calls
and
max_tool_steps
are not options on
openai.realtime.RealtimeModel
. Those controls live in the LiveKit Agent SDK configuration, not on the underlying realtime model wrapper. Quick summary and guidance: • Set
parallel_tool_calls
on the LLM wrapper you pass into the AgentSession (e.g.,
openai.LLM(...)
), not on
openai.realtime.RealtimeModel
. • Set
max_tool_steps
on the
AgentSession
itself. Example (Python) showing the separation:
Copy code
from livekit_agents import AgentSession
from livekit_agents.llms import openai

session = AgentSession(
    llm=openai.LLM(
        model="gpt-4o",
        parallel_tool_calls=False,  # set here, on the LLM wrapper
    ),
    max_tool_steps=2,  # set here, on AgentSession
    # other session options...
)
If you’re using a realtime model instance for streaming audio (e.g.,
openai.realtime.RealtimeModel
) keep using it for streaming/connection, but wrap/configure the LLM via the LiveKit LLM classes shown above. Would you like a concrete snippet showing how to combine
RealtimeModel
for streaming with the AgentSession LLM wrapper in your codebase?