Tool rejection plan
Prevent unintended tool calls using conditions based on conversation state
Overview
A rejection plan lets you prevent a tool from executing when certain conditions are met. You attach it to any tool call and it evaluates the recent conversation state to decide whether to reject the call.
- If all conditions match (AND logic), the tool call is rejected.
- To express OR at the top level, use a single group condition with
operator: "OR". - If
conditionsis empty or omitted, the tool always executes.
Use on any tool call, e.g., Assistant.hooks.do[type=tool].tool.rejectionPlan.
Schema
- conditions: Array of condition objects. Defaults to
[].- Types:
- RegexCondition: Match message content with a regex
type: “regex”regex: String pattern. RegExp.test-style substring matching. Escape backslashes in JSON (e.g.,"\\bhello\\b"). Supports inline flags like(?i)for case-insensitive.target(optional): Which message to inspectrole:user|assistantposition: Integer index in history (default-1for the most recent). Negative counts from the end;0is the first message
negate(optional): Whentrue, the condition matches if the regex does NOT match (defaultfalse)
- LiquidCondition: Evaluate a Liquid template that must output exactly
"true"or"false"type: “liquid”liquid: The template. You can accessmessages(recent chat messages),now, and assistant variables. Useful filters includelast,where, andreverse
- GroupCondition: Combine multiple conditions
type: “group”operator:AND|ORconditions: Nested list of conditions (can recursively nest groups)
- RegexCondition: Match message content with a regex
- Types:
Examples
1) Reject endCall unless the user says goodbye
2) Reject transfer if the user is actually asking a question
3) Reject transfer if the user hasn’t mentioned transfer recently (Liquid)
Liquid template for readability:
Wired into a rejection plan:
4) Top-level OR using a group
Normal tool call example
Attach rejectionPlan directly on a tool in your assistant configuration (model.tools):
Another example: transferCall with rejection
Tips
- Escape backslashes in regex patterns: write
\\bin JSON to mean\bin the regex engine. position: -1targets the most recent message. Omitroleto target regardless of role.- Prefer a
groupwithoperator: "OR"for disjunctive logic at the top level.