letta-nightly 0.12.1.dev20251024104217__py3-none-any.whl → 0.13.0.dev20251024223017__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 letta-nightly might be problematic. Click here for more details.

Files changed (159) hide show
  1. letta/__init__.py +2 -3
  2. letta/adapters/letta_llm_adapter.py +1 -0
  3. letta/adapters/simple_llm_request_adapter.py +8 -5
  4. letta/adapters/simple_llm_stream_adapter.py +22 -6
  5. letta/agents/agent_loop.py +10 -3
  6. letta/agents/base_agent.py +4 -1
  7. letta/agents/helpers.py +41 -9
  8. letta/agents/letta_agent.py +11 -10
  9. letta/agents/letta_agent_v2.py +47 -37
  10. letta/agents/letta_agent_v3.py +395 -300
  11. letta/agents/voice_agent.py +8 -6
  12. letta/agents/voice_sleeptime_agent.py +3 -3
  13. letta/constants.py +30 -7
  14. letta/errors.py +20 -0
  15. letta/functions/function_sets/base.py +55 -3
  16. letta/functions/mcp_client/types.py +33 -57
  17. letta/functions/schema_generator.py +135 -23
  18. letta/groups/sleeptime_multi_agent_v3.py +6 -11
  19. letta/groups/sleeptime_multi_agent_v4.py +227 -0
  20. letta/helpers/converters.py +78 -4
  21. letta/helpers/crypto_utils.py +6 -2
  22. letta/interfaces/anthropic_parallel_tool_call_streaming_interface.py +9 -11
  23. letta/interfaces/anthropic_streaming_interface.py +3 -4
  24. letta/interfaces/gemini_streaming_interface.py +4 -6
  25. letta/interfaces/openai_streaming_interface.py +63 -28
  26. letta/llm_api/anthropic_client.py +7 -4
  27. letta/llm_api/deepseek_client.py +6 -4
  28. letta/llm_api/google_ai_client.py +3 -12
  29. letta/llm_api/google_vertex_client.py +1 -1
  30. letta/llm_api/helpers.py +90 -61
  31. letta/llm_api/llm_api_tools.py +4 -1
  32. letta/llm_api/openai.py +12 -12
  33. letta/llm_api/openai_client.py +53 -16
  34. letta/local_llm/constants.py +4 -3
  35. letta/local_llm/json_parser.py +5 -2
  36. letta/local_llm/utils.py +2 -3
  37. letta/log.py +171 -7
  38. letta/orm/agent.py +43 -9
  39. letta/orm/archive.py +4 -0
  40. letta/orm/custom_columns.py +15 -0
  41. letta/orm/identity.py +11 -11
  42. letta/orm/mcp_server.py +9 -0
  43. letta/orm/message.py +6 -1
  44. letta/orm/run_metrics.py +7 -2
  45. letta/orm/sqlalchemy_base.py +2 -2
  46. letta/orm/tool.py +3 -0
  47. letta/otel/tracing.py +2 -0
  48. letta/prompts/prompt_generator.py +7 -2
  49. letta/schemas/agent.py +41 -10
  50. letta/schemas/agent_file.py +3 -0
  51. letta/schemas/archive.py +4 -2
  52. letta/schemas/block.py +2 -1
  53. letta/schemas/enums.py +36 -3
  54. letta/schemas/file.py +3 -3
  55. letta/schemas/folder.py +2 -1
  56. letta/schemas/group.py +2 -1
  57. letta/schemas/identity.py +18 -9
  58. letta/schemas/job.py +3 -1
  59. letta/schemas/letta_message.py +71 -12
  60. letta/schemas/letta_request.py +7 -3
  61. letta/schemas/letta_stop_reason.py +0 -25
  62. letta/schemas/llm_config.py +8 -2
  63. letta/schemas/mcp.py +80 -83
  64. letta/schemas/mcp_server.py +349 -0
  65. letta/schemas/memory.py +20 -8
  66. letta/schemas/message.py +212 -67
  67. letta/schemas/providers/anthropic.py +13 -6
  68. letta/schemas/providers/azure.py +6 -4
  69. letta/schemas/providers/base.py +8 -4
  70. letta/schemas/providers/bedrock.py +6 -2
  71. letta/schemas/providers/cerebras.py +7 -3
  72. letta/schemas/providers/deepseek.py +2 -1
  73. letta/schemas/providers/google_gemini.py +15 -6
  74. letta/schemas/providers/groq.py +2 -1
  75. letta/schemas/providers/lmstudio.py +9 -6
  76. letta/schemas/providers/mistral.py +2 -1
  77. letta/schemas/providers/openai.py +7 -2
  78. letta/schemas/providers/together.py +9 -3
  79. letta/schemas/providers/xai.py +7 -3
  80. letta/schemas/run.py +7 -2
  81. letta/schemas/run_metrics.py +2 -1
  82. letta/schemas/sandbox_config.py +2 -2
  83. letta/schemas/secret.py +3 -158
  84. letta/schemas/source.py +2 -2
  85. letta/schemas/step.py +2 -2
  86. letta/schemas/tool.py +24 -1
  87. letta/schemas/usage.py +0 -1
  88. letta/server/rest_api/app.py +123 -7
  89. letta/server/rest_api/dependencies.py +3 -0
  90. letta/server/rest_api/interface.py +7 -4
  91. letta/server/rest_api/redis_stream_manager.py +16 -1
  92. letta/server/rest_api/routers/v1/__init__.py +7 -0
  93. letta/server/rest_api/routers/v1/agents.py +332 -322
  94. letta/server/rest_api/routers/v1/archives.py +127 -40
  95. letta/server/rest_api/routers/v1/blocks.py +54 -6
  96. letta/server/rest_api/routers/v1/chat_completions.py +146 -0
  97. letta/server/rest_api/routers/v1/folders.py +27 -35
  98. letta/server/rest_api/routers/v1/groups.py +23 -35
  99. letta/server/rest_api/routers/v1/identities.py +24 -10
  100. letta/server/rest_api/routers/v1/internal_runs.py +107 -0
  101. letta/server/rest_api/routers/v1/internal_templates.py +162 -179
  102. letta/server/rest_api/routers/v1/jobs.py +15 -27
  103. letta/server/rest_api/routers/v1/mcp_servers.py +309 -0
  104. letta/server/rest_api/routers/v1/messages.py +23 -34
  105. letta/server/rest_api/routers/v1/organizations.py +6 -27
  106. letta/server/rest_api/routers/v1/providers.py +35 -62
  107. letta/server/rest_api/routers/v1/runs.py +30 -43
  108. letta/server/rest_api/routers/v1/sandbox_configs.py +6 -4
  109. letta/server/rest_api/routers/v1/sources.py +26 -42
  110. letta/server/rest_api/routers/v1/steps.py +16 -29
  111. letta/server/rest_api/routers/v1/tools.py +17 -13
  112. letta/server/rest_api/routers/v1/users.py +5 -17
  113. letta/server/rest_api/routers/v1/voice.py +18 -27
  114. letta/server/rest_api/streaming_response.py +5 -2
  115. letta/server/rest_api/utils.py +187 -25
  116. letta/server/server.py +27 -22
  117. letta/server/ws_api/server.py +5 -4
  118. letta/services/agent_manager.py +148 -26
  119. letta/services/agent_serialization_manager.py +6 -1
  120. letta/services/archive_manager.py +168 -15
  121. letta/services/block_manager.py +14 -4
  122. letta/services/file_manager.py +33 -29
  123. letta/services/group_manager.py +10 -0
  124. letta/services/helpers/agent_manager_helper.py +65 -11
  125. letta/services/identity_manager.py +105 -4
  126. letta/services/job_manager.py +11 -1
  127. letta/services/mcp/base_client.py +2 -2
  128. letta/services/mcp/oauth_utils.py +33 -8
  129. letta/services/mcp_manager.py +174 -78
  130. letta/services/mcp_server_manager.py +1331 -0
  131. letta/services/message_manager.py +109 -4
  132. letta/services/organization_manager.py +4 -4
  133. letta/services/passage_manager.py +9 -25
  134. letta/services/provider_manager.py +91 -15
  135. letta/services/run_manager.py +72 -15
  136. letta/services/sandbox_config_manager.py +45 -3
  137. letta/services/source_manager.py +15 -8
  138. letta/services/step_manager.py +24 -1
  139. letta/services/streaming_service.py +581 -0
  140. letta/services/summarizer/summarizer.py +1 -1
  141. letta/services/tool_executor/core_tool_executor.py +111 -0
  142. letta/services/tool_executor/files_tool_executor.py +5 -3
  143. letta/services/tool_executor/sandbox_tool_executor.py +2 -2
  144. letta/services/tool_executor/tool_execution_manager.py +1 -1
  145. letta/services/tool_manager.py +10 -3
  146. letta/services/tool_sandbox/base.py +61 -1
  147. letta/services/tool_sandbox/local_sandbox.py +1 -3
  148. letta/services/user_manager.py +2 -2
  149. letta/settings.py +49 -5
  150. letta/system.py +14 -5
  151. letta/utils.py +73 -1
  152. letta/validators.py +105 -0
  153. {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/METADATA +4 -2
  154. {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/RECORD +157 -151
  155. letta/schemas/letta_ping.py +0 -28
  156. letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
  157. {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/WHEEL +0 -0
  158. {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/entry_points.txt +0 -0
  159. {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/licenses/LICENSE +0 -0
letta/validators.py ADDED
@@ -0,0 +1,105 @@
1
+ import inspect
2
+ import re
3
+ from functools import wraps
4
+ from typing import Annotated
5
+
6
+ from fastapi import Path
7
+
8
+ from letta.errors import LettaInvalidArgumentError
9
+ from letta.schemas.enums import PrimitiveType # PrimitiveType is now in schemas.enums
10
+
11
+ # Map from PrimitiveType to the actual prefix string (which is just the enum value)
12
+ PRIMITIVE_ID_PREFIXES = {primitive_type: primitive_type.value for primitive_type in PrimitiveType}
13
+
14
+
15
+ PRIMITIVE_ID_PATTERNS = {
16
+ # f-string interpolation gets confused because of the regex's required curly braces {}
17
+ prefix: re.compile("^" + prefix + "-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
18
+ for prefix in PRIMITIVE_ID_PREFIXES.values()
19
+ }
20
+
21
+
22
+ def _create_path_validator_factory(primitive: str):
23
+ """
24
+ Creates a factory function that returns a fresh Path validator.
25
+
26
+ This avoids shared state issues when the same validator is used
27
+ across multiple endpoints with different parameter names.
28
+ """
29
+
30
+ def factory():
31
+ return Path(
32
+ description=f"The ID of the {primitive} in the format '{primitive}-<uuid4>'",
33
+ pattern=PRIMITIVE_ID_PATTERNS[primitive].pattern,
34
+ examples=[f"{primitive}-123e4567-e89b-42d3-8456-426614174000"],
35
+ min_length=len(primitive) + 1 + 36,
36
+ max_length=len(primitive) + 1 + 36,
37
+ )
38
+
39
+ return factory
40
+
41
+
42
+ # PATH_VALIDATORS now contains factory functions, not Path objects
43
+ # Usage: folder_id: str = PATH_VALIDATORS[PrimitiveType.FOLDER.value]()
44
+ PATH_VALIDATORS = {primitive_type.value: _create_path_validator_factory(primitive_type.value) for primitive_type in PrimitiveType}
45
+
46
+
47
+ # Type aliases for common ID types
48
+ # These can be used directly in route handler signatures for cleaner code
49
+ AgentId = Annotated[str, PATH_VALIDATORS[PrimitiveType.AGENT.value]()]
50
+ ToolId = Annotated[str, PATH_VALIDATORS[PrimitiveType.TOOL.value]()]
51
+ SourceId = Annotated[str, PATH_VALIDATORS[PrimitiveType.SOURCE.value]()]
52
+ BlockId = Annotated[str, PATH_VALIDATORS[PrimitiveType.BLOCK.value]()]
53
+ MessageId = Annotated[str, PATH_VALIDATORS[PrimitiveType.MESSAGE.value]()]
54
+ RunId = Annotated[str, PATH_VALIDATORS[PrimitiveType.RUN.value]()]
55
+ JobId = Annotated[str, PATH_VALIDATORS[PrimitiveType.JOB.value]()]
56
+ GroupId = Annotated[str, PATH_VALIDATORS[PrimitiveType.GROUP.value]()]
57
+ FileId = Annotated[str, PATH_VALIDATORS[PrimitiveType.FILE.value]()]
58
+ FolderId = Annotated[str, PATH_VALIDATORS[PrimitiveType.FOLDER.value]()]
59
+ ArchiveId = Annotated[str, PATH_VALIDATORS[PrimitiveType.ARCHIVE.value]()]
60
+ PassageId = Annotated[str, PATH_VALIDATORS[PrimitiveType.PASSAGE.value]()]
61
+ ProviderId = Annotated[str, PATH_VALIDATORS[PrimitiveType.PROVIDER.value]()]
62
+ SandboxConfigId = Annotated[str, PATH_VALIDATORS[PrimitiveType.SANDBOX_CONFIG.value]()]
63
+ StepId = Annotated[str, PATH_VALIDATORS[PrimitiveType.STEP.value]()]
64
+ IdentityId = Annotated[str, PATH_VALIDATORS[PrimitiveType.IDENTITY.value]()]
65
+
66
+
67
+ def raise_on_invalid_id(param_name: str, expected_prefix: PrimitiveType):
68
+ """
69
+ Decorator that validates an ID parameter has the expected prefix format.
70
+ Can be stacked multiple times on the same function to validate different IDs.
71
+
72
+ Args:
73
+ param_name: The name of the function parameter to validate (e.g., "agent_id")
74
+ expected_prefix: The expected primitive type (e.g., PrimitiveType.AGENT)
75
+
76
+ Example:
77
+ @raise_on_invalid_id(param_name="agent_id", expected_prefix=PrimitiveType.AGENT)
78
+ @raise_on_invalid_id(param_name="folder_id", expected_prefix=PrimitiveType.FOLDER)
79
+ def my_function(agent_id: str, folder_id: str):
80
+ pass
81
+ """
82
+
83
+ def decorator(function):
84
+ @wraps(function)
85
+ def wrapper(*args, **kwargs):
86
+ sig = inspect.signature(function)
87
+ bound_args = sig.bind(*args, **kwargs)
88
+ bound_args.apply_defaults()
89
+
90
+ if param_name in bound_args.arguments:
91
+ arg_value = bound_args.arguments[param_name]
92
+
93
+ if arg_value is not None:
94
+ prefix = PRIMITIVE_ID_PREFIXES[expected_prefix]
95
+ if PRIMITIVE_ID_PATTERNS[prefix].match(arg_value) is None:
96
+ raise LettaInvalidArgumentError(
97
+ message=f"Invalid {expected_prefix.value} ID format: {arg_value}. Expected format: '{prefix}-<uuid4>'",
98
+ argument_name=param_name,
99
+ )
100
+
101
+ return function(*args, **kwargs)
102
+
103
+ return wrapper
104
+
105
+ return decorator
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: letta-nightly
3
- Version: 0.12.1.dev20251024104217
3
+ Version: 0.13.0.dev20251024223017
4
4
  Summary: Create LLM agents with long-term memory and custom tools
5
5
  Author-email: Letta Team <contact@letta.com>
6
6
  License: Apache License
@@ -99,7 +99,6 @@ Requires-Dist: pytest-json-report>=1.5.0; extra == 'dev'
99
99
  Requires-Dist: pytest-mock>=3.14.0; extra == 'dev'
100
100
  Requires-Dist: pytest-order>=1.2.0; extra == 'dev'
101
101
  Provides-Extra: experimental
102
- Requires-Dist: google-cloud-profiler>=4.1.0; extra == 'experimental'
103
102
  Requires-Dist: granian[reload,uvloop]>=2.3.2; extra == 'experimental'
104
103
  Requires-Dist: uvloop>=0.21.0; extra == 'experimental'
105
104
  Provides-Extra: external-tools
@@ -119,6 +118,9 @@ Requires-Dist: pg8000>=1.30.3; extra == 'postgres'
119
118
  Requires-Dist: pgvector>=0.2.3; extra == 'postgres'
120
119
  Requires-Dist: psycopg2-binary>=2.9.10; extra == 'postgres'
121
120
  Requires-Dist: psycopg2>=2.9.10; extra == 'postgres'
121
+ Provides-Extra: profiling
122
+ Requires-Dist: ddtrace>=2.18.2; extra == 'profiling'
123
+ Requires-Dist: google-cloud-profiler>=4.1.0; extra == 'profiling'
122
124
  Provides-Extra: redis
123
125
  Requires-Dist: redis>=6.2.0; extra == 'redis'
124
126
  Provides-Extra: server