Skip to main content
0 reactions

Rasa Tutorial — Part 8: Tool Constraints: Make Your Agent Ask Before It Acts

Featured card for Rasa Tutorial Part 8, Tool Constraints: Make Your Agent Ask Before It Acts. Three ticked memory fields, branch, topic and day, unlock the book_appointment tool, the agent asks “Shall I book this appointment?”, the customer answers “Yes, please.”, with the notes Hidden until all three are set and Runs only after a yes.
Rasa Tutorial, Part 8: Tool Constraints.

Some tools must never run too early, or without the customer’s yes: booking an appointment, moving money, cancelling a card. In this part of the Rasa Tutorial, you add tool constraints to your Rasa Mantle agent: rules in a skill’s frontmatter that Rasa itself enforces, whatever Claude decides.

By the end, the banking agent from Part 7 won’t even be offered its booking tool until it knows the branch, the topic and the day, and Rasa will ask the customer to confirm, in your exact words, before any booking is made. You’ll watch the tool appear in the Rasa Inspector.

This is Part 8 of the Rasa Tutorial. The parts in Module C, Progressive Control:

All parts of the Rasa Tutorial

Module A: Start Here

Module B: Building Skills

Module C: Progressive Control

Module D: Orchestration

  • Part 12: The Runtime Loop: How Mantle Handles a Turn
  • Part 13: Guarantees and Guardrails
  • Part 14: Skills and Routing
  • Part 15: Context Management

Module E: Agent Setup

  • Part 16: agent.yml: Identity, Persona and Rules
  • Part 17: integrations.yml: Claude, Model Groups and Routing
  • Part 18: MCP Tools
  • Part 19: Hooks
  • Part 20: Build Faster with the Rasa Copilot

Module F: Voice

  • Part 21: Talk to Your Agent in the Browser
  • Part 22: Designing for Voice
  • Part 23: Connect a Phone Line
  • Part 24: Monitor Voice Calls

Module G: Channels

  • Part 25: The REST Channel and a Website Chat Widget
  • Part 26: Microsoft Teams

Module H: Observability

  • Part 27: Tracing with Langfuse
  • Part 28: Metrics and Conversation Events

Module I: Deploy

  • Part 29: Run Your Agent with Docker
  • Part 30: CI/CD for a Rasa Agent
  • Part 31: Deploy to Kubernetes with Rasa’s Helm Chart
  • Part 32: Deploy on AWS
  • Part 33: Deploy on Azure
  • Part 34: Deploy on Google Cloud

Module J: Rasa Studio

  • Part 35: Rasa Studio with a Mantle Agent

Module K: Wrap-up

  • Part 36: Final Project, Cheat Sheet and What to Learn Next

Cost: Rasa’s Developer Edition licence is free. Claude is pay-per-use: Claude Sonnet 5.5, the model this series uses, costs $2 per million input tokens and $10 per million output tokens (Claude pricing (opens in a new tab)). In this part you send six messages, which make nine calls to Claude: about $0.05. That’s an estimate: in Part 2, eight calls cost $0.05 on the Claude Console. Training also indexes Part 6’s reference document with Azure OpenAI again, which costs far less than a cent. The confirmation question and the other responses cost nothing: Rasa sends them without calling Claude.

Prerequisites

Step 1: Hide the Booking Tool Until Every Detail Is In

Open Terminal, go to your project folder and turn on its virtual environment:

TerminalBash
cd my-rasa-agent
source .venv/bin/activate

A tool constraint is a rule about one tool, written in the frontmatter of the skill that uses it. Claude still decides when to call the tool, but Rasa decides whether the call can happen. Use one wherever a tool changes something for real: a booking, a payment, a cancellation.

In Part 5, the booking tool checked by itself whether the branch, topic or day was missing. Now let Rasa hold it back until all three are in memory. Open skills/book_appointment/skill.md and add tool_constraints to the frontmatter, after description:

skills/book_appointment/skill.md (excerpt)YAML
tool_constraints:
  - book_appointment:
      requires: >
        session.book_appointment.branch
        and session.book_appointment.topic
        and session.book_appointment.day
  • tool_constraints lists the rules, one entry per tool, named exactly as the tool is: book_appointment.
  • requires is a condition. Until it’s true, Rasa leaves the tool out of what Claude is offered, and blocks any call to it. Claude can’t call a tool it isn’t offered.
  • session.book_appointment.branch on its own means “the skill’s branch field has a value”, as in Part 7. and joins the three, so all of them must have one.
  • > lets the condition run over several lines. YAML joins them into one.
  • If Rasa can’t work a condition out, it keeps the tool hidden: the safe way to fail.

Step 2: Make Rasa Ask Before the Tool Runs

Add requires_confirmation under the same tool, so the whole entry reads:

skills/book_appointment/skill.md (excerpt)YAML
tool_constraints:
  - book_appointment:
      requires: >
        session.book_appointment.branch
        and session.book_appointment.topic
        and session.book_appointment.day
      requires_confirmation:
        enabled: true
        utter_for_confirmation: utter_ask_book_appointment_confirmation
        utter_on_user_denial: utter_book_appointment_cancelled
  • enabled: true turns the pause on. When Claude calls the tool, Rasa holds the call, asks the customer, and runs the tool only if they agree.
  • utter_for_confirmation names the response Rasa asks with, and utter_on_user_denial the response it sends when the customer says no. Leave both out and Claude words them itself.

Add both responses to skills/book_appointment/responses.yml, under the confirmation from Part 7. Here’s the whole file now:

skills/book_appointment/responses.ymlYAML
responses:
  utter_book_appointment_confirmed:
    - text: >-
        Your appointment is booked. Your booking reference is
        {booking_reference}. Please bring a photo ID with you.

  utter_ask_book_appointment_confirmation:
    - text: >-
        Shall I book this appointment? Branch: {branch}. Topic: {topic}.
        Day: {day}.

  utter_book_appointment_cancelled:
    - text: No problem. I haven't booked anything.
  • {branch}, {topic} and {day} are filled in from the skill’s memory exactly as it holds them, so the topic and the day appear in lower case.
  • The question repeats the details, so the customer sees exactly what they’re agreeing to.

Advertisement

Step 3: Let Rasa Do the Asking

Your instructions from Part 5 still tell Claude to read the details back and ask for a yes. Now Rasa asks, so take that job out of them: if Claude asked too, the customer would confirm twice. Replace steps 2 and 3 with this one step:

skills/book_appointment/skill.md (excerpt)Plain text
2. When you have all three, book it with @tool.book_appointment.

Claude calls the tool as soon as it has the three details, and Rasa takes it from there.

Step 4: End the Skill When the Booking Is Made

Once the booking is made, the skill’s job is done. Say so in the frontmatter, after description:

skills/book_appointment/skill.md (excerpt)YAML
complete_when:
  condition: "session.book_appointment.booking_reference"
  • complete_when states what must be true before the skill can finish.
  • A condition on its own also ends the skill by itself the moment it becomes true: here, as soon as the tool saves the booking reference.
  • Rasa then moves straight on to your wrap-up question from Part 7, and Claude doesn’t get another turn to talk about a booking that’s already done.

Here’s the whole file now:

skills/book_appointment/skill.mdPlain text
---
name: Book an Appointment
description: Branch appointments - book a meeting with an adviser at one of our branches

complete_when:
  condition: "session.book_appointment.booking_reference"

tool_constraints:
  - book_appointment:
      requires: >
        session.book_appointment.branch
        and session.book_appointment.topic
        and session.book_appointment.day
      requires_confirmation:
        enabled: true
        utter_for_confirmation: utter_ask_book_appointment_confirmation
        utter_on_user_denial: utter_book_appointment_cancelled

utter:
  - utter_book_appointment_confirmed:
      when: "session.book_appointment.booking_reference"
---

Help the customer book an appointment with an adviser at a branch.

1. Find out which branch they want to visit, what the appointment is about
   and which day suits them. Ask for anything they haven't said, one question
   at a time. Record each answer with `set_memory` as soon as they give it.
2. When you have all three, book it with @tool.book_appointment.

Step 5: Train Your Agent

TerminalBash
rasa train

Rasa checks your constraints while it trains, including the response names they use. When it finishes, the last line names your new agent package:

Output (the line that matters)Plain text
2026-11-21 17:32:15 INFO     rasa.mantle.model_archive.snapshot  - [info     ] Mantle agent package saved at 'models/20261121-173214-diachronic-deck.tar.gz'.

The INFO notes above it are the same as in Part 7; they aren’t errors.

Step 6: Book an Appointment

TerminalBash
rasa inspect

When the Rasa Inspector opens in your browser, send I would like to book an appointment with an adviser. Claude asks which branch. Reply Riverton Station, please. It's about a loan, and Tuesday suits me. Rasa asks your confirmation question. Reply Yes, please.

A conversation in the Rasa Inspector: the customer asks to book an appointment with an adviser, the agent asks which branch, the customer answers Riverton Station, a loan and Tuesday, the agent asks the exact question “Shall I book this appointment? Branch: Riverton Station. Topic: loan. Day: tuesday.”, the customer replies “Yes, please.”, and the agent confirms the booking with reference APT-8096 and asks whether it can help with anything else.
Rasa asks your question before the booking runs, then sends your confirmation.

The question is your response, word for word, with the details from memory. Only after your yes does the booking run; then your confirmation from Part 7 and your wrap-up question follow. Yours will show a different reference: the demo tool makes up a new one for each booking.

Now see the constraint at work. Click the Inspector mode button at the top of the chat and choose Inspect. Then click the LLM call just above Happy to help. Which branch would you like to visit? Its panel lists, under Tools, everything Rasa offered Claude for that call:

The LLM call panel in the Rasa Inspector for the call that asked which branch: model claude-sonnet-5-5, 932 ms, and a Tools list of activate, search_knowledge, listen, complete, cancel and set_memory, with book_appointment greyed out.
Before the details are in memory, book_appointment is greyed out: not offered to Claude.

book_appointment is greyed out: its condition wasn’t met yet, so Claude couldn’t book. Now click the LLM call just above Tool call: book_appointment:

The LLM call panel in the Rasa Inspector for the call after the customer gave the branch, topic and day: model claude-sonnet-5-5, 2.7 s, and a Tools list of activate, search_knowledge, listen, complete, cancel and correct, with book_appointment highlighted in purple.
With all three details in memory, Rasa offers book_appointment, and Claude calls it.

Once memory held all three details, Rasa offered the tool, and Claude called it: purple marks the tool Claude chose. Scroll down the chat to see what happened next:

Inspect mode in the Rasa Inspector: an LLM call and Tool call: book_appointment, the question marked utter_ask_book_appointment_confirmation template, Agent turn ended, the customer’s “Yes, please.”, an LLM call with Tool call: book_appointment and Tool call: resolve_tool_confirmation, the booking confirmation marked utter_book_appointment_confirmed template, Book an Appointment skill completed, the Completed skill, and the wrap-up question marked utter_ask_wants_to_continue template.
Rasa holds the booking, asks, and runs it after the customer agrees.
  • Right after Tool call: book_appointment comes your question, marked utter_ask_book_appointment_confirmation template, and the turn ends: Rasa held the call and waited for the customer.
  • After Yes, please., one LLM call records the answer (Tool call: resolve_tool_confirmation), and only then does the booking run.
  • Book an Appointment skill completed follows the confirmation with no LLM call in between: your complete_when condition ended the skill.

Now turn a booking down. Choose Preview from the Inspector mode menu, click the circular arrow (Restart conversation) at the top of the chat, and send Please book me an appointment at Lakeside about a card on Friday. Reply No, don't book it. to the question, then That is all, thanks.

A conversation in the Rasa Inspector: the customer asks to book an appointment at Lakeside about a card on Friday, the agent asks “Shall I book this appointment? Branch: Lakeside. Topic: card. Day: friday.”, the customer replies “No, don’t book it.”, the agent answers “No problem. I haven’t booked anything.”, the customer says “That is all, thanks.”, and the agent asks whether it can help with anything else.
On a no, Rasa sends your cancel line and books nothing.

Rasa sent your cancel line and booked nothing. When you said you were done, Claude ended the booking task, and your wrap-up question followed.

When you’re done, go back to Terminal and press Ctrl+C to stop the agent.

Clean Up

If the agent is still running, press Ctrl+C in Terminal to stop it. Claude and Azure OpenAI both charge only for what your agent uses, so a stopped agent costs nothing.

Keep the my-rasa-agent folder: Part 9 builds on it.

Common Mistakes

MistakeDo this instead
Naming the tool differently in tool_constraints than in tools.pyUse the tool’s exact name, book_appointment.
Writing only the field’s name in a condition, such as branchWrite the full form: session, the skill’s folder name and the field, as in session.book_appointment.branch.
Leaving the “read the details back and ask” step in the instructionsRemove it when requires_confirmation is on, or the customer confirms twice.
Asking for confirmation on tools that only look things upKeep confirmation for tools that change something, such as a booking or a payment. Finding a branch needs no yes.
Putting a condition with : in it on one line without quotesQuote it, or fold it over several lines with > as in Step 1.

Troubleshooting

ProblemFix
Claude never books, even with all three detailsThe condition never became true. Check each field’s name against memory.yml and the skill folder’s name, then train again and restart rasa inspect. In Inspect mode, a greyed tool in an LLM call’s Tools list means its condition wasn’t met.
The customer is asked to confirm twiceRemove the confirmation step from the instructions, as in Step 3.
Claude adds its own message after the booking confirmationAdd complete_when from Step 4, so the skill ends as soon as the booking reference is saved.
rasa train stops with an error about a response nameThe names in utter_for_confirmation and utter_on_user_denial must match responses.yml exactly.

FAQ

Does Claude still decide when to book?

Yes. Claude still asks for the details in its own words and chooses when to call the tool. The constraint decides only whether the tool is there to call, and whether it runs before the customer agrees.

What if the customer changes the subject instead of answering?

The question stays open. Rasa’s Tool Constraints (opens in a new tab) guide says it’s asked again when the conversation comes back to the booking.

Can the customer answer with Yes and No buttons?

Rasa lets you put two buttons on the confirmation question, with the payloads set:session.system.confirmation=true and =false, so a tap answers without a call to Claude. In Rasa Pro 3.22, though, Claude never sees the tap, so it can contradict the booking or ask again later; Fixed: Rasa Mantle Says “I haven’t booked it yet” After the Customer Taps Yes shows what happens and how to fix it. With typed answers, as in this part, Claude records the answer itself.

Can a tool constraint send a message after the tool runs?

Yes: on_success names a response sent after the tool succeeds, and on_failure one sent after it fails. Your utter trigger from Part 7 already sends the booking confirmation, so this part doesn’t need them.

Conclusion

You added tool constraints: requires keeps the booking tool away from Claude until memory holds every detail, requires_confirmation makes Rasa ask the customer in your words before the tool runs, and complete_when ends the skill once the booking is made. Claude still runs the conversation, but the booking can no longer happen too early or without a yes.

← Previous: Part 7: Responses: Control the Exact Wording

Next → Part 9: Scoped Instructions: Show Claude Only the Rules That Apply

Additional Resources

Rasa, Claude, Azure and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by Rasa Technologies, Anthropic or Microsoft.

0 comments