Skip to navigation
AgentsAgentBase

set_semantic_gates

View as MarkdownOpen in Claude

Set how the call checks the semantic gates on its SWAIG functions. Each argument sets one AI parameter. An argument left as None leaves that setting as it is, and the platform default applies to a setting that was never set.

Parameters

enabled
bool | NoneDefaults to None

False runs gated functions without checking their gates. Sets semantic_gates_enabled; the platform default is True.

timeout_ms
int | NoneDefaults to None

How long one gate check may take, from 500 to 10000 milliseconds. A check that runs out of time blocks the function. Sets semantic_gate_timeout_ms; the platform default is 2500.

history
int | NoneDefaults to None

How many recent conversation entries the decision model reads, from 0 to 100. Sets semantic_gate_history; the platform default is 20.

dialogue
str | NoneDefaults to None

Which dialogue the decision model judges. Sets semantic_gate_dialogue; the platform default is "window".

  • "window" — the newest history entries.
  • "proposal" — the entries since global_data.semantic_state last changed (see set_semantic_state()), from the agent’s first turn after the change: the read-back and the caller’s reply. With no semantic_state set, the window is used.

A gate’s own dialogue, history, and since take the place of these settings for its function.

Raises ValueError when a value has the wrong type or is out of range. Values are checked in the order enabled, dialogue, timeout_ms, history, and values checked before the one that raised stay set.

Returns

AgentBase — Returns self for method chaining.

Examples

from signalwire import AgentBase
agent = AgentBase(name="account-agent", route="/account")
agent.set_prompt_text("You help callers manage their account.")
agent.set_semantic_gates(timeout_ms=4000, history=40)
agent.serve()

Judge confirmations on the proposal’s dialogue:

from signalwire import AgentBase
agent = AgentBase(name="account-agent", route="/account")
agent.set_prompt_text("You help callers manage their account.")
agent.set_semantic_gates(dialogue="proposal", history=30)
agent.serve()

This renders "params": {"semantic_gate_dialogue": "proposal", "semantic_gate_history": 30}.