what's the purpose of MAX_TOOL_STEPS ? explain in ...
# ask-ai
c
what's the purpose of MAX_TOOL_STEPS ? explain in detail
t
Thanks for reaching out, Purna. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The
MAX_TOOL_STEPS
parameter in the
AgentSession
class defines the maximum number of consecutive tool calls that can be made per LLM turn. By default, this value is set to 3. When this limit is reached during tool execution, the system logs a warning message: "maximum number of function calls steps reached" and stops further tool execution for that turn. This parameter is designed to prevent infinite loops or excessive tool usage by limiting how many consecutive tool operations can occur before requiring another interaction with the user. Sources: Tree View: | dse-workbench
c
I have a function call which takes 30 seconds to finish, now the agent currently executed this function_call. The problem is when the user speaks anything when the function_call is running, the agent will call the function again. how can I prevent that?
t
To prevent the agent from calling a function again while it is still executing, you can use the
max_nested_fnc_calls
parameter. This parameter controls the maximum depth of nested function calls allowed. When the nested function depth reaches or exceeds the configured maximum depth, the function context is dropped, and additional function calls are prevented. For your scenario, you can set
max_nested_fnc_calls
to a lower value or even to 0 to completely disable nested function calls. This ensures that the agent will not call the function again while it is still running. Sources: livekit.agents.pipeline.pipeline_agent API documentation
c
Thanks, will test it out.
t
You're welcome! Feel free to reach out if you have any further questions or need assistance. Good luck with your testing!
c
is max_nested_fnc_calls present in V1
t
Yes, the
max_nested_fnc_calls
parameter is available in V1. It is part of the
VoicePipelineAgent
class constructor and controls the maximum depth of nested function calls allowed. By default, its value is set to 1. Sources: livekit.agents.pipeline API documentation