rasa-pro 3.14.0.dev10__py3-none-any.whl → 3.14.0.dev11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

Files changed (291) hide show
  1. rasa/__main__.py +15 -3
  2. rasa/agents/agent_manager.py +50 -2
  3. rasa/agents/constants.py +3 -0
  4. rasa/agents/core/types.py +11 -0
  5. rasa/agents/protocol/a2a/a2a_agent.py +45 -5
  6. rasa/agents/protocol/mcp/mcp_base_agent.py +14 -5
  7. rasa/agents/protocol/mcp/mcp_open_agent.py +27 -13
  8. rasa/agents/protocol/mcp/mcp_task_agent.py +42 -31
  9. rasa/agents/schemas/agent_tool_result.py +0 -2
  10. rasa/agents/schemas/agent_tool_schema.py +55 -3
  11. rasa/agents/templates/mcp_open_agent_prompt_template.jinja2 +6 -6
  12. rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +5 -5
  13. rasa/agents/utils.py +42 -3
  14. rasa/builder/copilot/telemetry.py +35 -19
  15. rasa/builder/main.py +5 -14
  16. rasa/builder/project_generator.py +1 -1
  17. rasa/builder/service.py +5 -0
  18. rasa/builder/template_cache.py +9 -184
  19. rasa/cli/project_templates/basic/data/data.md +5 -6
  20. rasa/cli/project_templates/basic/domain/domain.md +5 -2
  21. rasa/cli/project_templates/finance/README.md +8 -7
  22. rasa/cli/project_templates/finance/actions/__init__.py +0 -46
  23. rasa/cli/project_templates/finance/actions/accounts/check_balance.py +18 -0
  24. rasa/cli/project_templates/finance/actions/{transfers/action_process_immediate_payment.py → cards/check_that_card_exists.py} +6 -3
  25. rasa/cli/project_templates/finance/actions/cards/list_cards.py +22 -0
  26. rasa/cli/project_templates/finance/actions/contacts/__init__.py +0 -0
  27. rasa/cli/project_templates/finance/actions/contacts/add_contact.py +30 -0
  28. rasa/cli/project_templates/finance/actions/contacts/list_contacts.py +22 -0
  29. rasa/cli/project_templates/finance/actions/contacts/remove_contact.py +35 -0
  30. rasa/cli/project_templates/finance/actions/db.py +117 -0
  31. rasa/cli/project_templates/finance/actions/transfers/check_transfer_funds.py +27 -0
  32. rasa/cli/project_templates/finance/actions/transfers/check_transfer_limit.py +36 -0
  33. rasa/cli/project_templates/finance/actions/transfers/execute_recurrent_payment.py +20 -0
  34. rasa/cli/project_templates/finance/actions/transfers/execute_transfer.py +45 -0
  35. rasa/cli/project_templates/finance/actions/transfers/list_transactions.py +32 -0
  36. rasa/cli/project_templates/finance/config.yml +6 -0
  37. rasa/cli/project_templates/finance/credentials.yml +7 -6
  38. rasa/cli/project_templates/finance/data/accounts/check_balance.yml +3 -4
  39. rasa/cli/project_templates/finance/data/accounts/download_statements.yml +26 -0
  40. rasa/cli/project_templates/finance/data/bills/bill_pay_reminder.yml +25 -0
  41. rasa/cli/project_templates/finance/data/cards/activate_card.yml +35 -0
  42. rasa/cli/project_templates/finance/data/cards/block_card.yml +37 -58
  43. rasa/cli/project_templates/finance/data/cards/list_cards.yml +14 -0
  44. rasa/cli/project_templates/finance/data/cards/replace_card.yml +16 -0
  45. rasa/cli/project_templates/finance/data/cards/replace_eligible_card.yml +29 -0
  46. rasa/cli/project_templates/finance/data/contacts/add_contact.yml +33 -0
  47. rasa/cli/project_templates/finance/data/contacts/list_contacts.yml +14 -0
  48. rasa/cli/project_templates/finance/data/contacts/remove_contact.yml +31 -0
  49. rasa/cli/project_templates/finance/data/data.md +6 -3
  50. rasa/cli/project_templates/finance/data/general/agent_details.yml +6 -0
  51. rasa/cli/project_templates/finance/data/general/hello.yml +1 -2
  52. rasa/cli/project_templates/finance/data/general/human_handoff.yml +1 -1
  53. rasa/cli/project_templates/finance/data/transfers/check_transfer_limit.yml +18 -0
  54. rasa/cli/project_templates/finance/data/transfers/list_transactions.yml +46 -0
  55. rasa/cli/project_templates/finance/data/transfers/move_money_between_accounts.yml +51 -0
  56. rasa/cli/project_templates/finance/data/transfers/transfer_money.yml +29 -62
  57. rasa/cli/project_templates/finance/data/transfers/transfer_money_to_a_third_party.yml +175 -0
  58. rasa/cli/project_templates/finance/db/cards.json +18 -0
  59. rasa/cli/project_templates/finance/db/contacts.json +10 -0
  60. rasa/cli/project_templates/finance/db/my_account.json +6 -0
  61. rasa/cli/project_templates/finance/db/transactions.json +22 -0
  62. rasa/cli/project_templates/finance/docs/docs.md +8 -0
  63. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/account_features/budgeting_analytics.txt +22 -0
  64. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/account_features/multi_currency_accounts.txt +19 -0
  65. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/account_features/premium_benefits.txt +19 -0
  66. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/card_management/contactless_limits.txt +16 -0
  67. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/card_management/freeze_unfreeze_card.txt +16 -0
  68. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/card_management/lost_stolen_card.txt +19 -0
  69. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/money_transfers/instant_payments.txt +19 -0
  70. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/money_transfers/international_transfers.txt +19 -0
  71. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/security_fraud/fraud_protection.txt +22 -0
  72. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/security_fraud/secure_payments.txt +22 -0
  73. rasa/cli/project_templates/finance/domain/_system/patterns/pattern_session_start.yml +11 -0
  74. rasa/cli/project_templates/finance/domain/accounts/check_balance.yml +9 -5
  75. rasa/cli/project_templates/finance/domain/accounts/download_statements.yml +40 -0
  76. rasa/cli/project_templates/finance/domain/bills/bill_pay_reminder.yml +49 -0
  77. rasa/cli/project_templates/finance/domain/cards/activate_card.yml +24 -0
  78. rasa/cli/project_templates/finance/domain/cards/block_card.yml +33 -90
  79. rasa/cli/project_templates/finance/domain/cards/list_cards.yml +16 -0
  80. rasa/cli/project_templates/finance/domain/cards/replace_card.yml +43 -0
  81. rasa/cli/project_templates/finance/domain/cards/shared.yml +15 -0
  82. rasa/cli/project_templates/finance/domain/contacts/add_contact.yml +37 -0
  83. rasa/cli/project_templates/finance/domain/contacts/list_contacts.yml +16 -0
  84. rasa/cli/project_templates/finance/domain/contacts/remove_contact.yml +32 -0
  85. rasa/cli/project_templates/finance/domain/domain.md +9 -1
  86. rasa/cli/project_templates/finance/domain/general/_shared.yml +53 -0
  87. rasa/cli/project_templates/finance/domain/general/agent_details.yml +19 -0
  88. rasa/cli/project_templates/finance/domain/general/cannot_handle.yml +5 -2
  89. rasa/cli/project_templates/finance/domain/general/feedback.yml +0 -3
  90. rasa/cli/project_templates/finance/domain/general/human_handoff.yml +7 -3
  91. rasa/cli/project_templates/finance/domain/general/welcome.yml +5 -2
  92. rasa/cli/project_templates/finance/domain/transfers/check_transfer_limit.yml +32 -0
  93. rasa/cli/project_templates/finance/domain/transfers/list_transactions.yml +44 -0
  94. rasa/cli/project_templates/finance/domain/transfers/shared.yml +17 -0
  95. rasa/cli/project_templates/finance/domain/transfers/transfer_money.yml +203 -61
  96. rasa/cli/project_templates/finance/endpoints.yml +3 -2
  97. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +31 -12
  98. rasa/cli/project_templates/telco/data/data.md +1 -1
  99. rasa/cli/project_templates/telco/docs/docs.md +3 -0
  100. rasa/cli/project_templates/telco/domain/domain.md +1 -2
  101. rasa/constants.py +1 -1
  102. rasa/core/actions/direct_custom_actions_executor.py +9 -2
  103. rasa/core/agent.py +2 -3
  104. rasa/core/available_agents.py +1 -1
  105. rasa/core/brokers/broker.py +1 -1
  106. rasa/core/brokers/kafka.py +52 -8
  107. rasa/core/channels/__init__.py +82 -35
  108. rasa/core/channels/inspector/README.md +1 -1
  109. rasa/core/channels/telegram.py +4 -9
  110. rasa/core/channels/voice_stream/twilio_media_streams.py +5 -1
  111. rasa/core/concurrent_lock_store.py +66 -16
  112. rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +76 -1
  113. rasa/core/iam_credentials_providers/credentials_provider_protocol.py +1 -1
  114. rasa/core/lock_store.py +41 -7
  115. rasa/core/policies/flows/agent_executor.py +632 -0
  116. rasa/core/policies/flows/flow_executor.py +3 -417
  117. rasa/core/policies/flows/mcp_tool_executor.py +32 -12
  118. rasa/core/processor.py +49 -28
  119. rasa/core/run.py +22 -0
  120. rasa/dialogue_understanding/commands/cancel_flow_command.py +1 -1
  121. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +11 -3
  122. rasa/dialogue_understanding/commands/clarify_command.py +11 -3
  123. rasa/dialogue_understanding/commands/knowledge_answer_command.py +11 -3
  124. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +3 -3
  125. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +3 -3
  126. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +3 -3
  127. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +3 -3
  128. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +2 -0
  129. rasa/dialogue_understanding/processor/command_processor.py +70 -0
  130. rasa/dialogue_understanding/stack/dialogue_stack.py +0 -25
  131. rasa/engine/loader.py +12 -0
  132. rasa/engine/recipes/default_components.py +111 -82
  133. rasa/engine/recipes/default_recipe.py +79 -22
  134. rasa/engine/runner/dask.py +8 -5
  135. rasa/graph_components/validators/default_recipe_validator.py +59 -19
  136. rasa/model_manager/warm_rasa_process.py +13 -3
  137. rasa/model_training.py +0 -14
  138. rasa/nlu/classifiers/logistic_regression_classifier.py +1 -22
  139. rasa/nlu/classifiers/mitie_intent_classifier.py +3 -0
  140. rasa/nlu/classifiers/sklearn_intent_classifier.py +1 -3
  141. rasa/nlu/extractors/crf_entity_extractor.py +9 -10
  142. rasa/nlu/extractors/mitie_entity_extractor.py +3 -0
  143. rasa/nlu/extractors/spacy_entity_extractor.py +3 -0
  144. rasa/nlu/featurizers/dense_featurizer/mitie_featurizer.py +2 -0
  145. rasa/nlu/featurizers/dense_featurizer/spacy_featurizer.py +3 -0
  146. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +4 -2
  147. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +4 -0
  148. rasa/nlu/tokenizers/jieba_tokenizer.py +3 -4
  149. rasa/nlu/tokenizers/mitie_tokenizer.py +3 -2
  150. rasa/nlu/tokenizers/spacy_tokenizer.py +3 -2
  151. rasa/nlu/utils/mitie_utils.py +3 -0
  152. rasa/nlu/utils/spacy_utils.py +3 -2
  153. rasa/telemetry.py +63 -0
  154. rasa/utils/log_utils.py +95 -4
  155. rasa/utils/tensorflow/__init__.py +0 -22
  156. rasa/utils/tensorflow/callback.py +17 -7
  157. rasa/utils/tensorflow/layers.py +10 -7
  158. rasa/utils/tensorflow/rasa_layers.py +1 -1
  159. rasa/version.py +1 -1
  160. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/METADATA +99 -89
  161. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/RECORD +164 -235
  162. rasa/cli/project_templates/finance/actions/accounts/action_ask_account.py +0 -47
  163. rasa/cli/project_templates/finance/actions/accounts/action_check_balance.py +0 -40
  164. rasa/cli/project_templates/finance/actions/action_session_start.py +0 -74
  165. rasa/cli/project_templates/finance/actions/cards/action_ask_card.py +0 -48
  166. rasa/cli/project_templates/finance/actions/cards/action_check_card_existence.py +0 -36
  167. rasa/cli/project_templates/finance/actions/cards/action_update_card_status.py +0 -54
  168. rasa/cli/project_templates/finance/actions/database.py +0 -277
  169. rasa/cli/project_templates/finance/actions/transfers/action_add_payee.py +0 -52
  170. rasa/cli/project_templates/finance/actions/transfers/action_ask_account_from.py +0 -51
  171. rasa/cli/project_templates/finance/actions/transfers/action_check_payee_existence.py +0 -40
  172. rasa/cli/project_templates/finance/actions/transfers/action_check_sufficient_funds.py +0 -40
  173. rasa/cli/project_templates/finance/actions/transfers/action_list_payees.py +0 -46
  174. rasa/cli/project_templates/finance/actions/transfers/action_remove_payee.py +0 -49
  175. rasa/cli/project_templates/finance/actions/transfers/action_schedule_payment.py +0 -19
  176. rasa/cli/project_templates/finance/actions/transfers/action_validate_payment_date.py +0 -36
  177. rasa/cli/project_templates/finance/csvs/accounts.csv +0 -8
  178. rasa/cli/project_templates/finance/csvs/advisors.csv +0 -7
  179. rasa/cli/project_templates/finance/csvs/appointments.csv +0 -211
  180. rasa/cli/project_templates/finance/csvs/branches.csv +0 -10
  181. rasa/cli/project_templates/finance/csvs/cards.csv +0 -11
  182. rasa/cli/project_templates/finance/csvs/payees.csv +0 -11
  183. rasa/cli/project_templates/finance/csvs/transactions.csv +0 -71
  184. rasa/cli/project_templates/finance/csvs/users.csv +0 -4
  185. rasa/cli/project_templates/finance/data/cards/select_card.yml +0 -12
  186. rasa/cli/project_templates/finance/data/general/bot_identity.yml +0 -6
  187. rasa/cli/project_templates/finance/data/system/patterns/pattern_chitchat.yml +0 -5
  188. rasa/cli/project_templates/finance/data/system/source/accounts.json +0 -51
  189. rasa/cli/project_templates/finance/data/system/source/advisors.json +0 -44
  190. rasa/cli/project_templates/finance/data/system/source/appointments.json +0 -1474
  191. rasa/cli/project_templates/finance/data/system/source/branches.json +0 -47
  192. rasa/cli/project_templates/finance/data/system/source/cards.json +0 -72
  193. rasa/cli/project_templates/finance/data/system/source/payees.json +0 -74
  194. rasa/cli/project_templates/finance/data/system/source/transactions.json +0 -492
  195. rasa/cli/project_templates/finance/data/system/source/users.json +0 -29
  196. rasa/cli/project_templates/finance/data/transfers/add_payee.yml +0 -29
  197. rasa/cli/project_templates/finance/data/transfers/list_payees.yml +0 -5
  198. rasa/cli/project_templates/finance/data/transfers/remove_payee.yml +0 -21
  199. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +0 -8
  200. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +0 -8
  201. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +0 -8
  202. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +0 -8
  203. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +0 -8
  204. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +0 -7
  205. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +0 -8
  206. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +0 -8
  207. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +0 -8
  208. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +0 -8
  209. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +0 -8
  210. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +0 -8
  211. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +0 -8
  212. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +0 -8
  213. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +0 -8
  214. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +0 -8
  215. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +0 -8
  216. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +0 -8
  217. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +0 -8
  218. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +0 -8
  219. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +0 -50
  220. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +0 -50
  221. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +0 -48
  222. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +0 -50
  223. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +0 -50
  224. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +0 -47
  225. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +0 -50
  226. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +0 -50
  227. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +0 -47
  228. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +0 -50
  229. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +0 -50
  230. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +0 -50
  231. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +0 -47
  232. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +0 -50
  233. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +0 -50
  234. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +0 -47
  235. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +0 -50
  236. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +0 -50
  237. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +0 -47
  238. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +0 -50
  239. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +0 -50
  240. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +0 -47
  241. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +0 -47
  242. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +0 -50
  243. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +0 -50
  244. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +0 -47
  245. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +0 -50
  246. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +0 -50
  247. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +0 -47
  248. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +0 -50
  249. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +0 -50
  250. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +0 -47
  251. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +0 -50
  252. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +0 -50
  253. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +0 -50
  254. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +0 -47
  255. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +0 -50
  256. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +0 -50
  257. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +0 -47
  258. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +0 -50
  259. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +0 -50
  260. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +0 -47
  261. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +0 -50
  262. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +0 -50
  263. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +0 -50
  264. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +0 -47
  265. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +0 -50
  266. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +0 -50
  267. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +0 -47
  268. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +0 -50
  269. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +0 -50
  270. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +0 -47
  271. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +0 -50
  272. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +0 -50
  273. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +0 -47
  274. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +0 -47
  275. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +0 -50
  276. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +0 -50
  277. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +0 -50
  278. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +0 -50
  279. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +0 -47
  280. rasa/cli/project_templates/finance/domain/cards/select_card.yml +0 -12
  281. rasa/cli/project_templates/finance/domain/general/bot_identity.yml +0 -5
  282. rasa/cli/project_templates/finance/domain/general/defaults.yml +0 -24
  283. rasa/cli/project_templates/finance/domain/general/goodbye.yml +0 -7
  284. rasa/cli/project_templates/finance/domain/general/help.yml +0 -5
  285. rasa/cli/project_templates/finance/domain/general/utils.yml +0 -13
  286. rasa/cli/project_templates/finance/domain/transfers/add_payee.yml +0 -47
  287. rasa/cli/project_templates/finance/domain/transfers/list_payees.yml +0 -4
  288. rasa/cli/project_templates/finance/domain/transfers/remove_payee.yml +0 -16
  289. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/NOTICE +0 -0
  290. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/WHEEL +0 -0
  291. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/entry_points.txt +0 -0
@@ -1,27 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
- import asyncio
4
- from typing import Any, Dict, List, Optional, Text, cast
3
+ from typing import Any, Dict, List, Optional, Text
5
4
 
6
5
  import structlog
7
6
  from jinja2 import Template
8
7
  from pypred import Predicate
9
8
  from structlog.contextvars import bound_contextvars
10
9
 
11
- from rasa.agents.agent_manager import AgentManager
12
- from rasa.agents.constants import (
13
- A2A_AGENT_CONTEXT_ID_KEY,
14
- AGENT_METADATA_AGENT_RESPONSE_KEY,
15
- AGENT_METADATA_EXIT_IF_KEY,
16
- AGENT_METADATA_STRUCTURED_RESULTS_KEY,
17
- MAX_AGENT_RETRY_DELAY_SECONDS,
18
- )
19
- from rasa.agents.core.types import AgentStatus, ProtocolType
20
- from rasa.agents.schemas import AgentInput, AgentOutput
21
- from rasa.agents.schemas.agent_input import AgentInputSlot
22
- from rasa.core.available_agents import AvailableAgents
23
10
  from rasa.core.available_endpoints import AvailableEndpoints
24
11
  from rasa.core.constants import ACTIVE_FLOW_METADATA_KEY, STEP_ID_METADATA_KEY
12
+ from rasa.core.policies.flows.agent_executor import run_agent
25
13
  from rasa.core.policies.flows.flow_exceptions import (
26
14
  FlowCircuitBreakerTrippedException,
27
15
  FlowException,
@@ -34,7 +22,6 @@ from rasa.core.policies.flows.flow_step_result import (
34
22
  PauseFlowReturnPrediction,
35
23
  )
36
24
  from rasa.core.policies.flows.mcp_tool_executor import call_mcp_tool
37
- from rasa.core.utils import get_slot_names_from_exit_conditions
38
25
  from rasa.dialogue_understanding.patterns.cancel import CancelPatternFlowStackFrame
39
26
  from rasa.dialogue_understanding.patterns.collect_information import (
40
27
  FLOW_PATTERN_COLLECT_INFORMATION,
@@ -62,29 +49,18 @@ from rasa.dialogue_understanding.stack.frames import (
62
49
  )
63
50
  from rasa.dialogue_understanding.stack.frames.flow_stack_frame import (
64
51
  AgentStackFrame,
65
- AgentState,
66
52
  FlowStackFrameType,
67
53
  )
68
54
  from rasa.dialogue_understanding.stack.utils import (
69
55
  user_frames_on_the_stack,
70
56
  )
71
57
  from rasa.dialogue_understanding.utils import assemble_options_string
72
- from rasa.shared.agents.utils import get_protocol_type
73
58
  from rasa.shared.constants import RASA_PATTERN_HUMAN_HANDOFF
74
59
  from rasa.shared.core.constants import (
75
- ACTION_AGENT_REQUEST_USER_INPUT_NAME,
76
60
  ACTION_LISTEN_NAME,
77
- ACTION_METADATA_MESSAGE_KEY,
78
- ACTION_METADATA_TEXT_KEY,
79
- ACTION_SEND_TEXT_NAME,
80
61
  SILENCE_TIMEOUT_SLOT,
81
- SLOTS_EXCLUDED_FOR_AGENT,
82
62
  )
83
63
  from rasa.shared.core.events import (
84
- AgentCancelled,
85
- AgentCompleted,
86
- AgentResumed,
87
- AgentStarted,
88
64
  Event,
89
65
  FlowCompleted,
90
66
  FlowResumed,
@@ -109,18 +85,13 @@ from rasa.shared.core.flows.steps import (
109
85
  SetSlotsFlowStep,
110
86
  )
111
87
  from rasa.shared.core.flows.steps.constants import START_STEP
112
- from rasa.shared.core.slots import CategoricalSlot, Slot, SlotRejection
88
+ from rasa.shared.core.slots import Slot, SlotRejection
113
89
  from rasa.shared.core.trackers import DialogueStateTracker
114
- from rasa.shared.utils.llm import tracker_as_readable_transcript
115
90
 
116
91
  structlogger = structlog.get_logger()
117
92
 
118
93
  MAX_NUMBER_OF_STEPS = 250
119
94
 
120
- MAX_AGENT_RETRIES = 3
121
-
122
- # Slots that should not be forwarded to sub-agents via AgentInput
123
-
124
95
 
125
96
  def render_template_variables(text: str, context: Dict[Text, Any]) -> str:
126
97
  """Replace context variables in a text."""
@@ -908,388 +879,3 @@ def _append_global_silence_timeout_event(
908
879
  AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout,
909
880
  )
910
881
  )
911
-
912
-
913
- def _reset_slots_covered_by_exit_if(
914
- exit_conditions: List[str], tracker: DialogueStateTracker
915
- ) -> None:
916
- """Reset the slots covered by the exit_if condition."""
917
- reset_slot_names = get_slot_names_from_exit_conditions(exit_conditions)
918
- for slot_name in reset_slot_names:
919
- if tracker.slots.get(slot_name) is not None:
920
- tracker.update(SlotSet(slot_name, None))
921
-
922
-
923
- async def run_agent(
924
- initial_events: List[Event],
925
- stack: DialogueStack,
926
- step: CallFlowStep,
927
- tracker: DialogueStateTracker,
928
- slots: List[Slot],
929
- ) -> FlowStepResult:
930
- """Run an agent call step."""
931
- structlogger.debug(
932
- "flow.step.run_agent", agent_id=step.call, step_id=step.id, flow_id=step.flow_id
933
- )
934
-
935
- final_events = initial_events
936
- agent_stack_frame = tracker.stack.find_agent_stack_frame_by_agent(
937
- agent_id=step.call
938
- )
939
-
940
- if (
941
- agent_stack_frame
942
- and agent_stack_frame == stack.top()
943
- and agent_stack_frame.state == AgentState.INTERRUPTED
944
- ):
945
- structlogger.debug(
946
- "flow.step.run_agent.resume_interrupted_agent",
947
- agent_id=step.call,
948
- step_id=step.id,
949
- flow_id=step.flow_id,
950
- )
951
- # The agent was previously interrupted when waiting for user input.
952
- # Now we're back to the agent execution step and need to output the last message
953
- # from the agent (user input request) again and wait for user input
954
- cast(AgentStackFrame, stack.top()).state = AgentState.WAITING_FOR_INPUT
955
- tracker.update_stack(stack)
956
- utterance = (
957
- agent_stack_frame.metadata.get(AGENT_METADATA_AGENT_RESPONSE_KEY, "")
958
- if agent_stack_frame.metadata
959
- else ""
960
- )
961
- final_events.append(AgentResumed(agent_id=step.call, flow_id=step.flow_id))
962
- return PauseFlowReturnPrediction(
963
- _create_agent_request_user_input_prediction(utterance, final_events)
964
- )
965
-
966
- agent_input_metadata = (
967
- agent_stack_frame.metadata
968
- if agent_stack_frame and agent_stack_frame.metadata
969
- else {}
970
- )
971
- _update_agent_input_metadata_with_events(
972
- agent_input_metadata, step.call, step.flow_id, tracker
973
- )
974
- if step.exit_if:
975
- # TODO: this is a temporary fix to reset the slots covered by the exit_if
976
- if (
977
- agent_stack_frame
978
- and agent_stack_frame.frame_id == f"restart_agent_{step.call}"
979
- ):
980
- # when restarting an agent, we need to reset the slots covered by the
981
- # exit_if condition so that the agent can run again.
982
- _reset_slots_covered_by_exit_if(step.exit_if, tracker)
983
- agent_input_metadata[AGENT_METADATA_EXIT_IF_KEY] = step.exit_if
984
- agent_input = AgentInput(
985
- id=step.call,
986
- user_message=tracker.latest_message.text or ""
987
- if tracker.latest_message
988
- else "",
989
- slots=_prepare_slots_for_agent(tracker.current_slot_values(), slots),
990
- conversation_history=tracker_as_readable_transcript(tracker),
991
- events=tracker.current_state().get("events") or [],
992
- metadata=agent_input_metadata,
993
- )
994
-
995
- final_events.append(AgentStarted(step.call, step.flow_id))
996
-
997
- protocol_type = get_protocol_type(step, AvailableAgents.get_agent_config(step.call))
998
- # send the input to the agent and wait for a response
999
- structlogger.debug(
1000
- "flow.step.run_agent.agent_input",
1001
- agent_name=step.call,
1002
- step_id=step.id,
1003
- flow_id=step.flow_id,
1004
- agent_input=agent_input,
1005
- )
1006
- output: AgentOutput = await _call_agent_with_retry(
1007
- agent_name=step.call,
1008
- protocol_type=protocol_type,
1009
- agent_input=agent_input,
1010
- max_retries=MAX_AGENT_RETRIES,
1011
- )
1012
- structlogger.debug(
1013
- "flow.step.run_agent.agent_response",
1014
- agent_name=step.call,
1015
- step_id=step.id,
1016
- flow_id=step.flow_id,
1017
- agent_response=output,
1018
- )
1019
-
1020
- # add the set slot events returned by the agent to the list of final events
1021
- if output.events:
1022
- final_events.extend(output.events)
1023
-
1024
- if output.status == AgentStatus.INPUT_REQUIRED:
1025
- output.metadata = output.metadata or {}
1026
- output.metadata[AGENT_METADATA_AGENT_RESPONSE_KEY] = (
1027
- output.response_message or ""
1028
- )
1029
- output.metadata[AGENT_METADATA_STRUCTURED_RESULTS_KEY] = (
1030
- output.structured_results or []
1031
- )
1032
- _update_agent_events(final_events, output.metadata)
1033
-
1034
- top_stack_frame = stack.top()
1035
- # update the agent stack frame if it is already on the stack
1036
- # otherwise push a new one
1037
- if isinstance(top_stack_frame, AgentStackFrame):
1038
- top_stack_frame.state = AgentState.WAITING_FOR_INPUT
1039
- top_stack_frame.metadata = output.metadata
1040
- top_stack_frame.step_id = step.id
1041
- top_stack_frame.agent_id = step.call
1042
- top_stack_frame.flow_id = step.flow_id
1043
- else:
1044
- stack.push(
1045
- AgentStackFrame(
1046
- flow_id=step.flow_id,
1047
- agent_id=step.call,
1048
- state=AgentState.WAITING_FOR_INPUT,
1049
- step_id=step.id,
1050
- metadata=output.metadata,
1051
- )
1052
- )
1053
-
1054
- action_prediction = _create_agent_request_user_input_prediction(
1055
- output.response_message, final_events
1056
- )
1057
- return PauseFlowReturnPrediction(action_prediction)
1058
- elif output.status == AgentStatus.COMPLETED:
1059
- output.metadata = output.metadata or {}
1060
- _update_agent_events(final_events, output.metadata)
1061
- structlogger.debug(
1062
- "flow.step.run_agent.completed",
1063
- agent_name=step.call,
1064
- step_id=step.id,
1065
- flow_id=step.flow_id,
1066
- )
1067
- remove_agent_stack_frame(stack, step.call)
1068
- agent_completed_event = AgentCompleted(agent_id=step.call, flow_id=step.flow_id)
1069
- final_events.append(agent_completed_event)
1070
- if output.response_message:
1071
- # for open-ended agents we want to utter the last agent message
1072
-
1073
- return PauseFlowReturnPrediction(
1074
- _create_send_text_prediction(output.response_message, final_events)
1075
- )
1076
- else:
1077
- return ContinueFlowWithNextStep(events=final_events)
1078
- elif output.status == AgentStatus.FATAL_ERROR:
1079
- output.metadata = output.metadata or {}
1080
- _update_agent_events(final_events, output.metadata)
1081
- # the agent failed, trigger pattern_internal_error
1082
- structlogger.error(
1083
- "flow.step.run_agent.fatal_error",
1084
- agent_name=step.call,
1085
- step_id=step.id,
1086
- flow_id=step.flow_id,
1087
- error_message=output.error_message,
1088
- )
1089
- remove_agent_stack_frame(stack, step.call)
1090
- final_events.append(
1091
- AgentCancelled(
1092
- agent_id=step.call, flow_id=step.flow_id, reason=output.error_message
1093
- )
1094
- )
1095
- stack.push(InternalErrorPatternFlowStackFrame())
1096
- return ContinueFlowWithNextStep(events=final_events)
1097
- else:
1098
- output.metadata = output.metadata or {}
1099
- _update_agent_events(final_events, output.metadata)
1100
- structlogger.error(
1101
- "flow.step.run_agent.unknown_status",
1102
- agent_name=step.call,
1103
- step_id=step.id,
1104
- flow_id=step.flow_id,
1105
- status=output.status,
1106
- )
1107
- remove_agent_stack_frame(stack, step.call)
1108
- final_events.append(AgentCancelled(agent_id=step.call, flow_id=step.flow_id))
1109
- stack.push(InternalErrorPatternFlowStackFrame())
1110
- return ContinueFlowWithNextStep(events=final_events)
1111
-
1112
-
1113
- def remove_agent_stack_frame(stack: DialogueStack, agent_id: str) -> None:
1114
- """Finishes the agentic loop by popping the agent stack frame from the
1115
- provided `stack`. The `tracker.stack` is NOT modified.
1116
- """
1117
- agent_stack_frame = stack.find_agent_stack_frame_by_agent(agent_id)
1118
- if not agent_stack_frame:
1119
- return
1120
-
1121
- while removed_frame := stack.pop():
1122
- structlogger.debug(
1123
- "flow_executor.remove_agent_stack_frame",
1124
- removed_frame=removed_frame,
1125
- )
1126
- if removed_frame == agent_stack_frame:
1127
- break
1128
-
1129
-
1130
- def _create_action_prediction(
1131
- action_name: str, message: Optional[str], events: Optional[List[Event]]
1132
- ) -> FlowActionPrediction:
1133
- """Create a prediction for an action with a text message."""
1134
- action_metadata = {
1135
- ACTION_METADATA_MESSAGE_KEY: {
1136
- ACTION_METADATA_TEXT_KEY: message,
1137
- }
1138
- }
1139
- return FlowActionPrediction(
1140
- action_name,
1141
- 1.0,
1142
- events=events if events else [],
1143
- metadata=action_metadata,
1144
- )
1145
-
1146
-
1147
- def _create_agent_request_user_input_prediction(
1148
- message: Optional[str], events: Optional[List[Event]]
1149
- ) -> FlowActionPrediction:
1150
- """Create a prediction for requesting user input from the agent
1151
- and waiting for it.
1152
- """
1153
- return _create_action_prediction(
1154
- ACTION_AGENT_REQUEST_USER_INPUT_NAME, message, events
1155
- )
1156
-
1157
-
1158
- def _create_send_text_prediction(
1159
- message: Optional[str], events: Optional[List[Event]]
1160
- ) -> FlowActionPrediction:
1161
- """Create a prediction for sending a text message to the user."""
1162
- return _create_action_prediction(ACTION_SEND_TEXT_NAME, message, events)
1163
-
1164
-
1165
- async def _call_agent_with_retry(
1166
- agent_name: str,
1167
- protocol_type: ProtocolType,
1168
- agent_input: AgentInput,
1169
- max_retries: int,
1170
- ) -> AgentOutput:
1171
- """Call an agent with retries in case of recoverable errors."""
1172
- for attempt in range(max_retries):
1173
- if attempt > 0:
1174
- structlogger.debug(
1175
- "flow_executor.call_agent_with_retry.retrying",
1176
- agent_name=agent_name,
1177
- attempt=attempt + 1,
1178
- num_retries=max_retries,
1179
- )
1180
- try:
1181
- agent_response: AgentOutput = await AgentManager().run_agent(
1182
- agent_name=agent_name, protocol_type=protocol_type, context=agent_input
1183
- )
1184
- except Exception as e:
1185
- # We don't have a vaild agent response at this time to act based
1186
- # on the agent status, so we return a fatal error.
1187
- structlogger.error(
1188
- "flow_executor.call_agent_with_retry.exception",
1189
- agent_name=agent_name,
1190
- error_message=str(e),
1191
- )
1192
- return AgentOutput(
1193
- id=agent_name,
1194
- status=AgentStatus.FATAL_ERROR,
1195
- error_message=str(e),
1196
- )
1197
-
1198
- if agent_response.status != AgentStatus.RECOVERABLE_ERROR:
1199
- return agent_response
1200
-
1201
- structlogger.warning(
1202
- "flow_executor.call_agent_with_retry.recoverable_error",
1203
- agent_name=agent_name,
1204
- attempt=attempt + 1,
1205
- num_retries=max_retries,
1206
- error_message=agent_response.error_message,
1207
- )
1208
- if attempt < max_retries - 1:
1209
- # exponential backoff - wait longer with each retry
1210
- # 1 second, 2 seconds, 4 seconds, etc.
1211
- await asyncio.sleep(min(2**attempt, MAX_AGENT_RETRY_DELAY_SECONDS))
1212
-
1213
- # we exhausted all retries, return fatal error
1214
- structlogger.warning(
1215
- "flow_executor.call_agent_with_retry.exhausted_retries",
1216
- agent_name=agent_name,
1217
- num_retries=max_retries,
1218
- )
1219
- return AgentOutput(
1220
- id=agent_name,
1221
- status=AgentStatus.FATAL_ERROR,
1222
- error_message="Exhausted all retries for agent call.",
1223
- )
1224
-
1225
-
1226
- def _prepare_slots_for_agent(
1227
- slot_values: Dict[str, Any], slot_definitions: List[Slot]
1228
- ) -> List[AgentInputSlot]:
1229
- """Prepare the slots for the agent.
1230
-
1231
- Filter out slots that should not be forwarded to agents.
1232
- Add the slot type and allowed values to the slot dictionary.
1233
-
1234
- Args:
1235
- slot_values: The full slot dictionary from the tracker.
1236
- slot_definitions: The slot definitions from the domain.
1237
-
1238
- Returns:
1239
- A list of slots containing the name, current value, type, and allowed values.
1240
- """
1241
-
1242
- def _get_slot_definition(slot_name: str) -> Optional[Slot]:
1243
- for slot in slot_definitions:
1244
- if slot.name == slot_name:
1245
- return slot
1246
- return None
1247
-
1248
- filtered_slots: List[AgentInputSlot] = []
1249
- for key, value in slot_values.items():
1250
- if key in SLOTS_EXCLUDED_FOR_AGENT:
1251
- continue
1252
- slot_definition = _get_slot_definition(key)
1253
- if slot_definition:
1254
- filtered_slots.append(
1255
- AgentInputSlot(
1256
- name=key,
1257
- value=value,
1258
- type=slot_definition.type_name if slot_definition else "any",
1259
- allowed_values=slot_definition.values
1260
- if isinstance(slot_definition, CategoricalSlot)
1261
- else None,
1262
- )
1263
- )
1264
-
1265
- return filtered_slots
1266
-
1267
-
1268
- def _update_agent_events(events: List[Event], metadata: Dict[str, Any]) -> None:
1269
- """Update the agent events based on the agent output metadata if needed."""
1270
- if A2A_AGENT_CONTEXT_ID_KEY in metadata:
1271
- # If the context ID is present, we need to store it in the AgentStarted
1272
- # event, so that it can be re-used later in case the agent is restarted.
1273
- for event in events:
1274
- if isinstance(event, AgentStarted):
1275
- event.context_id = metadata[A2A_AGENT_CONTEXT_ID_KEY]
1276
-
1277
-
1278
- def _update_agent_input_metadata_with_events(
1279
- metadata: Dict[str, Any], agent_id: str, flow_id: str, tracker: DialogueStateTracker
1280
- ) -> None:
1281
- """Update the agent input metadata with the events."""
1282
- agent_started_events = [
1283
- event
1284
- for event in tracker.events
1285
- if type(event) == AgentStarted
1286
- and event.agent_id == agent_id
1287
- and event.flow_id == flow_id
1288
- ]
1289
- if agent_started_events:
1290
- # If we have context ID from the previous agent run, we want to
1291
- # include it in the metadata so that the agent can continue the same
1292
- # context.
1293
- agent_started_event = agent_started_events[-1]
1294
- if agent_started_event.context_id:
1295
- metadata[A2A_AGENT_CONTEXT_ID_KEY] = agent_started_event.context_id
@@ -1,9 +1,8 @@
1
1
  import json
2
- import operator
3
- from functools import reduce
4
2
  from typing import Any, Dict, List, Optional
5
3
 
6
4
  import structlog
5
+ from jinja2.sandbox import SandboxedEnvironment
7
6
  from mcp.types import CallToolResult
8
7
 
9
8
  from rasa.core.available_endpoints import AvailableEndpoints
@@ -23,7 +22,7 @@ from rasa.utils.common import ensure_jsonified_iterable
23
22
 
24
23
  structlogger = structlog.get_logger()
25
24
 
26
- CONFIG_RESULT_KEY = "result_key"
25
+ CONFIG_VALUE = "value"
27
26
  CONFIG_SLOT = "slot"
28
27
 
29
28
 
@@ -41,6 +40,7 @@ async def call_mcp_tool(
41
40
  mapping=step.mapping,
42
41
  step_id=step.id,
43
42
  flow_id=step.flow_id,
43
+ json_formatting=["mapping"],
44
44
  )
45
45
 
46
46
  try:
@@ -126,6 +126,7 @@ async def _execute_mcp_tool_call(
126
126
  mcp_server=step.mcp_server,
127
127
  result_content=result.content,
128
128
  result_structured_content=result.structuredContent,
129
+ json_formatting=["result_content", "result_structured_content"],
129
130
  )
130
131
 
131
132
  # Process successful result
@@ -223,31 +224,49 @@ def _jsonify_slot_value(value: Any) -> str | int | float | bool | None:
223
224
  return value
224
225
 
225
226
 
227
+ def _get_slot_value_from_jinja2_expression(
228
+ result_expression: str,
229
+ result_as_dict: Dict[str, Any],
230
+ ) -> Any:
231
+ """Get the slot value from the Jinja2 expression"""
232
+ # Create a sandboxed environment to evaluate the expression
233
+ _env = SandboxedEnvironment()
234
+
235
+ # Compile the expression
236
+ compiled_expr = _env.compile_expression(result_expression)
237
+
238
+ # Evaluate the expression
239
+ return compiled_expr(result_as_dict)
240
+
241
+
226
242
  def _process_tool_result(
227
243
  result: CallToolResult,
228
244
  output_mapping: List[Dict[str, str]],
229
245
  ) -> Optional[List[SlotSet]]:
230
- """Create a SetSlot event for the tool result."""
246
+ """Create a SetSlot event for the tool result using Jinja2 expressions"""
231
247
  try:
232
248
  _result_as_dict = {"result": result.model_dump()}
233
249
  slots = []
234
250
  for mapping in output_mapping:
235
251
  try:
236
- # Use reduce to navigate through nested keys in the result
237
- slot_value = reduce(
238
- operator.getitem,
239
- mapping[CONFIG_RESULT_KEY].split("."),
240
- _result_as_dict,
252
+ result_expression = mapping[CONFIG_VALUE]
253
+
254
+ # Get the slot value from the Jinja2 expression
255
+ slot_value = _get_slot_value_from_jinja2_expression(
256
+ result_expression, _result_as_dict
241
257
  )
258
+
242
259
  slots.append(
243
260
  SlotSet(mapping[CONFIG_SLOT], _jsonify_slot_value(slot_value))
244
261
  )
245
- except (KeyError, TypeError):
262
+ except Exception as e:
246
263
  structlogger.error(
247
- "call_mcp_tool.result_key_not_found_in_tool_result",
264
+ "call_mcp_tool.value_not_found_in_tool_result",
248
265
  slot=mapping[CONFIG_SLOT],
249
- result_key=mapping[CONFIG_RESULT_KEY],
266
+ value=mapping[CONFIG_VALUE],
250
267
  result=_result_as_dict,
268
+ error=str(e),
269
+ json_formatting=["result"],
251
270
  )
252
271
  return None
253
272
  return slots
@@ -256,6 +275,7 @@ def _process_tool_result(
256
275
  "call_mcp_tool.result_processing_failed",
257
276
  error=str(e),
258
277
  result=result,
278
+ json_formatting=["result"],
259
279
  )
260
280
  return None
261
281