set_response

View as MarkdownOpen in Claude

Set or replace the response after construction. The response is a prompt injected into the model’s context, not text spoken verbatim, so write it as an instruction in the second person. To separate a factual outcome from the speaking instruction, use set_tool_response() instead.

Parameters

response
strRequired

Instruction for the model, such as "Tell the caller their order shipped yesterday."

Returns

FunctionResult — self, for chaining.

Example

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="check_order", description="Look up an order by ID")
def check_order(args, raw_data):
order_id = args.get("order_id")
result = FunctionResult()
if order_id:
result.set_response(f"Tell the caller order {order_id} shipped yesterday.")
else:
result.set_response("Tell the caller you couldn't find that order number.")
return result
agent.serve()