Skip to navigation
AgentsPatterns

RequestList

View as MarkdownOpen in Claude

RequestList keeps a list, in the call’s global_data, of what the caller asked for while the agent was busy with another task. A tool notes each request with note(), and the agent tells the caller it’s noted for right after this. Step text shows the list as ${global_data.<global_key>_text}, so once the current task is done, the agent takes up each request in order.

The model hears of each new request in the tool result. Current platform releases expand step text again when a value it reads changes, so the list shows in the step’s text at the next request. Earlier releases and realtime models keep the text from when the step was entered; return refresh_step() with the note to show the list there at once.

from signalwire.patterns import RequestList

Parameters

global_key
strRequired

The global_data key the list is kept under. The list’s text for step text is kept under <global_key>_text.

openers
Mapping[str, str] | NoneDefaults to None

Keyword-only. How the agent opens each kind of request when it takes it up, keyed by kind. {about} in an opener is replaced with what the request is about. A kind without an opener opens with what it’s about.

heading
strDefaults to Noted for right after this:

Keyword-only. The first line of the list’s text.

Methods

Example

from signalwire import AgentBase, FunctionResult
from signalwire.patterns import RequestList
agent = AgentBase(name="desk", route="/desk")
agent.prompt_add_section("Role", "You take orders and note other requests.")
later = RequestList("later", openers={"balance": "You also asked about your balance.",
"question": "You had a question: {about}."})
agent.set_global_data(later.defaults())
def note_request(args, raw_data):
return later.note(raw_data, args["kind"], args["about"])
def finish_request(args, raw_data):
return later.done(raw_data, FunctionResult("Done with that request."))
agent.define_tool("note_request", "Note something the caller asked for, to take up after the order",
{"type": "object",
"properties": {"kind": {"type": "string", "enum": ["balance", "question"]},
"about": {"type": "string"}},
"required": ["kind", "about"]}, note_request)
agent.define_tool("finish_request", "Mark the first noted request as taken up",
{"type": "object", "properties": {}}, finish_request)
ctx = agent.define_contexts().add_context("default")
ctx.add_step("take_order").set_text("Take the caller's order.\n\n${global_data.later_text}")
agent.serve()