set_gather_info

View as MarkdownOpen in Claude

Enable info gathering for this step. Call add_gather_question() after this method to define the questions.

The gather_info system collects structured information from the caller by presenting questions one at a time. It uses dynamic step instruction re-injection rather than tool calls, producing zero tool_call/tool_result entries in LLM-visible history.

Parameters

output_key
str

Key in global_data to store collected answers under. When None, answers are stored at the top level of global_data.

completion_action
str

Where to go when all questions are answered.

  • "next_step" — auto-advance to the next sequential step
  • A step name (e.g., "process_results") — jump to that specific step
  • None — return to normal step mode after gathering
prompt
str

Preamble text injected once when entering the gather step, giving the AI personality and context for asking the questions.

Returns

Step — Self for method chaining.

Example

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7intake = ctx.add_step("intake")
8intake.set_text("Collect patient information.")
9intake.set_gather_info(
10 output_key="patient_info",
11 completion_action="next_step",
12 prompt="Be friendly and professional when collecting information."
13)
14intake.add_gather_question(
15 key="full_name",
16 question="What is your full name?",
17 confirm=True
18)
19ctx.add_step("review").set_text("Review the collected information with the patient.")
20
21agent.serve()