Skip to navigation
AgentsPatterns

Proposal

View as MarkdownOpen in Claude

Proposal reads a change back to the caller and gates the tool that carries it out on the caller’s yes. It takes two tools:

  • A proposing tool returns propose(). The change is recorded in global_data.semantic_state, and the agent says the read-back word for word, then waits for the caller.
  • The confirm tool gets the three semantic gates from confirm_gates(), judged on the proposal’s dialogue. It runs only when the caller answered, the answer is a yes, and what they answered was a read-back of this change. Its handler returns complete().

When a gate fails, the model is told why, with the proposal quoted, and tool chaining is turned off with back_to_back_functions(False) so the model answers in words. Because that setting lasts for the call, propose(), ask_again(), and complete() turn chaining back on with back_to_back_functions("forever"). An agent that sets back_to_back_functions itself should allow for this.

from signalwire.patterns import Proposal

Parameters

confirm_tool
strRequired

The name of the tool that carries out the change.

decline_tool
str | NoneDefaults to None

Keyword-only. The tool that a no or a requested change goes to. It’s named in what the model is told when the caller doesn’t say yes.

threshold
floatDefaults to 0.8

Keyword-only. Each gate’s threshold. A yes/no gate wants about 0.8; with unclear, about 0.6.

unclear
boolDefaults to False

Keyword-only. True lets the gates answer unclear as well, which asks the caller again. See unclear on SemanticGate.

Methods

To read the proposal a request carries, use current().

Example

from signalwire import AgentBase
from signalwire.patterns import Proposal
agent = AgentBase(name="tea", route="/tea")
agent.prompt_add_section("Role", "You take tea orders.")
order = Proposal("place_order", decline_tool="review_order")
def review_order(args, raw_data):
return order.propose(f"That's a {args['item']}. Is that right?",
raw_data=raw_data, details={"item": args["item"]})
def place_order(args, raw_data):
return order.complete("Order 4471 is placed")
agent.define_tool("review_order", "Read the order back",
{"type": "object", "properties": {"item": {"type": "string"}}, "required": ["item"]},
review_order)
agent.define_tool("place_order", "Place the order the caller said yes to",
{"type": "object", "properties": {}}, place_order,
gates=order.confirm_gates())
agent.serve()

The gates judge the proposal’s dialogue on their own, so the agent doesn’t need set_semantic_gates(dialogue="proposal") for them.