wait_for_user

View as MarkdownOpen in Claude

Control how the agent pauses and waits for the user to speak. The arguments are evaluated in priority order: answer_first takes precedence, then timeout, then enabled. If none are provided, waiting is enabled with no timeout.

Parameters

enabled
bool | NoneDefaults to None

Explicitly enable (True) or disable (False) waiting for user input.

timeout
int | NoneDefaults to None

Number of seconds to wait for the user to speak before the agent continues.

answer_first
boolDefaults to False

When True, activates the special "answer_first" mode. This answers the call and waits for the user to speak before the agent begins its greeting.

Returns

FunctionResult — self, for chaining.

Examples

Wait with Timeout

from signalwire import AgentBase
from signalwire import FunctionResult
agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")
@agent.tool(name="wait_for_confirmation", description="Wait for user confirmation")
def wait_for_confirmation(args, raw_data):
return (
FunctionResult("Please respond when you're ready.")
.wait_for_user(timeout=30)
)
agent.serve()

Disable Waiting

from signalwire import AgentBase
from signalwire import FunctionResult
agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")
@agent.tool(name="disable_wait", description="Continue without waiting for input")
def disable_wait(args, raw_data):
return (
FunctionResult("Continuing without waiting.")
.wait_for_user(enabled=False)
)
agent.serve()