xpander-sdk 2.0.206__py3-none-any.whl → 2.0.208__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.
@@ -475,6 +475,32 @@ class AgentOutput(BaseModel):
475
475
  use_json_mode: Optional[bool] = False
476
476
 
477
477
  class TaskLevelStrategies(XPanderSharedModel):
478
+ """
479
+ Configuration object for task-level execution strategies.
480
+
481
+ This model groups optional strategy configurations that control how a task is
482
+ executed and managed over time, including retries, iterative execution,
483
+ stopping conditions, and daily run limits.
484
+
485
+ Attributes:
486
+ retry_strategy:
487
+ Optional retry policy configuration that defines how the task should
488
+ behave when execution fails (e.g., max attempts, backoff rules).
489
+
490
+ iterative_strategy:
491
+ Optional iterative execution configuration for tasks that may run in
492
+ repeated cycles/steps until completion or a stop condition is met.
493
+
494
+ stop_strategy:
495
+ Optional stopping policy configuration that defines when the task
496
+ should stop running (e.g., timeout, max iterations, success criteria).
497
+
498
+ max_runs_per_day:
499
+ Optional limit on how many times the task is allowed to run within a
500
+ 24-hour period. If not set, no explicit daily limit is enforced.
501
+ """
502
+
478
503
  retry_strategy: Optional[OrchestrationRetryStrategy] = None
479
504
  iterative_strategy: Optional[OrchestrationIterativeStrategy] = None
480
- stop_strategy: Optional[OrchestrationStopStrategy] = None
505
+ stop_strategy: Optional[OrchestrationStopStrategy] = None
506
+ max_runs_per_day: Optional[int] = None
@@ -159,8 +159,33 @@ class ToolsRepository(XPanderSharedModel):
159
159
 
160
160
  for tool in self.list:
161
161
 
162
- # add json schema to the model doc
163
- tool.schema.__doc__ = "Pay attention to the schema, dont miss. " + json.dumps(tool.schema.model_json_schema(mode="serialization"))
162
+ # add json schema to the model doc with enhanced guidance
163
+ schema_json = tool.schema.model_json_schema(mode="serialization")
164
+
165
+ # Build example with actual schema structure
166
+ example_payload = {}
167
+ if 'properties' in schema_json:
168
+ for prop_name, prop_def in schema_json['properties'].items():
169
+ if prop_def.get('type') == 'object':
170
+ if prop_def.get('properties'):
171
+ # Show one example nested field
172
+ first_nested = list(prop_def['properties'].keys())[0]
173
+ example_payload[prop_name] = {first_nested: "<value>"}
174
+ else:
175
+ example_payload[prop_name] = {}
176
+ else:
177
+ example_payload[prop_name] = f"<{prop_def.get('type', 'value')}>"
178
+
179
+ tool.schema.__doc__ = f"""CRITICAL: This entire schema must be wrapped in a 'payload' parameter.
180
+
181
+ Call this function as: function_name(payload={{...}})
182
+ DO NOT call as: function_name(body_params={{...}}, headers={{...}}, ...)
183
+
184
+ Example correct call:
185
+ {json.dumps({"payload": example_payload}, indent=2)}
186
+
187
+ Full schema: {json.dumps(schema_json, indent=2)}
188
+ """
164
189
 
165
190
  schema_cls: Type[BaseModel] = tool.schema
166
191
 
@@ -208,7 +233,44 @@ class ToolsRepository(XPanderSharedModel):
208
233
 
209
234
  # --- Metadata ---
210
235
  tool_function.__name__ = tool_ref.id
211
- tool_function.__doc__ = tool_ref.description or tool_ref.name
236
+
237
+ # Build comprehensive docstring with parameter structure guidance
238
+ base_doc = tool_ref.description or tool_ref.name
239
+
240
+ # Extract schema properties for examples
241
+ schema_props = schema_ref.model_json_schema().get('properties', {})
242
+ param_names = list(schema_props.keys())
243
+
244
+ # Create example structure
245
+ example_parts = []
246
+ for prop_name in param_names:
247
+ prop_info = schema_props.get(prop_name, {})
248
+ if prop_info.get('type') == 'object' and prop_info.get('properties'):
249
+ # Show nested structure
250
+ nested_props = list(prop_info['properties'].keys())
251
+ if nested_props:
252
+ example_parts.append(f'"{prop_name}": {{"{nested_props[0]}": ...}}')
253
+ else:
254
+ example_parts.append(f'"{prop_name}": {{}}')
255
+ else:
256
+ example_parts.append(f'"{prop_name}": ...')
257
+
258
+ example_json = "{" + ", ".join(example_parts) + "}"
259
+
260
+ tool_function.__doc__ = f"""{base_doc}
261
+
262
+ IMPORTANT - Parameter Structure:
263
+ All parameters must be passed as a single 'payload' object containing the required fields.
264
+
265
+ Correct usage example:
266
+ {{
267
+ "payload": {example_json}
268
+ }}
269
+
270
+ DO NOT pass parameters as separate top-level arguments.
271
+ DO NOT use: {{"{param_names[0] if param_names else 'param'}": ..., "{param_names[1] if len(param_names) > 1 else 'param2'}": ...}}
272
+ USE: {{"payload": {{"{param_names[0] if param_names else 'param'}": ..., "{param_names[1] if len(param_names) > 1 else 'param2'}": ..., ...}}}}
273
+ """
212
274
 
213
275
  # --- Signature ---
214
276
  payload_param = Parameter(
@@ -98,20 +98,24 @@ def build_model_from_schema(
98
98
 
99
99
  field_args = {}
100
100
 
101
- # Enhance description to clarify optional vs required status
101
+ # Enhance description to clarify optional vs required status AND nesting
102
102
  enhanced_description = description or f"Parameter: {prop_name}"
103
+
104
+ # Add payload wrapper reminder for top-level params
105
+ wrapper_note = " (must be inside payload object)"
106
+
103
107
  if is_empty_param_container:
104
- enhanced_description = f"[OPTIONAL - empty container] {enhanced_description} (default: empty object)"
108
+ enhanced_description = f"[OPTIONAL - empty container] {enhanced_description} (default: empty object){wrapper_note}"
105
109
  elif prop_name in required:
106
110
  if default is not None:
107
- enhanced_description = f"[REQUIRED with default] {enhanced_description} (default: {default})"
111
+ enhanced_description = f"[REQUIRED with default] {enhanced_description} (default: {default}){wrapper_note}"
108
112
  else:
109
- enhanced_description = f"[REQUIRED] {enhanced_description}"
113
+ enhanced_description = f"[REQUIRED] {enhanced_description}{wrapper_note}"
110
114
  else:
111
115
  if default is not None:
112
- enhanced_description = f"[OPTIONAL with default] {enhanced_description} (default: {default})"
116
+ enhanced_description = f"[OPTIONAL with default] {enhanced_description} (default: {default}){wrapper_note}"
113
117
  else:
114
- enhanced_description = f"[OPTIONAL] {enhanced_description} - can be omitted or set to null"
118
+ enhanced_description = f"[OPTIONAL] {enhanced_description} - can be omitted or set to null{wrapper_note}"
115
119
 
116
120
  field_args["description"] = enhanced_description
117
121
 
@@ -169,7 +173,16 @@ def build_model_from_schema(
169
173
  strict=False, # Allow flexibility with types to handle AI agent inputs better
170
174
  extra="allow",
171
175
  title=model_name,
172
- description="IMPORTANT: Required fields must be provided. Optional fields can be omitted entirely or set to null. All parameters with defaults will use those defaults if not provided. Check the 'required' array in the schema to see which fields are mandatory."
176
+ description="""CRITICAL - This schema must be wrapped in a 'payload' parameter.
177
+
178
+ CORRECT: Call function with {"payload": {<this_schema>}}
179
+ INCORRECT: Call function with {<this_schema>} directly
180
+
181
+ All fields shown below must be nested inside a 'payload' object when calling the function.
182
+
183
+ Required fields must be provided. Optional fields can be omitted entirely or set to null.
184
+ All parameters with defaults will use those defaults if not provided.
185
+ Check the 'required' array in the schema to see which fields are mandatory."""
173
186
  )
174
187
  return create_model(
175
188
  model_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xpander-sdk
3
- Version: 2.0.206
3
+ Version: 2.0.208
4
4
  Summary: xpander.ai Backend-as-a-service for AI Agents - SDK
5
5
  Home-page: https://www.xpander.ai
6
6
  Author: xpanderAI
@@ -23,7 +23,7 @@ xpander_sdk/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
23
23
  xpander_sdk/modules/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  xpander_sdk/modules/agents/agents_module.py,sha256=3EhKOIPb4c39GOrNt4zU4V6WbsGj7W_yWwRNSJBKmfc,6419
25
25
  xpander_sdk/modules/agents/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- xpander_sdk/modules/agents/models/agent.py,sha256=lHWz37a4_qB9Hq4sZhvjILjj566hJHZbDlj7JJ6iO68,15340
26
+ xpander_sdk/modules/agents/models/agent.py,sha256=K0ZIF_JA09Vz1I2QdBvbXoByz_OzUQtNH7eE5imQ_CA,16427
27
27
  xpander_sdk/modules/agents/models/agent_list.py,sha256=byEayS2uLwDKaVT3lAHltrFocQFKpr8XEwQ6NTEEEMo,4081
28
28
  xpander_sdk/modules/agents/models/knowledge_bases.py,sha256=YimpjVJxWe8YTbGMD6oGQOA_YV8ztHQHTTBOaBB44ZM,1037
29
29
  xpander_sdk/modules/agents/sub_modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -71,7 +71,7 @@ xpander_sdk/modules/tasks/sub_modules/task.py,sha256=zRDHsE_LnYYa3OC79wVQqeRnpAo
71
71
  xpander_sdk/modules/tasks/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  xpander_sdk/modules/tasks/utils/files.py,sha256=KqqwSQSrwim2-H3XP5wOadDDfngAyEI034tA7Oon-vc,3631
73
73
  xpander_sdk/modules/tools_repository/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- xpander_sdk/modules/tools_repository/tools_repository_module.py,sha256=HpiOtsJwIeyDqb1499X4FuRUdh8v-mQZQlQ2Zlgq1lY,9557
74
+ xpander_sdk/modules/tools_repository/tools_repository_module.py,sha256=Hck2dACK2O8BHPXfFdVY8xBMQGYSFrB-trVCJ15LKN4,12393
75
75
  xpander_sdk/modules/tools_repository/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  xpander_sdk/modules/tools_repository/decorators/register_tool.py,sha256=ep-BlJHmqvG7zcW6l-hz_V0ZJx3PGfNqdijw6VjUGek,4078
77
77
  xpander_sdk/modules/tools_repository/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -82,7 +82,7 @@ xpander_sdk/modules/tools_repository/sub_modules/tool.py,sha256=rivnznxi6CrrOWE1
82
82
  xpander_sdk/modules/tools_repository/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
83
  xpander_sdk/modules/tools_repository/utils/generic.py,sha256=bQ31-RoAq12lpDoIWsgmqAt7NL5YdzW1j3WKqZtYb2A,1904
84
84
  xpander_sdk/modules/tools_repository/utils/local_tools.py,sha256=zp5P8hVnRUJQb-w-2jCEMV5eUB_awmvYfY_rin5qvEw,1875
85
- xpander_sdk/modules/tools_repository/utils/schemas.py,sha256=EUi35h7CRrOVXV-TH-lyCpOdK5pu1uODDxvGB1JGDXY,13734
85
+ xpander_sdk/modules/tools_repository/utils/schemas.py,sha256=EAoxhkVmwtqPOm-FkXiQRDNmcrmcnEeXbw73k7PzvUk,14242
86
86
  xpander_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
87
  xpander_sdk/utils/env.py,sha256=U_zIhqWgKs5fk2-HXjAaODj4oWMc5dRQ0fvw6fqVcFk,1522
88
88
  xpander_sdk/utils/event_loop.py,sha256=kJrN0upgBhyI86tkTdfHeajznrIZl44Rl6WDiDG3GHE,2516
@@ -90,8 +90,8 @@ xpander_sdk/utils/generic.py,sha256=XrRj2-L8c0YWpfPdDyXE-pVL-6lKF9VpyZzKHQ4wuCc,
90
90
  xpander_sdk/utils/tools.py,sha256=lyFkq2yP7DxBkyXYVlnFRwDhQCvf0fZZMDm5fBycze4,1244
91
91
  xpander_sdk/utils/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
92
  xpander_sdk/utils/agents/compactization_agent.py,sha256=S_U1dSmDC7I0JUsp_THUYjfutEI5QMBaMPJEXGp0_Sw,14389
93
- xpander_sdk-2.0.206.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
94
- xpander_sdk-2.0.206.dist-info/METADATA,sha256=ATScz104ZRoYszw-HsRrYKEVKazK0FWrnwFlCT-J-u8,17952
95
- xpander_sdk-2.0.206.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
96
- xpander_sdk-2.0.206.dist-info/top_level.txt,sha256=UCjnxQpsMy5Zoe7lmRuVDO6DI2V_6PgRFfm4oizRbVs,12
97
- xpander_sdk-2.0.206.dist-info/RECORD,,
93
+ xpander_sdk-2.0.208.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
94
+ xpander_sdk-2.0.208.dist-info/METADATA,sha256=MSaI4iPo6_l9e4BOPwlT-4FtLI70FBqwihyjxFUBu9s,17952
95
+ xpander_sdk-2.0.208.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
96
+ xpander_sdk-2.0.208.dist-info/top_level.txt,sha256=UCjnxQpsMy5Zoe7lmRuVDO6DI2V_6PgRFfm4oizRbVs,12
97
+ xpander_sdk-2.0.208.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5