Agent Script Pattern: Enforce Business Rules with Filters

Use available when to control which topics or actions are available to the LLM. If the conditions aren't met, the LLM can't access the topic or reasoning action (also described as a tool in the developer guide).

When your business conditions aren't met, this pattern allows you to hide the topic or action entirely, simplifying the LLM's decision-making and enforcing business rules about feature availability. Without filtering, customers might convince the LLM to use features that aren't allowed. Or, the LLM might make reasoning errors during complex workflows and prolonged conversations, due to prompt noise and context drift. See Required Topic Workflow for a related pattern.

Pattern Examples:

  • Only enable the create_return action when the order is within the return window and verified—otherwise, hide it completely from the agent.
  • Only enable the escalate topic for verified customers during business hours.

Control which topics are available based on whether the user is verified.

In this example:

  • All users can access General Info.
  • Verified users can be routed to the Order Management.
  • Escalation requires verification and valid business hours.

Make actions available only when business rules are satisfied.

Keep in mind that the LLM can call any available reasoning action, even if you don’t explicitly tell it to.

  • Keep filter logic simple: Use clear conditions rather than complex nested logic.
  • Protect against customer manipulation: Filter business-sensitive features. Don't only rely on prompt engineering.