xpander-sdk 2.0.161__py3-none-any.whl → 2.0.192__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.
Files changed (33) hide show
  1. xpander_sdk/__init__.py +6 -0
  2. xpander_sdk/consts/api_routes.py +8 -0
  3. xpander_sdk/models/compactization.py +112 -0
  4. xpander_sdk/models/events.py +3 -0
  5. xpander_sdk/models/frameworks.py +2 -2
  6. xpander_sdk/models/generic.py +27 -0
  7. xpander_sdk/models/notifications.py +98 -0
  8. xpander_sdk/models/orchestrations.py +271 -0
  9. xpander_sdk/modules/agents/models/agent.py +7 -4
  10. xpander_sdk/modules/agents/sub_modules/agent.py +18 -10
  11. xpander_sdk/modules/backend/__init__.py +8 -0
  12. xpander_sdk/modules/backend/backend_module.py +47 -2
  13. xpander_sdk/modules/backend/decorators/__init__.py +7 -0
  14. xpander_sdk/modules/backend/decorators/on_auth_event.py +131 -0
  15. xpander_sdk/modules/backend/events_registry.py +172 -0
  16. xpander_sdk/modules/backend/frameworks/agno.py +176 -54
  17. xpander_sdk/modules/backend/frameworks/dispatch.py +3 -1
  18. xpander_sdk/modules/backend/utils/mcp_oauth.py +36 -24
  19. xpander_sdk/modules/events/decorators/__init__.py +3 -0
  20. xpander_sdk/modules/events/decorators/on_tool.py +384 -0
  21. xpander_sdk/modules/events/events_module.py +9 -3
  22. xpander_sdk/modules/tasks/models/task.py +3 -14
  23. xpander_sdk/modules/tasks/sub_modules/task.py +54 -20
  24. xpander_sdk/modules/tools_repository/sub_modules/tool.py +46 -15
  25. xpander_sdk/modules/tools_repository/utils/generic.py +3 -0
  26. xpander_sdk/utils/agents/__init__.py +0 -0
  27. xpander_sdk/utils/agents/compactization_agent.py +257 -0
  28. xpander_sdk/utils/generic.py +5 -0
  29. {xpander_sdk-2.0.161.dist-info → xpander_sdk-2.0.192.dist-info}/METADATA +97 -13
  30. {xpander_sdk-2.0.161.dist-info → xpander_sdk-2.0.192.dist-info}/RECORD +33 -22
  31. {xpander_sdk-2.0.161.dist-info → xpander_sdk-2.0.192.dist-info}/WHEEL +0 -0
  32. {xpander_sdk-2.0.161.dist-info → xpander_sdk-2.0.192.dist-info}/licenses/LICENSE +0 -0
  33. {xpander_sdk-2.0.161.dist-info → xpander_sdk-2.0.192.dist-info}/top_level.txt +0 -0
xpander_sdk/__init__.py CHANGED
@@ -17,6 +17,7 @@ For more information, visit: https://xpander.ai
17
17
 
18
18
  # Backend-related imports
19
19
  from .modules.backend.backend_module import Backend
20
+ from .modules.backend.decorators.on_auth_event import on_auth_event
20
21
 
21
22
  # Agent-related imports
22
23
  from .modules.agents.agents_module import Agents, Agent, AgentsListItem
@@ -27,6 +28,7 @@ from .modules.tasks.tasks_module import Tasks, Task, TasksListItem, AgentExecuti
27
28
  from xpander_sdk.modules.events.decorators.on_task import on_task
28
29
  from xpander_sdk.modules.events.decorators.on_boot import on_boot
29
30
  from xpander_sdk.modules.events.decorators.on_shutdown import on_shutdown
31
+ from xpander_sdk.modules.events.decorators.on_tool import on_tool_before, on_tool_after, on_tool_error
30
32
 
31
33
  # Tools and repository imports
32
34
  from .modules.tools_repository.tools_repository_module import ToolsRepository, Tool
@@ -53,6 +55,7 @@ from .models.shared import OutputFormat, Tokens
53
55
  __all__ = [
54
56
  # xpander.ai Backend
55
57
  "Backend",
58
+ "on_auth_event",
56
59
  # Agent management
57
60
  "Agents",
58
61
  "Agent",
@@ -75,6 +78,9 @@ __all__ = [
75
78
  "MCPServerAuthType",
76
79
  "register_tool",
77
80
  "build_model_from_schema",
81
+ "on_tool_before",
82
+ "on_tool_after",
83
+ "on_tool_error",
78
84
  # Knowledge bases
79
85
  "KnowledgeBases",
80
86
  "KnowledgeBase",
@@ -55,6 +55,14 @@ and deleting resources.
55
55
 
56
56
  # Tools
57
57
  GetOrInvokeToolById = "/tools/{tool_id}"
58
+ InvokeCustomAgentTool = "/tools/{connector_id}/{tool_id}"
59
+ GetOrInvokeToolByUUID = "/tools/{connector_id}_{tool_id}"
60
+ ExecuteCodeInSandbox = "/tools/{task_id}/xp-code-executor"
61
+
62
+ # HITL (Human-in-the-Loop)
63
+ HITLRequest = "/hitl/request"
64
+ HITLApprove = "/hitl/{task_id}/approve"
65
+ HITLReject = "/hitl/{task_id}/reject"
58
66
 
59
67
  def __str__(self) -> str:
60
68
  return str(self.value)
@@ -0,0 +1,112 @@
1
+ from typing import List, Literal, Union
2
+
3
+ from pydantic import Field
4
+ from xpander_sdk.models.deep_planning import DeepPlanningItem
5
+ from xpander_sdk.models.shared import XPanderSharedModel
6
+ from xpander_sdk.modules.agents.models.agent import AgentInstructions
7
+ from xpander_sdk.modules.tasks.models.task import AgentExecutionInput
8
+
9
+
10
+ class TaskCompactizationInput(XPanderSharedModel):
11
+ user_input: AgentExecutionInput = Field(
12
+ ...,
13
+ description=(
14
+ "Original user input that initiated the task, including text, optional file URLs, "
15
+ "and optional user details."
16
+ ),
17
+ )
18
+ agent_instructions: AgentInstructions = Field(
19
+ ...,
20
+ description="Agent instructions (role, goals, and general guidance) that were active during execution."
21
+ )
22
+ task_context_and_messages: str = Field(
23
+ ...,
24
+ description=(
25
+ "Complete execution context including message history, tool calls, and session state. "
26
+ "This contains all information about what was attempted and what was achieved."
27
+ )
28
+ )
29
+ uncompleted_tasks: List["DeepPlanningItem"] = Field(
30
+ default_factory=list,
31
+ description=(
32
+ "List of planned tasks that remain incomplete. Each task has an id, title, and completed status. "
33
+ "ALL of these tasks MUST be completed and marked as completed=true in the continuation."
34
+ )
35
+ )
36
+
37
+ class TaskCompactizationRetryEvent(XPanderSharedModel):
38
+ is_retry: bool
39
+
40
+ class TaskCompactizationOutput(XPanderSharedModel):
41
+ new_task_prompt: str = Field(
42
+ ...,
43
+ min_length=1,
44
+ description=(
45
+ "A continuation prompt that seamlessly continues the running execution. "
46
+ "This is NOT a new task - it's the next message in an ongoing conversation. "
47
+ "The prompt must:\n"
48
+ "1. Resume from where the execution left off (do NOT repeat completed work)\n"
49
+ "2. Focus on completing ALL remaining uncompleted tasks\n"
50
+ "3. Include specific instructions to mark each task as completed after finishing it\n"
51
+ "4. Be written as if you're continuing mid-conversation, not starting fresh\n"
52
+ "5. Reference the current state and what still needs to be done\n"
53
+ "Example: 'Continuing from where we left off, we still need to complete tasks X, Y, and Z. "
54
+ "Let's proceed with task X first, then mark it complete using the appropriate tool.'"
55
+ ),
56
+ )
57
+
58
+ task_context: str = Field(
59
+ ...,
60
+ min_length=1,
61
+ description=(
62
+ "Comprehensive context for continuing the execution. This context will be injected "
63
+ "into the agent's system prompt to maintain execution continuity.\n\n"
64
+ "REQUIRED FORMAT (use these exact headings, in this order):\n"
65
+ "1) ORIGINAL USER REQUEST\n"
66
+ "- Verbatim user_input text and any file references.\n\n"
67
+ "2) AGENT INSTRUCTIONS IN EFFECT\n"
68
+ "- General description from agent instructions.\n"
69
+ "- Role instructions (bullet list).\n"
70
+ "- Goals (bullet list).\n"
71
+ "- Any constraints or special requirements.\n\n"
72
+ "3) EXECUTION SUMMARY\n"
73
+ "- What actions were taken (facts only, no speculation).\n"
74
+ "- What outputs were produced (facts only).\n\n"
75
+ "4) CURRENT STATE AND ARTIFACTS\n"
76
+ "- All created artifacts with their identifiers, paths, URLs, or references.\n"
77
+ "- Current state of variables, decisions, configurations, and assumptions.\n"
78
+ "- Active session or database state if relevant.\n\n"
79
+ "5) MESSAGES AND KEY EVIDENCE\n"
80
+ "- Compact chronological summary of the conversation flow.\n"
81
+ "- Up to 5 verbatim quotes (max 25 words each) capturing critical details.\n\n"
82
+ "6) TOOL CALLS AND OBSERVATIONS\n"
83
+ "- For each tool call: tool name/id, purpose, key inputs, key outputs, errors.\n"
84
+ "- Include plan tool calls (create/get/complete) if they occurred.\n"
85
+ "- If no tools used: 'No tool calls were made.'\n\n"
86
+ "7) COMPLETED VS UNCOMPLETED TASKS\n"
87
+ "- Completed: List with task IDs and titles that are done.\n"
88
+ "- Uncompleted: List each task ID, title, and specific reason it's incomplete.\n"
89
+ "- CRITICAL: All uncompleted tasks MUST be finished in the continuation.\n\n"
90
+ "8) OPEN QUESTIONS AND UNKNOWNS\n"
91
+ "- Missing information needed to complete remaining tasks.\n"
92
+ "- Blockers or dependencies preventing progress.\n"
93
+ "- If none: 'No open questions.'\n\n"
94
+ "9) NEXT ACTIONS TO COMPLETE ALL TASKS\n"
95
+ "- Ordered list of specific actions to complete each uncompleted task.\n"
96
+ "- Each action should reference the task ID it completes.\n"
97
+ "- Final action must be to mark all tasks as completed using the plan tools.\n\n"
98
+ "ACCURACY REQUIREMENTS:\n"
99
+ "- Do NOT invent details. Use 'Unknown' if information is missing.\n"
100
+ "- Preserve exact names, IDs, numbers, file paths, and user wording.\n"
101
+ "- Task completion status must match reality - no implied completion.\n"
102
+ "- Focus on actionable, specific continuation steps.\n"
103
+ ),
104
+ )
105
+
106
+
107
+ class TaskCompactizationEvent(XPanderSharedModel):
108
+ type: Literal["retry", "summarization"]
109
+ data: Union[
110
+ TaskCompactizationOutput,
111
+ TaskCompactizationRetryEvent
112
+ ]
@@ -71,3 +71,6 @@ class TaskUpdateEventType(str, Enum):
71
71
 
72
72
  # deep planning
73
73
  PlanUpdated = "plan_updated"
74
+
75
+ # task compactization
76
+ TaskCompactization = "task_compactization"
@@ -30,7 +30,7 @@ class AgnoSettings(BaseModel):
30
30
  session_storage (Optional[bool]): If True, enables session-level storage. Default is True.
31
31
  user_memories (Optional[bool]): If True, enables memory of user interactions. Default is True.
32
32
  session_summaries (Optional[bool]): If True, enables generation of session summaries. Default is False.
33
- num_history_runs (Optional[int]): Number of historical runs to retain or consider. Default is 3.
33
+ num_history_runs (Optional[int]): Number of historical runs to retain or consider. Default is 10.
34
34
  tool_call_limit (Optional[int]): Max tool calls per run.
35
35
  coordinate_mode (Optional[bool]): If True, The agent will be loaded as a Team. Default is False.
36
36
  pii_detection_enabled (Optional[bool]): If True, enables PII detection guardrail on agent input. Default is False.
@@ -50,7 +50,7 @@ class AgnoSettings(BaseModel):
50
50
  agentic_culture: Optional[bool] = False
51
51
 
52
52
  session_summaries: Optional[bool] = False
53
- num_history_runs: Optional[int] = 3
53
+ num_history_runs: Optional[int] = 10
54
54
  max_tool_calls_from_history: Optional[int] = 0
55
55
  tool_call_limit: Optional[int] = None
56
56
  coordinate_mode: Optional[bool] = False
@@ -0,0 +1,27 @@
1
+ from enum import Enum
2
+ from typing import Optional
3
+
4
+ from xpander_sdk.models.shared import XPanderSharedModel
5
+
6
+ class LLMCredentialsKeyType(str, Enum):
7
+ XPander = "xpander"
8
+ Custom = "custom"
9
+
10
+ class LLMCredentials(XPanderSharedModel):
11
+ name: str
12
+ description: Optional[str] = None
13
+ value: str
14
+
15
+ class LLMModelProvider(Enum):
16
+ OpenAI = "openai"
17
+ NvidiaNIM = "nim"
18
+ AmazonBedrock = "amazon_bedrock"
19
+ HuggingFace = "huggingFace"
20
+ FriendliAI = "friendlyAI"
21
+ Anthropic = "anthropic"
22
+ GoogleGemini = "gemini"
23
+ Fireworks = "fireworks"
24
+ GoogleAIStudio = "google_ai_studio"
25
+ Helicone = "helicone"
26
+ OpenRouter = "open_router"
27
+ Nebius = "nebius"
@@ -0,0 +1,98 @@
1
+ """Models for notification configurations and credentials.
2
+
3
+ This module provides data models for configuring various notification channels
4
+ including email, Slack, and webhooks, along with their authentication details.
5
+ """
6
+
7
+ from typing import Dict, List, Literal, Optional, Union
8
+
9
+ from xpander_sdk.models.shared import XPanderSharedModel
10
+
11
+ class SlackCredentials(XPanderSharedModel):
12
+ """Slack API authentication credentials.
13
+
14
+ Attributes:
15
+ authed_user_id: Authenticated user's Slack ID.
16
+ access_token: OAuth access token for API calls.
17
+ client_id: Slack app client ID.
18
+ client_secret: Slack app client secret.
19
+ verification_token: Token for verifying requests from Slack.
20
+ signing_secret: Secret for validating webhook signatures.
21
+ app_configuration_token: Token for app configuration.
22
+ app_configuration_refresh_token: Refresh token for app configuration.
23
+ """
24
+
25
+ authed_user_id: Optional[str] = None
26
+ access_token: Optional[str] = None
27
+ client_id: Optional[str] = None
28
+ client_secret: Optional[str] = None
29
+ verification_token: Optional[str] = None
30
+ signing_secret: Optional[str] = None
31
+ app_configuration_token: Optional[str] = None
32
+ app_configuration_refresh_token: Optional[str] = None
33
+
34
+ class NotificationSettingsBase(XPanderSharedModel):
35
+ """Base class for notification settings with common customization fields.
36
+
37
+ Attributes:
38
+ subject_suffix: Optional suffix to append to notification subjects.
39
+ body_prefix: Optional prefix to prepend to notification bodies.
40
+ """
41
+
42
+ subject_suffix: Optional[str] = None
43
+ body_prefix: Optional[str] = None
44
+
45
+ class EmailNotificationSettings(NotificationSettingsBase):
46
+ """Configuration for email notifications.
47
+
48
+ Attributes:
49
+ to: List of recipient email addresses.
50
+ """
51
+
52
+ to: List[str]
53
+
54
+ class SlackNotificationSettings(NotificationSettingsBase):
55
+ """Configuration for Slack notifications.
56
+
57
+ Attributes:
58
+ channels: List of Slack channel IDs or names to post to.
59
+ credentials: Slack API authentication credentials.
60
+ """
61
+
62
+ channels: List[str]
63
+ credentials: SlackCredentials
64
+
65
+ class WebhookNotificationSettings(NotificationSettingsBase):
66
+ """Configuration for webhook notifications.
67
+
68
+ Attributes:
69
+ url: Target webhook URL to POST notification data.
70
+ headers: Optional HTTP headers to include in the webhook request.
71
+ """
72
+
73
+ url: str
74
+ headers: Optional[Dict[str, str]] = {}
75
+
76
+ NotificationType = Literal["email", "slack", "webhook"]
77
+ """Supported notification channel types."""
78
+
79
+ NotificationDetails = Union[
80
+ EmailNotificationSettings,
81
+ SlackNotificationSettings,
82
+ WebhookNotificationSettings,
83
+ ]
84
+ """Union type for all notification detail configurations."""
85
+
86
+
87
+ class NotificationSettings(XPanderSharedModel):
88
+ """Configuration for event-based notifications.
89
+
90
+ Attributes:
91
+ on_success: Notifications to send when an operation succeeds.
92
+ Maps notification types to a list of notification configurations.
93
+ on_error: Notifications to send when an operation fails.
94
+ Maps notification types to a list of notification configurations.
95
+ """
96
+
97
+ on_success: Optional[Dict[NotificationType, List[NotificationDetails]]] = {}
98
+ on_error: Optional[Dict[NotificationType, List[NotificationDetails]]] = {}
@@ -0,0 +1,271 @@
1
+ """Models for orchestration workflows and node definitions.
2
+
3
+ This module provides data models for building and managing orchestration workflows,
4
+ including various node types, execution strategies, and control flow conditions.
5
+ """
6
+
7
+ from enum import Enum
8
+ from typing import Dict, List, Literal, Optional, Union
9
+ from uuid import uuid4
10
+
11
+ from pydantic import Field
12
+
13
+ from xpander_sdk.models.generic import (
14
+ LLMCredentials,
15
+ LLMCredentialsKeyType,
16
+ LLMModelProvider,
17
+ )
18
+ from xpander_sdk.models.shared import OutputFormat
19
+ from xpander_sdk.models.notifications import NotificationDetails
20
+ from xpander_sdk.models.shared import XPanderSharedModel
21
+
22
+ class OrchestrationNodeType(str, Enum):
23
+ """Types of nodes available in an orchestration workflow.
24
+
25
+ Attributes:
26
+ CustomFunction: Node that executes a custom function.
27
+ Code: Node that executes arbitrary code.
28
+ Agent: Node that invokes an AI agent.
29
+ Orchestration: Node that references another orchestration.
30
+ Classifier: Node that classifies inputs using LLM.
31
+ Wait: Node that pauses execution until a condition is met.
32
+ Action: Node that triggers an action (api).
33
+ """
34
+
35
+ CustomFunction = "custom_function"
36
+ Code = "code"
37
+ Agent = "agent"
38
+ Orchestration = "orchestration"
39
+ Classifier = "classifier"
40
+ Wait = "wait"
41
+ Action = "action"
42
+
43
+ class OrchestrationConditionType(str, Enum):
44
+ """Types of conditions for orchestration control flow.
45
+
46
+ Attributes:
47
+ Regex: Condition based on regular expression matching.
48
+ Contains: Condition based on substring containment.
49
+ """
50
+
51
+ Regex = "regex"
52
+ Contains = "contains"
53
+
54
+ class OrchestrationWaitNodeType(str, Enum):
55
+ """Types of wait nodes in orchestration workflows.
56
+
57
+ Attributes:
58
+ Webhook: Wait for an external webhook call.
59
+ HITL: Wait for human-in-the-loop interaction.
60
+ """
61
+
62
+ Webhook = "webhook"
63
+ HITL = "hitl"
64
+
65
+ class OrchestrationCondition(XPanderSharedModel):
66
+ """Condition for controlling orchestration flow.
67
+
68
+ Attributes:
69
+ type: Type of condition (regex or contains).
70
+ term: The pattern or string to match against.
71
+ """
72
+
73
+ type: OrchestrationConditionType
74
+ term: str
75
+
76
+ class OrchestrationRetryStrategy(XPanderSharedModel):
77
+ """Strategy for retrying failed orchestration nodes.
78
+
79
+ Attributes:
80
+ enabled: Whether retry is enabled for this node.
81
+ max_retries: Maximum number of retry attempts. Defaults to 3.
82
+ """
83
+
84
+ enabled: Optional[bool] = False
85
+ max_retries: Optional[int] = 3
86
+
87
+ class OrchestrationIterativeStrategy(XPanderSharedModel):
88
+ """Strategy for iteratively executing orchestration nodes.
89
+
90
+ Attributes:
91
+ enabled: Whether iterative execution is enabled.
92
+ max_iterations: Maximum number of iterations. Defaults to 3.
93
+ end_condition: Optional condition to stop iteration early.
94
+ """
95
+
96
+ enabled: Optional[bool] = False
97
+ max_iterations: Optional[int] = 3
98
+ end_condition: Optional[OrchestrationCondition] = None
99
+
100
+ class OrchestrationStopStrategy(XPanderSharedModel):
101
+ """Strategy for stopping orchestration execution.
102
+
103
+ Attributes:
104
+ enabled: Whether the stop strategy is enabled.
105
+ stop_on_failure: Whether to stop the entire orchestration on node failure.
106
+ stop_on_condition: Optional condition that will stop execution if met.
107
+ """
108
+
109
+ enabled: Optional[bool] = False
110
+ stop_on_failure: Optional[bool] = True
111
+ stop_on_condition: Optional[OrchestrationCondition] = None
112
+
113
+ class OrchestrationClassifierNodeLLMSettings(XPanderSharedModel):
114
+ """LLM configuration for classifier nodes.
115
+
116
+ Attributes:
117
+ model_provider: The LLM provider to use. Defaults to OpenAI.
118
+ model_name: Specific model identifier. Defaults to "gpt-5.2".
119
+ llm_credentials_key: Key identifier for stored credentials.
120
+ llm_credentials_key_type: Type of credential key storage. Defaults to XPander.
121
+ llm_credentials: Direct credential object if not using stored credentials.
122
+ """
123
+
124
+ model_provider: Optional[LLMModelProvider] = LLMModelProvider.OpenAI
125
+ model_name: Optional[str] = "gpt-5.2"
126
+ llm_credentials_key: Optional[str] = None
127
+ llm_credentials_key_type: Optional[LLMCredentialsKeyType] = (
128
+ LLMCredentialsKeyType.XPander
129
+ )
130
+ llm_credentials: Optional[LLMCredentials] = None
131
+
132
+ class OrchestrationPointerNode(XPanderSharedModel):
133
+ """Node that references an external asset (agent, function, or orchestration).
134
+
135
+ Attributes:
136
+ asset_id: Unique identifier of the asset to execute.
137
+ type: Type of asset being referenced.
138
+ output_type: Expected output format. Defaults to Text.
139
+ output_schema: JSON schema for structured output validation.
140
+ instructions: Optional instructions for the pointer node (Action only).
141
+ ignore_response: Should ignore the node result and proceed with previous result?.
142
+ """
143
+
144
+ asset_id: str
145
+ type: Literal[
146
+ OrchestrationNodeType.Agent,
147
+ OrchestrationNodeType.CustomFunction,
148
+ OrchestrationNodeType.Orchestration,
149
+ OrchestrationNodeType.Action,
150
+ ]
151
+
152
+ output_type: Optional[OutputFormat] = OutputFormat.Text
153
+ output_schema: Optional[Dict] = None
154
+ instructions: Optional[str] = None
155
+ ignore_response: Optional[bool] = False
156
+
157
+ class OrchestrationClassifierNode(XPanderSharedModel):
158
+ """Node that uses LLM to classify or transform inputs.
159
+
160
+ Attributes:
161
+ output_type: Expected output format. Defaults to Text.
162
+ output_schema: JSON schema for structured output validation.
163
+ instructions: Classification or transformation instructions for the LLM.
164
+ examples: Example inputs/outputs to guide the LLM behavior.
165
+ settings: LLM configuration settings.
166
+ """
167
+
168
+ output_type: Optional[OutputFormat] = OutputFormat.Text
169
+ output_schema: Optional[Dict] = None
170
+ instructions: Optional[str] = None
171
+ examples: Optional[List[str]] = []
172
+ settings: OrchestrationClassifierNodeLLMSettings
173
+
174
+ class OrchestrationGuardrailNode(XPanderSharedModel):
175
+ """Node that uses LLM to evaluate input and enforce guardrails.
176
+
177
+ This node can stop execution if the guardrail check fails.
178
+
179
+ Attributes:
180
+ instructions: Evaluation instructions for the LLM to assess the input.
181
+ examples: Example inputs/outputs to guide the LLM behavior.
182
+ settings: LLM configuration settings.
183
+ stop_on_false: Whether to stop execution if the guardrail check fails. Defaults to True.
184
+ """
185
+
186
+ instructions: str
187
+ examples: Optional[List[str]] = []
188
+ settings: OrchestrationClassifierNodeLLMSettings
189
+ stop_on_false: Optional[bool] = True
190
+
191
+ class OrchestrationSummarizerNode(XPanderSharedModel):
192
+ """Node that processes large payloads and answers specific questions.
193
+
194
+ This node uses an LLM to summarize or extract information from large inputs.
195
+
196
+ Attributes:
197
+ instructions: Summarization or question-answering instructions for the LLM.
198
+ examples: Example inputs/outputs to guide the LLM behavior.
199
+ settings: LLM configuration settings.
200
+ """
201
+
202
+ instructions: str
203
+ examples: Optional[List[str]] = []
204
+ settings: OrchestrationClassifierNodeLLMSettings
205
+
206
+ class OrchestrationCodeNode(XPanderSharedModel):
207
+ """Node that executes arbitrary code.
208
+
209
+ Attributes:
210
+ code: The code string to execute.
211
+ """
212
+
213
+ code: str
214
+
215
+ class OrchestrationWaitNode(XPanderSharedModel):
216
+ """Node that pauses execution until an external event occurs.
217
+
218
+ Attributes:
219
+ type: Type of wait event (webhook or human-in-the-loop).
220
+ definition: Notification configuration for triggering continuation.
221
+ """
222
+
223
+ type: Literal[OrchestrationWaitNodeType.Webhook, OrchestrationWaitNodeType.HITL]
224
+ definition: NotificationDetails
225
+
226
+ class OrchestrationNode(XPanderSharedModel):
227
+ """A node in an orchestration workflow.
228
+
229
+ Represents a single execution unit in an orchestration with control flow,
230
+ execution strategies, and a specific node type definition.
231
+
232
+ Attributes:
233
+ id: Unique identifier for the node. Auto-generated if not provided.
234
+ next_node_ids: List of IDs of the next nodes to execute in the workflow (supports branching).
235
+ name: Human-readable name for the node.
236
+ description: Detailed description of the node's purpose.
237
+ condition: Conditional logic for executing this node.
238
+ retry_strategy: Strategy for retrying failed executions.
239
+ iterative_strategy: Strategy for iterative execution.
240
+ stop_strategy: Strategy for stopping the workflow.
241
+ definition: The actual node implementation (code, classifier, pointer, or wait).
242
+ input_type: Expected input format. Defaults to Text.
243
+ input_schema: JSON schema for structured input validation.
244
+ input_instructions: Instructions to use for structured input.
245
+ """
246
+
247
+ id: str = Field(default_factory=lambda: str(uuid4()))
248
+ next_node_ids: List[str] = Field(default_factory=list)
249
+ name: Optional[str] = None
250
+ description: Optional[str] = None
251
+ condition: Optional[OrchestrationCondition] = None
252
+ retry_strategy: Optional[OrchestrationRetryStrategy] = Field(
253
+ default_factory=OrchestrationRetryStrategy
254
+ )
255
+ iterative_strategy: Optional[OrchestrationIterativeStrategy] = Field(
256
+ default_factory=OrchestrationIterativeStrategy
257
+ )
258
+ stop_strategy: Optional[OrchestrationStopStrategy] = Field(
259
+ default_factory=OrchestrationStopStrategy
260
+ )
261
+ definition: Union[
262
+ OrchestrationCodeNode,
263
+ OrchestrationClassifierNode,
264
+ OrchestrationPointerNode,
265
+ OrchestrationWaitNode,
266
+ OrchestrationGuardrailNode,
267
+ OrchestrationSummarizerNode,
268
+ ]
269
+ input_type: Optional[OutputFormat] = OutputFormat.Text
270
+ input_schema: Optional[Dict] = None
271
+ input_instructions: Optional[str] = None
@@ -10,6 +10,7 @@ from enum import Enum
10
10
  from typing import Dict, List, Literal, Optional, Type
11
11
  from pydantic import BaseModel, computed_field
12
12
 
13
+ from xpander_sdk.models.orchestrations import OrchestrationIterativeStrategy, OrchestrationRetryStrategy, OrchestrationStopStrategy
13
14
  from xpander_sdk.models.shared import XPanderSharedModel
14
15
  from xpander_sdk.modules.tools_repository.models.mcp import MCPServerDetails
15
16
 
@@ -420,12 +421,14 @@ class AgentType(str, Enum):
420
421
  Regular: Standard agent for individual task execution.
421
422
  A2A: Agent that is used via A2A protocol.
422
423
  Curl: Custom Agent that is used via curl.
424
+ Orchestration: marks the agent as an Orchestration object.
423
425
  """
424
426
 
425
427
  Manager = "manager"
426
428
  Regular = "regular"
427
429
  A2A = "a2a"
428
430
  Curl = "curl"
431
+ Orchestration = "orchestration"
429
432
 
430
433
 
431
434
  @dataclass
@@ -471,7 +474,7 @@ class AgentOutput(BaseModel):
471
474
  is_markdown: Optional[bool] = False
472
475
  use_json_mode: Optional[bool] = False
473
476
 
474
- class LLMCredentials(XPanderSharedModel):
475
- name: str
476
- description: Optional[str] = None
477
- value: str
477
+ class TaskLevelStrategies(XPanderSharedModel):
478
+ retry_strategy: Optional[OrchestrationRetryStrategy] = None
479
+ iterative_strategy: Optional[OrchestrationIterativeStrategy] = None
480
+ stop_strategy: Optional[OrchestrationStopStrategy] = None