rasa-pro 3.14.0.dev1__py3-none-any.whl → 3.14.0.dev20250818__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 (147) hide show
  1. rasa/api.py +0 -5
  2. rasa/cli/arguments/default_arguments.py +0 -12
  3. rasa/cli/arguments/run.py +0 -2
  4. rasa/cli/dialogue_understanding_test.py +0 -4
  5. rasa/cli/e2e_test.py +0 -4
  6. rasa/cli/inspect.py +0 -3
  7. rasa/cli/llm_fine_tuning.py +0 -5
  8. rasa/cli/run.py +0 -4
  9. rasa/cli/shell.py +0 -3
  10. rasa/constants.py +0 -6
  11. rasa/core/actions/action.py +2 -42
  12. rasa/core/agent.py +0 -16
  13. rasa/core/available_endpoints.py +0 -30
  14. rasa/core/channels/inspector/dist/assets/{arc-2e78c586.js → arc-1ddec37b.js} +1 -1
  15. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-806b712e.js → blockDiagram-38ab4fdb-18af387c.js} +1 -1
  16. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-0745efa9.js → c4Diagram-3d4e48cf-250127a3.js} +1 -1
  17. rasa/core/channels/inspector/dist/assets/channel-59f6d54b.js +1 -0
  18. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-7bd1082b.js → classDiagram-70f12bd4-c3388b34.js} +1 -1
  19. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-d937ba49.js → classDiagram-v2-f2320105-9c893a82.js} +1 -1
  20. rasa/core/channels/inspector/dist/assets/clone-26177ddb.js +1 -0
  21. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-a2a564ca.js → createText-2e5e7dd3-c111213b.js} +1 -1
  22. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b5256940.js → edges-e0da2a9e-812a729d.js} +1 -1
  23. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-e6883ad2.js → erDiagram-9861fffd-fd5051bc.js} +1 -1
  24. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-e576fc02.js → flowDb-956e92f1-3287ac02.js} +1 -1
  25. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-2e298d01.js → flowDiagram-66a62f08-692fb0b2.js} +1 -1
  26. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-29c03f5a.js +1 -0
  27. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-dd7b150a.js → flowchart-elk-definition-4a651766-008376f1.js} +1 -1
  28. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-5b79575c.js → ganttDiagram-c361ad54-df330a69.js} +1 -1
  29. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-3016f40a.js → gitGraphDiagram-72cf32ee-e03676fb.js} +1 -1
  30. rasa/core/channels/inspector/dist/assets/{graph-3e19170f.js → graph-46fad2ba.js} +1 -1
  31. rasa/core/channels/inspector/dist/assets/{index-3862675e-eb9c86de.js → index-3862675e-a484ac55.js} +1 -1
  32. rasa/core/channels/inspector/dist/assets/index-a003633f.js +1335 -0
  33. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b4280e4d.js → infoDiagram-f8f76790-3f9e6ec2.js} +1 -1
  34. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-556091f8.js → journeyDiagram-49397b02-79f72383.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{layout-08436411.js → layout-aad098e5.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{line-683c4f3b.js → line-219ab7ae.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{linear-cee6d791.js → linear-2cddbe62.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a0bf0b1a.js → mindmap-definition-fc14e90a-1d41ed99.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-3730d5c4.js → pieDiagram-8a3498a8-cc496ee8.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-12a20fed.js → quadrantDiagram-120e2f19-84d32884.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-b9732102.js → requirementDiagram-deff3bca-c0deb984.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-a2e72776.js → sankeyDiagram-04a897e0-b9d7fd62.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-8b7a76bb.js → sequenceDiagram-704730f1-7d517565.js} +1 -1
  44. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e65853ac.js → stateDiagram-587899a1-98ef9b27.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-6f58a44b.js → stateDiagram-v2-d93cdb3a-cee70748.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-df25b934.js → styles-6aaf32cf-3f9d1c96.js} +1 -1
  47. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-88357141.js → styles-9a916d00-67471923.js} +1 -1
  48. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-d600174d.js → styles-c10674c1-bd093fb7.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-4adc3e0b.js → svgDrawCommon-08f97a94-675794e8.js} +1 -1
  50. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-42816fa1.js → timeline-definition-85554ec2-0ac67617.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-621eb66a.js → xychartDiagram-e933f94c-c018dc37.js} +1 -1
  52. rasa/core/channels/inspector/dist/index.html +1 -1
  53. rasa/core/channels/inspector/src/components/DialogueStack.tsx +5 -7
  54. rasa/core/channels/inspector/src/helpers/formatters.ts +3 -24
  55. rasa/core/channels/inspector/src/theme/base/styles.ts +1 -19
  56. rasa/core/channels/inspector/src/types.ts +0 -4
  57. rasa/core/constants.py +0 -4
  58. rasa/core/policies/enterprise_search_policy.py +2 -4
  59. rasa/core/policies/flow_policy.py +2 -2
  60. rasa/core/policies/flows/flow_executor.py +35 -374
  61. rasa/core/processor.py +1 -6
  62. rasa/core/run.py +1 -8
  63. rasa/core/utils.py +1 -21
  64. rasa/dialogue_understanding/commands/__init__.py +0 -8
  65. rasa/dialogue_understanding/commands/cancel_flow_command.py +4 -97
  66. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +0 -11
  67. rasa/dialogue_understanding/commands/knowledge_answer_command.py +0 -11
  68. rasa/dialogue_understanding/commands/start_flow_command.py +8 -129
  69. rasa/dialogue_understanding/commands/utils.py +2 -6
  70. rasa/dialogue_understanding/generator/command_parser.py +0 -4
  71. rasa/dialogue_understanding/generator/llm_based_command_generator.py +12 -50
  72. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +6 -7
  73. rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +6 -7
  74. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +2 -41
  75. rasa/dialogue_understanding/patterns/continue_interrupted.py +1 -163
  76. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +7 -51
  77. rasa/dialogue_understanding/stack/dialogue_stack.py +2 -123
  78. rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +0 -57
  79. rasa/dialogue_understanding/stack/utils.py +2 -3
  80. rasa/dialogue_understanding_test/du_test_runner.py +2 -7
  81. rasa/e2e_test/e2e_test_runner.py +0 -5
  82. rasa/server.py +0 -10
  83. rasa/shared/constants.py +0 -5
  84. rasa/shared/core/constants.py +1 -12
  85. rasa/shared/core/domain.py +5 -5
  86. rasa/shared/core/events.py +0 -319
  87. rasa/shared/core/flows/flows_list.py +2 -2
  88. rasa/shared/core/flows/flows_yaml_schema.json +186 -101
  89. rasa/shared/core/flows/steps/call.py +5 -51
  90. rasa/shared/core/flows/validation.py +7 -45
  91. rasa/shared/core/flows/yaml_flows_io.py +3 -3
  92. rasa/shared/providers/llm/_base_litellm_client.py +7 -39
  93. rasa/shared/providers/llm/litellm_router_llm_client.py +4 -8
  94. rasa/shared/providers/llm/llm_client.py +3 -7
  95. rasa/shared/providers/llm/llm_response.py +0 -49
  96. rasa/shared/providers/llm/self_hosted_llm_client.py +4 -8
  97. rasa/shared/utils/llm.py +5 -28
  98. rasa/shared/utils/schemas/events.py +0 -42
  99. rasa/studio/upload.py +7 -4
  100. rasa/tracing/instrumentation/instrumentation.py +2 -4
  101. rasa/utils/common.py +0 -53
  102. rasa/version.py +1 -1
  103. {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/METADATA +2 -3
  104. {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/RECORD +107 -143
  105. rasa/agents/__init__.py +0 -0
  106. rasa/agents/agent_factory.py +0 -122
  107. rasa/agents/agent_manager.py +0 -162
  108. rasa/agents/constants.py +0 -31
  109. rasa/agents/core/__init__.py +0 -0
  110. rasa/agents/core/agent_protocol.py +0 -108
  111. rasa/agents/core/types.py +0 -70
  112. rasa/agents/exceptions.py +0 -8
  113. rasa/agents/protocol/__init__.py +0 -5
  114. rasa/agents/protocol/a2a/__init__.py +0 -0
  115. rasa/agents/protocol/a2a/a2a_agent.py +0 -51
  116. rasa/agents/protocol/mcp/__init__.py +0 -0
  117. rasa/agents/protocol/mcp/mcp_base_agent.py +0 -697
  118. rasa/agents/protocol/mcp/mcp_open_agent.py +0 -275
  119. rasa/agents/protocol/mcp/mcp_task_agent.py +0 -447
  120. rasa/agents/schemas/__init__.py +0 -6
  121. rasa/agents/schemas/agent_input.py +0 -24
  122. rasa/agents/schemas/agent_output.py +0 -26
  123. rasa/agents/schemas/agent_tool_result.py +0 -51
  124. rasa/agents/schemas/agent_tool_schema.py +0 -112
  125. rasa/agents/templates/__init__.py +0 -0
  126. rasa/agents/templates/mcp_open_agent_prompt_template.jinja2 +0 -15
  127. rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +0 -13
  128. rasa/agents/utils.py +0 -72
  129. rasa/core/available_agents.py +0 -196
  130. rasa/core/channels/inspector/dist/assets/channel-c436ca7c.js +0 -1
  131. rasa/core/channels/inspector/dist/assets/clone-50dd656b.js +0 -1
  132. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-2b2aeaf8.js +0 -1
  133. rasa/core/channels/inspector/dist/assets/index-1bd9135e.js +0 -1353
  134. rasa/core/policies/flows/mcp_tool_executor.py +0 -240
  135. rasa/dialogue_understanding/commands/continue_agent_command.py +0 -91
  136. rasa/dialogue_understanding/commands/restart_agent_command.py +0 -146
  137. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +0 -61
  138. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +0 -61
  139. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +0 -81
  140. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +0 -81
  141. rasa/shared/agents/__init__.py +0 -0
  142. rasa/shared/agents/utils.py +0 -35
  143. rasa/shared/utils/mcp/__init__.py +0 -0
  144. rasa/shared/utils/mcp/server_connection.py +0 -157
  145. {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/NOTICE +0 -0
  146. {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/WHEEL +0 -0
  147. {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/entry_points.txt +0 -0
@@ -1,81 +0,0 @@
1
- ## Task Description
2
- Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to off-topic and knowledge requests.
3
-
4
- ---
5
-
6
- ## Available Actions:
7
- * `start flow flow_name`: Start a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
8
- * `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
9
- * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: When a message could refer to multiple flows, list the possible flows as options to clarify. Example: `disambiguate flows list_contacts add_contact remove_contact`.
10
- * `search and reply`: Provide a response from the knowledge base to address the user's inquiry when no flows fit, including domain knowledge, FAQs, and all off-topic or social messages.
11
- * `cancel flow`: Cancel the current flow if the user requests it.
12
- * `repeat message`: Repeat the last bot message.
13
- {% if active_agent %} * `continue agent`: Continue the currently active agent {{ active_agent.name }}.{% endif %}
14
- {% if completed_agents %}* `restart agent agent_name`: Restart the agent with the given name, in case the user wants to change some answer to a previous question asked by the agent. For example, `restart agent car_research_agent` if the user chnaged his mind about the car he wants to buy.{% endif %}
15
-
16
- ---
17
-
18
- ## General Instructions
19
- ### Start Flow
20
- * Only start a flow if the user's message is clear and fully addressed by that flow's description and purpose.
21
- * Pay close attention to exact wording and scope in the flow description — do not assume or “stretch” the intended use of a flow.
22
- ### Set Slot
23
- * Do not fill slots with abstract values or placeholders.
24
- * For categorical slots, try to match the user message with allowed slot values. Use "other" if you cannot match it.
25
- * Set the boolean slots based on the user's response. Map positive responses to `True`, and negative to `False`.
26
- * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
27
- ### Disambiguate Flows
28
- * Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
29
- * If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
30
- * If a single flow is a strong/plausible fit, prefer starting that flow directly.
31
- * If a user's message unambiguously and distinctly matches multiple flows, start all relevant flows at once (rather than disambiguating).
32
- ### Search and Reply
33
- * Only start `search and reply` if the user intent is clear.
34
- * Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
35
- ### Cancel Flow
36
- * Do not cancel any flow unless the user explicitly requests it.
37
- * Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
38
- ### General Tips
39
- * Only use information provided by the user.
40
- * Strictly adhere to the provided action format.
41
- * Focus on the last message and take it one step at a time.
42
- * Use the previous conversation steps only to aid understanding.
43
-
44
- ---
45
-
46
- ## Decision Rule Table
47
- | Condition | Action |
48
- |-------------------------------------------------------|--------------------|
49
- | Flow perfectly matches user's message | start flow |
50
- | Multiple flows are equally strong, relevant matches | disambiguate flows |
51
- | User's message is unclear or imprecise | disambiguate flows |
52
- | No flow fits at all, but knowledge base may help | search and reply |
53
-
54
- ---
55
-
56
- ## Available Flows and Slots
57
- Use the following structured data:
58
- ```json
59
- {"flows":[{% for flow in available_flows %}{"name":"{{ flow.name }}","description":{{ flow.description | to_json_escaped_string }}{% if flow.agent_info %},"sub-agents":[{% for agent in flow.agent_info %}{"name":"{{ agent.name }}","description":{{ agent.description | to_json_escaped_string }}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}{% if flow.slots %},"slots":[{% for slot in flow.slots %}{"name":"{{ slot.name }}"{% if slot.description %},"description":{{ slot.description | to_json_escaped_string }}{% endif %}{% if slot.allowed_values %},"allowed_values":{{ slot.allowed_values }}{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
60
- ```
61
-
62
- ---
63
-
64
- ## Current State
65
- {% if current_flow != None %}Use the following structured data:
66
- ```json
67
- {"active_flow": "{{ current_flow }}","current_step": {"requested_slot": "{{ current_slot }}","requested_slot_description": {{ current_slot_description | to_json_escaped_string }}},"slots": [{% for slot in flow_slots %}{"name": "{{ slot.name }}","value": "{{ slot.value }}","type": "{{ slot.type }}"{{ "," if slot.description or slot.allowed_values else "" }}{% if slot.description %}"description": {{ slot.description | to_json_escaped_string }}{{ "," if slot.allowed_values else "" }}{% endif %}{% if slot.allowed_values %}"allowed_values": "{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% if active_agent or completed_agents %},{% endif %}{% if active_agent %}"active_agent": {"name": "{{ active_agent.name }}","description": "{{ active_agent.description }}"}{% if completed_agents %},{% endif %}{% endif %}{% if completed_agents %}"completed_agents": [{% for agent in completed_agents %}{"name": "{{ agent.name }}","description": "{{ agent.description }}"}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}
68
- ```{% else %}
69
- You are currently not inside any flow.{% endif %}
70
-
71
- ---
72
-
73
- ## Conversation History
74
- {{ current_conversation }}
75
-
76
- ---
77
-
78
- ## Task
79
- Create an action list with one action per line in response to the user's last message: """{{ user_message }}""".
80
-
81
- Your action list:
@@ -1,81 +0,0 @@
1
- ## Task Description
2
- Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to off-topic and knowledge requests.
3
-
4
- ---
5
-
6
- ## Available Flows and Slots
7
- Use the following structured data:
8
- ```json
9
- {"flows":[{% for flow in available_flows %}{"name":"{{ flow.name }}","description":{{ flow.description | to_json_escaped_string }}{% if flow.agent_info %},"sub-agents":[{% for agent in flow.agent_info %}{"name":"{{ agent.name }}","description":{{ agent.description | to_json_escaped_string }}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}{% if flow.slots %},"slots":[{% for slot in flow.slots %}{"name":"{{ slot.name }}"{% if slot.description %},"description":{{ slot.description | to_json_escaped_string }}{% endif %}{% if slot.allowed_values %},"allowed_values":{{ slot.allowed_values }}{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
10
- ```
11
-
12
- ---
13
-
14
- ## Available Actions:
15
- * `start flow flow_name`: Start a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
16
- * `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
17
- * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: When a message could refer to multiple flows, list the possible flows as options to clarify. Example: `disambiguate flows list_contacts add_contact remove_contact`.
18
- * `search and reply`: Provide a response from the knowledge base to address the user’s inquiry when no flows fit, including domain knowledge, FAQs, and all off-topic or social messages.
19
- * `cancel flow`: Cancel the current flow if the user requests it.
20
- * `repeat message`: Repeat the last bot message.
21
- {% if active_agent %} * `continue agent`: Continue the currently active agent {{ active_agent.name }}.{% endif %}
22
- {% if completed_agents %}* `restart agent agent_name`: Restart the agent with the given name, in case the user wants to change some answer to a previous question asked by the agent. For example, `restart agent car_research_agent` if the user chnaged his mind about the car he wants to buy.{% endif %}
23
-
24
- ---
25
-
26
- ## General Instructions
27
- ### Start Flow
28
- * Only start a flow if the user's message is clear and fully addressed by that flow's description and purpose.
29
- * Pay close attention to exact wording and scope in the flow description — do not assume or “stretch” the intended use of a flow.
30
- ### Set Slot
31
- * Do not fill slots with abstract values or placeholders.
32
- * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
33
- * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
34
- * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
35
- ### Disambiguate Flows
36
- * Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
37
- * If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
38
- * If a single flow is a strong/plausible fit, prefer starting that flow directly.
39
- * If a user's message unambiguously and distinctly matches multiple flows, start all relevant flows at once (rather than disambiguating).
40
- ### Search and Reply
41
- * Only start `search and reply` if the user intent is clear.
42
- * Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
43
- ### Cancel Flow
44
- * Do not cancel any flow unless the user explicitly requests it.
45
- * Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
46
- ### General Tips
47
- * Only use information provided by the user.
48
- * Strictly adhere to the provided action format.
49
- * Focus on the last message and take it one step at a time.
50
- * Use the previous conversation steps only to aid understanding.
51
-
52
- ---
53
-
54
- ## Decision Rule Table
55
- | Condition | Action |
56
- |-------------------------------------------------------|--------------------|
57
- | Flow perfectly matches user's message | start flow |
58
- | Multiple flows are equally strong, relevant matches | disambiguate flows |
59
- | User's message is unclear or imprecise | disambiguate flows |
60
- | No flow fits at all, but knowledge base may help | search and reply |
61
-
62
- ---
63
-
64
- ## Current State
65
- {% if current_flow != None %}Use the following structured data:
66
- ```json
67
- {"active_flow": "{{ current_flow }}","current_step": {"requested_slot": "{{ current_slot }}","requested_slot_description": {{ current_slot_description | to_json_escaped_string }}},"slots": [{% for slot in flow_slots %}{"name": "{{ slot.name }}","value": "{{ slot.value }}","type": "{{ slot.type }}"{{ "," if slot.description or slot.allowed_values else "" }}{% if slot.description %}"description": {{ slot.description | to_json_escaped_string }}{{ "," if slot.allowed_values else "" }}{% endif %}{% if slot.allowed_values %}"allowed_values": "{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% if active_agent or completed_agents %},{% endif %}{% if active_agent %}"active_agent": {"name": "{{ active_agent.name }}","description": "{{ active_agent.description }}"}{% if completed_agents %},{% endif %}{% endif %}{% if completed_agents %}"completed_agents": [{% for agent in completed_agents %}{"name": "{{ agent.name }}","description": "{{ agent.description }}"}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}
68
- ```{% else %}
69
- You are currently not inside any flow.{% endif %}
70
-
71
- ---
72
-
73
- ## Conversation History
74
- {{ current_conversation }}
75
-
76
- ---
77
-
78
- ## Task
79
- Create an action list with one action per line in response to the user's last message: """{{ user_message }}""".
80
-
81
- Your action list:
File without changes
@@ -1,35 +0,0 @@
1
- from typing import Optional
2
-
3
- from rasa.agents.core.types import AgentIdentifier, ProtocolType
4
- from rasa.core.available_agents import AgentConfig, ProtocolConfig
5
- from rasa.shared.core.flows.steps import CallFlowStep
6
-
7
-
8
- def make_agent_identifier(
9
- agent_name: str, protocol_type: ProtocolType
10
- ) -> AgentIdentifier:
11
- """Make an agent identifier."""
12
- return AgentIdentifier(agent_name, protocol_type)
13
-
14
-
15
- def get_protocol_type(
16
- step: CallFlowStep, agent_config: Optional[AgentConfig]
17
- ) -> ProtocolType:
18
- """Get the protocol type for an agent.
19
-
20
- Args:
21
- step: The step that is calling the agent.
22
- agent_config: The agent configuration.
23
-
24
- Returns:
25
- The protocol type for the agent.
26
- """
27
- if step.exit_if:
28
- protocol_type = ProtocolType.MCP_TASK
29
- else:
30
- protocol_type = (
31
- ProtocolType.A2A
32
- if agent_config and agent_config.agent.protocol == ProtocolConfig.A2A
33
- else ProtocolType.MCP_OPEN
34
- )
35
- return protocol_type
File without changes
@@ -1,157 +0,0 @@
1
- """MCP server connection utilities."""
2
-
3
- import asyncio
4
- from contextlib import AsyncExitStack
5
- from typing import Any, Dict, Optional
6
-
7
- import structlog
8
- from mcp import ClientSession
9
- from mcp.client.streamable_http import streamablehttp_client
10
-
11
- structlogger = structlog.get_logger()
12
-
13
-
14
- class MCPServerConnection:
15
- """
16
- Manages connection to an MCP server.
17
-
18
- This class handles the lifecycle of connections to MCP servers,
19
- including connection establishment, session management, and cleanup.
20
- """
21
-
22
- def __init__(self, server_name: str, server_url: str, server_type: str):
23
- """
24
- Initialize the MCP server connection.
25
-
26
- Args:
27
- server_name: Server name to identify the server
28
- server_url: Server URL
29
- server_type: Server type (currently only 'http' is supported)
30
- """
31
- self.server_name = server_name
32
- self.server_url = server_url
33
- self.server_type = server_type
34
- self.session: Optional[ClientSession] = None
35
- self.exit_stack: Optional[AsyncExitStack] = None
36
-
37
- @classmethod
38
- def from_config(cls, server_config: Dict[str, Any]) -> "MCPServerConnection":
39
- """Initialize the MCP server connection from a configuration dictionary."""
40
- return cls(
41
- server_config["name"],
42
- server_config["url"],
43
- server_config.get("type", "http"),
44
- )
45
-
46
- async def connect(self) -> None:
47
- """Establish connection to the MCP server.
48
-
49
- Raises:
50
- ValueError: If the server type is not supported.
51
- ConnectionError: If connection fails.
52
- """
53
- if self.server_type != "http":
54
- raise ValueError(f"Unsupported server type: {self.server_type}")
55
-
56
- # Create a new exit stack for this connection to avoid task boundary issues
57
- self.exit_stack = AsyncExitStack()
58
-
59
- try:
60
- read_stream, write_stream, _ = await self.exit_stack.enter_async_context(
61
- streamablehttp_client(self.server_url)
62
- )
63
- self.session = await self.exit_stack.enter_async_context(
64
- ClientSession(read_stream, write_stream)
65
- )
66
- await self.session.initialize()
67
- except asyncio.CancelledError as e:
68
- event_info = f"Connection to MCP server {self.server_name} was cancelled."
69
- structlogger.error(
70
- "mcp_server_connection.connect.connection_cancelled",
71
- event_info=event_info,
72
- server_name=self.server_name,
73
- server_url=self.server_url,
74
- )
75
- # Clean up on cancellation
76
- await self._cleanup()
77
- raise ConnectionError(e)
78
-
79
- except Exception as e:
80
- event_info = f"Failed to connect to MCP server {self.server_name}: {e}"
81
- structlogger.error(
82
- "mcp_server_connection.connect.connection_failed",
83
- event_info=event_info,
84
- server_name=self.server_name,
85
- server_url=self.server_url,
86
- )
87
- # Clean up on error
88
- await self._cleanup()
89
- raise ConnectionError(e)
90
-
91
- async def ensure_active_session(self) -> ClientSession:
92
- """
93
- Ensure an active session is available.
94
-
95
- If no session exists or the current session is inactive,
96
- a new connection will be established.
97
-
98
- Returns:
99
- Active ClientSession instance.
100
- """
101
- if self.session is None:
102
- await self.connect()
103
- structlogger.info(
104
- "mcp_server_connection.ensure_active_session.no_session",
105
- server_name=self.server_name,
106
- server_url=self.server_url,
107
- event_info=(
108
- "No session found, connecting to the server "
109
- f"`{self.server_name}` @ `{self.server_url}`"
110
- ),
111
- )
112
- if self.session:
113
- try:
114
- await self.session.send_ping()
115
- except Exception as e:
116
- structlogger.error(
117
- "mcp_server_connection.ensure_active_session.ping_failed",
118
- error=str(e),
119
- server_name=self.server_name,
120
- server_url=self.server_url,
121
- event_info=(
122
- "Ping failed, trying to reconnect to the server "
123
- f"`{self.server_name}` @ `{self.server_url}`"
124
- ),
125
- )
126
- await self.connect()
127
- structlogger.info(
128
- "mcp_server_connection.ensure_active_session.reconnected",
129
- server_name=self.server_name,
130
- server_url=self.server_url,
131
- event_info=(
132
- "Reconnected to the server "
133
- f"`{self.server_name}` @ `{self.server_url}`"
134
- ),
135
- )
136
- assert self.session is not None # Ensures type for mypy
137
- return self.session
138
-
139
- async def close(self) -> None:
140
- """Close the connection and clean up resources."""
141
- await self._cleanup()
142
-
143
- async def _cleanup(self) -> None:
144
- """Internal cleanup method to safely close resources."""
145
- if self.exit_stack:
146
- try:
147
- await self.exit_stack.aclose()
148
- except Exception as e:
149
- # Log cleanup errors but don't raise them
150
- structlogger.warning(
151
- "mcp_server_connection.cleanup.failed",
152
- server_name=self.server_name,
153
- error=str(e),
154
- )
155
- finally:
156
- self.exit_stack = None
157
- self.session = None