xpander-sdk 2.0.175__py3-none-any.whl → 2.0.177__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.
@@ -1,10 +1,11 @@
1
1
  import asyncio
2
+ import json
2
3
  import shlex
3
4
  from os import getenv, environ
4
5
  from typing import Any, Callable, Dict, List, Optional
5
6
 
6
7
  from loguru import logger
7
-
8
+ from toon import encode as toon_encode
8
9
  from xpander_sdk import Configuration
9
10
  from xpander_sdk.models.shared import OutputFormat, ThinkMode
10
11
  from xpander_sdk.modules.agents.agents_module import Agents
@@ -19,6 +20,7 @@ from xpander_sdk.modules.tools_repository.models.mcp import (
19
20
  MCPServerTransport,
20
21
  MCPServerType,
21
22
  )
23
+ from xpander_sdk.modules.tools_repository.models.tool_invocation_result import ToolInvocationResult
22
24
  from xpander_sdk.modules.tools_repository.sub_modules.tool import Tool
23
25
  from xpander_sdk.modules.tools_repository.utils.schemas import build_model_from_schema
24
26
  from agno.agent import Agent as AgnoAgent
@@ -199,6 +201,19 @@ async def build_agent_args(
199
201
  except Exception:
200
202
  pass
201
203
 
204
+ # try toon optimization if compression enabled
205
+ if xpander_agent and xpander_agent and xpander_agent.agno_settings and xpander_agent.agno_settings.tool_calls_compression and xpander_agent.agno_settings.tool_calls_compression.enabled and not function_name.startswith("xp"):
206
+ try:
207
+ if isinstance(result, ToolInvocationResult):
208
+ json_result = json.loads(result.result) if isinstance(result.result, str) else result.result
209
+ result.result = toon_encode(json_result)
210
+ elif hasattr(result, "content"):
211
+ json_result = json.loads(result.content)
212
+ result.content = toon_encode(json_result)
213
+ except Exception:
214
+ pass
215
+
216
+
202
217
  # Return the result
203
218
  return result
204
219
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xpander-sdk
3
- Version: 2.0.175
3
+ Version: 2.0.177
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
@@ -20,6 +20,7 @@ Requires-Dist: httpx_sse
20
20
  Requires-Dist: nest-asyncio
21
21
  Requires-Dist: strands-agents
22
22
  Requires-Dist: openai-agents
23
+ Requires-Dist: python-toon
23
24
  Provides-Extra: agno
24
25
  Requires-Dist: agno; extra == "agno"
25
26
  Requires-Dist: sqlalchemy; extra == "agno"
@@ -30,7 +30,7 @@ xpander_sdk/modules/agents/utils/generic.py,sha256=XbG4OeHMQo4gVYCsasMlW_b8OoqS1
30
30
  xpander_sdk/modules/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  xpander_sdk/modules/backend/backend_module.py,sha256=wYghMuNXEtXgoyMXBgbMhgE7wYcbRwXJcpEyybF30kA,18927
32
32
  xpander_sdk/modules/backend/frameworks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- xpander_sdk/modules/backend/frameworks/agno.py,sha256=ZhRwOdDlcvZMYqaMUrGKFRytHEdHwHhm5nBqBBtrD-U,40232
33
+ xpander_sdk/modules/backend/frameworks/agno.py,sha256=6rBi-3wUPmSd5n1hFdhigjiLZ8jM5clLXaxwKiKxOWA,41159
34
34
  xpander_sdk/modules/backend/frameworks/dispatch.py,sha256=5dP4c37C42U53VjM2kkwIRwEw1i0IN3G0YESHH7J3OE,1557
35
35
  xpander_sdk/modules/backend/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  xpander_sdk/modules/backend/utils/mcp_oauth.py,sha256=slmrtpjGM__g7mkhvnY9yNRtGHS-fDcLH82rIkBKxkA,4527
@@ -83,8 +83,8 @@ xpander_sdk/utils/generic.py,sha256=XrRj2-L8c0YWpfPdDyXE-pVL-6lKF9VpyZzKHQ4wuCc,
83
83
  xpander_sdk/utils/tools.py,sha256=lyFkq2yP7DxBkyXYVlnFRwDhQCvf0fZZMDm5fBycze4,1244
84
84
  xpander_sdk/utils/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
85
85
  xpander_sdk/utils/agents/compactization_agent.py,sha256=pqaf7LVSyPFaeXU62dMPY6iQ160TFga1KJ0Kgu1dIgg,14449
86
- xpander_sdk-2.0.175.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
87
- xpander_sdk-2.0.175.dist-info/METADATA,sha256=9Cc6PiPaGtxWvtSR57Hff1gGiCFh-MuA0ucCChOjDak,15312
88
- xpander_sdk-2.0.175.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
89
- xpander_sdk-2.0.175.dist-info/top_level.txt,sha256=UCjnxQpsMy5Zoe7lmRuVDO6DI2V_6PgRFfm4oizRbVs,12
90
- xpander_sdk-2.0.175.dist-info/RECORD,,
86
+ xpander_sdk-2.0.177.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
87
+ xpander_sdk-2.0.177.dist-info/METADATA,sha256=GkvjGLP9bKCx0eAFqpDmWBxc3ooZoizCbKHJRbd-cnw,15339
88
+ xpander_sdk-2.0.177.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
89
+ xpander_sdk-2.0.177.dist-info/top_level.txt,sha256=UCjnxQpsMy5Zoe7lmRuVDO6DI2V_6PgRFfm4oizRbVs,12
90
+ xpander_sdk-2.0.177.dist-info/RECORD,,