Skip to navigation

back_to_back_functions

View as MarkdownOpen in Claude

Set whether the model can call another function right after a function result, without answering the caller in words first.

The setting lasts for the rest of the call, including a setting made by a semantic gate’s on_fail. After a refused gate turns chaining off, return "forever" from a later result to turn it back on; otherwise every later function result needs a spoken answer after it. It applies to the text pipeline only: realtime models don’t read it.

Parameters

value
bool | strDefaults to True

One of:

  • "forever" — the model chains functions freely. This is the call’s default.
  • False — the model answers in words after every function result.
  • True — while chaining is off, allow one more chain: the next request after a function result can call a function, and then chaining is off again. True never lowers "forever".

Returns

FunctionResult — self, for chaining.

Raises

ValueError if value is not True, False, or "forever".

Example

from signalwire import AgentBase, FunctionResult
agent = AgentBase(name="orders", route="/orders")
agent.set_prompt_text("You help callers with their orders.")
@agent.tool(name="read_back_order", description="Read the order back to the caller")
def read_back_order(args, raw_data):
return (
FunctionResult("Read the order back and wait for the caller to confirm it.")
.back_to_back_functions(False)
)
agent.serve()

This result renders as:

{"response": "Read the order back and wait for the caller to confirm it.",
"action": [{"back_to_back_functions": false}]}