Skip to navigation
AgentsTesting

SimulatedCall

View as MarkdownOpen in Claude

What one tool call came to in the simulation. CallSimulator.call() and replay() return it, and CallSimulator.calls keeps every one.

from signalwire.testing import SimulatedCall

Properties

name
str

The tool’s name.

args
dict[str, Any]

The arguments the model sent.

result
dict[str, Any]

The result as the platform gets it: response, and action when the result has actions.

ran
bool

Whether the tool’s handler, or its stub, ran.

blocked_by
str | None

Why the tool didn’t run: "step" for a tool the current step doesn’t offer (or a navigation the step doesn’t allow), or the id of the semantic gate that blocked it. None when it ran.

response
str

The result’s text: its response, or the tool_result of a structured response.

tool_prompt
str | None

The result’s tool_prompt, when it has one.

actions
list[dict[str, Any]]

The result’s actions.

Example

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("place_order", "Place the order", {"type": "object", "properties": {}},
lambda args, raw_data: FunctionResult("Order placed.").hangup())
ctx = agent.define_contexts().add_context("default")
ctx.add_step("take").set_text("Take the order.").set_functions("none")
ctx.add_step("confirm").set_text("Confirm the order.").set_functions(["place_order"])
outcome = CallSimulator(agent).call("place_order")
print(outcome.ran, outcome.blocked_by)
# False step
print(outcome.response)
# Nothing ran: place_order isn't available at this point in the call. The steps that offer it: confirm. No tools are available now.