from signalwire import AgentBase, FunctionResult
from signalwire.testing import CallSimulator
agent = AgentBase(name="orders", route="/orders")
agent.prompt_add_section("Role", "You take orders.")
agent.define_tool("review_order", "Read the order back", {"type": "object", "properties": {}},
lambda args, raw_data: FunctionResult("Read the order back.").swml_change_step("confirm"))
agent.define_tool("place_order", "Place the order", {"type": "object", "properties": {}},
lambda args, raw_data: FunctionResult("Order placed."))
ctx = agent.define_contexts().add_context("default")
ctx.add_step("take").set_text("Take the order.").set_functions(["review_order"])
ctx.add_step("confirm").set_text("Confirm the order.").set_functions(["place_order"]).set_history("isolate")
sim = CallSimulator(agent)
print(sim.history_mode())
# default
sim.call("review_order")
print(sim.history_mode())
# isolate