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
Optional[bool]Defaults to None

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

timeout
Optional[int]Defaults 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

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="wait_for_confirmation", description="Wait for user confirmation")
8def wait_for_confirmation(args, raw_data):
9 return (
10 FunctionResult("Please respond when you're ready.")
11 .wait_for_user(timeout=30)
12 )
13
14agent.serve()

Disable Waiting

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="disable_wait", description="Continue without waiting for input")
8def disable_wait(args, raw_data):
9 return (
10 FunctionResult("Continuing without waiting.")
11 .wait_for_user(enabled=False)
12 )
13
14agent.serve()