letta-nightly 0.8.11.dev20250708104317__py3-none-any.whl → 0.8.12.dev20250709104346__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.

letta/__init__.py CHANGED
@@ -5,8 +5,7 @@ try:
5
5
  __version__ = version("letta")
6
6
  except PackageNotFoundError:
7
7
  # Fallback for development installations
8
- __version__ = "0.8.11"
9
-
8
+ __version__ = "0.8.12"
10
9
 
11
10
  if os.environ.get("LETTA_VERSION"):
12
11
  __version__ = os.environ["LETTA_VERSION"]
@@ -6,6 +6,7 @@ from letta.agents.letta_agent_batch import LettaAgentBatch
6
6
  from letta.jobs.helpers import map_anthropic_batch_job_status_to_job_status, map_anthropic_individual_batch_item_status_to_job_status
7
7
  from letta.jobs.types import BatchPollingResult, ItemUpdateInfo
8
8
  from letta.log import get_logger
9
+ from letta.otel.tracing import trace_method
9
10
  from letta.schemas.enums import JobStatus, ProviderType
10
11
  from letta.schemas.letta_response import LettaBatchResponse
11
12
  from letta.schemas.llm_batch_job import LLMBatchJob
@@ -37,6 +38,7 @@ class BatchPollingMetrics:
37
38
  logger.info(f"[Poll BatchJob] Updated {self.updated_items_count} items for newly completed batch(es).")
38
39
 
39
40
 
41
+ @trace_method
40
42
  async def fetch_batch_status(server: SyncServer, batch_job: LLMBatchJob) -> BatchPollingResult:
41
43
  """
42
44
  Fetch the current status of a single batch job from the provider.
@@ -60,6 +62,7 @@ async def fetch_batch_status(server: SyncServer, batch_job: LLMBatchJob) -> Batc
60
62
  return BatchPollingResult(batch_job.id, JobStatus.running, None)
61
63
 
62
64
 
65
+ @trace_method
63
66
  async def fetch_batch_items(server: SyncServer, batch_id: str, batch_resp_id: str) -> List[ItemUpdateInfo]:
64
67
  """
65
68
  Fetch individual item results for a completed batch.
@@ -86,6 +89,7 @@ async def fetch_batch_items(server: SyncServer, batch_id: str, batch_resp_id: st
86
89
  return updates
87
90
 
88
91
 
92
+ @trace_method
89
93
  async def poll_batch_updates(server: SyncServer, batch_jobs: List[LLMBatchJob], metrics: BatchPollingMetrics) -> List[BatchPollingResult]:
90
94
  """
91
95
  Poll for updates to multiple batch jobs concurrently.
@@ -113,6 +117,7 @@ async def poll_batch_updates(server: SyncServer, batch_jobs: List[LLMBatchJob],
113
117
  return results
114
118
 
115
119
 
120
+ @trace_method
116
121
  async def process_completed_batches(
117
122
  server: SyncServer, batch_results: List[BatchPollingResult], metrics: BatchPollingMetrics
118
123
  ) -> List[ItemUpdateInfo]:
@@ -161,6 +166,7 @@ async def process_completed_batches(
161
166
  return item_updates
162
167
 
163
168
 
169
+ @trace_method
164
170
  async def poll_running_llm_batches(server: "SyncServer") -> List[LettaBatchResponse]:
165
171
  """
166
172
  Cron job to poll all running LLM batch jobs and update their polling responses in bulk.
letta/jobs/scheduler.py CHANGED
@@ -45,6 +45,7 @@ async def _try_acquire_lock_and_start_scheduler(server: SyncServer) -> bool:
45
45
  text("SELECT pg_try_advisory_lock(CAST(:lock_key AS bigint))"), {"lock_key": ADVISORY_LOCK_KEY}
46
46
  )
47
47
  acquired_lock = result.scalar()
48
+ await lock_session.commit()
48
49
 
49
50
  if not acquired_lock:
50
51
  if lock_session:
@@ -90,7 +91,7 @@ async def _try_acquire_lock_and_start_scheduler(server: SyncServer) -> bool:
90
91
  logger.warning("Attempting to release lock due to error during startup.")
91
92
  try:
92
93
  _advisory_lock_session = lock_session
93
- await _release_advisory_lock()
94
+ await _release_advisory_lock(lock_session)
94
95
  except Exception as unlock_err:
95
96
  logger.error(f"Failed to release lock during error handling: {unlock_err}", exc_info=True)
96
97
  finally:
@@ -140,11 +141,11 @@ async def _background_lock_retry_loop(server: SyncServer):
140
141
  await asyncio.sleep(settings.poll_lock_retry_interval_seconds)
141
142
 
142
143
 
143
- async def _release_advisory_lock():
144
+ async def _release_advisory_lock(lock_session=None):
144
145
  """Releases the advisory lock using the stored session."""
145
146
  global _advisory_lock_session
146
147
 
147
- lock_session = _advisory_lock_session
148
+ lock_session = _advisory_lock_session or lock_session
148
149
  _advisory_lock_session = None
149
150
 
150
151
  if lock_session is not None:
@@ -152,6 +153,7 @@ async def _release_advisory_lock():
152
153
  try:
153
154
  await lock_session.execute(text("SELECT pg_advisory_unlock(CAST(:lock_key AS bigint))"), {"lock_key": ADVISORY_LOCK_KEY})
154
155
  logger.info(f"Executed pg_advisory_unlock for lock {ADVISORY_LOCK_KEY}")
156
+ await lock_session.commit()
155
157
  except Exception as e:
156
158
  logger.error(f"Error executing pg_advisory_unlock: {e}", exc_info=True)
157
159
  finally:
@@ -101,6 +101,14 @@ async def retrieve_block(
101
101
  @router.get("/{block_id}/agents", response_model=List[AgentState], operation_id="list_agents_for_block")
102
102
  async def list_agents_for_block(
103
103
  block_id: str,
104
+ include_relationships: list[str] | None = Query(
105
+ None,
106
+ description=(
107
+ "Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. "
108
+ "If not provided, all relationships are loaded by default. "
109
+ "Using this can optimize performance by reducing unnecessary joins."
110
+ ),
111
+ ),
104
112
  server: SyncServer = Depends(get_letta_server),
105
113
  actor_id: Optional[str] = Header(None, alias="user_id"),
106
114
  ):
@@ -110,7 +118,9 @@ async def list_agents_for_block(
110
118
  """
111
119
  actor = await server.user_manager.get_actor_or_default_async(actor_id=actor_id)
112
120
  try:
113
- agents = await server.block_manager.get_agents_for_block_async(block_id=block_id, actor=actor)
121
+ agents = await server.block_manager.get_agents_for_block_async(
122
+ block_id=block_id, include_relationships=include_relationships, actor=actor
123
+ )
114
124
  return agents
115
125
  except NoResultFound:
116
126
  raise HTTPException(status_code=404, detail=f"Block with id={block_id} not found")
@@ -286,14 +286,20 @@ class BlockManager:
286
286
 
287
287
  @trace_method
288
288
  @enforce_types
289
- async def get_agents_for_block_async(self, block_id: str, actor: PydanticUser) -> List[PydanticAgentState]:
289
+ async def get_agents_for_block_async(
290
+ self,
291
+ block_id: str,
292
+ actor: PydanticUser,
293
+ include_relationships: Optional[List[str]] = None,
294
+ ) -> List[PydanticAgentState]:
290
295
  """
291
296
  Retrieve all agents associated with a given block.
292
297
  """
293
298
  async with db_registry.async_session() as session:
294
299
  block = await BlockModel.read_async(db_session=session, identifier=block_id, actor=actor)
295
300
  agents_orm = block.agents
296
- return await asyncio.gather(*[agent.to_pydantic_async() for agent in agents_orm])
301
+ agents = await asyncio.gather(*[agent.to_pydantic_async(include_relationships=include_relationships) for agent in agents_orm])
302
+ return agents
297
303
 
298
304
  @trace_method
299
305
  @enforce_types
@@ -158,6 +158,7 @@ class AsyncToolSandboxLocal(AsyncToolSandboxBase):
158
158
  if not settings.debug:
159
159
  os.remove(temp_file_path)
160
160
 
161
+ @trace_method
161
162
  async def _prepare_venv(self, local_configs, venv_path: str, env: Dict[str, str]):
162
163
  """
163
164
  Prepare virtual environment asynchronously (in a background thread).
@@ -174,11 +175,12 @@ class AsyncToolSandboxLocal(AsyncToolSandboxBase):
174
175
  )
175
176
  log_event(name="finish create_venv_for_local_sandbox")
176
177
 
177
- log_event(name="start install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
178
- await asyncio.to_thread(
179
- install_pip_requirements_for_sandbox, local_configs, upgrade=True, user_install_if_no_venv=False, env=env, tool=self.tool
180
- )
181
- log_event(name="finish install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
178
+ if local_configs.pip_requirements or (self.tool and self.tool.pip_requirements):
179
+ log_event(name="start install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
180
+ await asyncio.to_thread(
181
+ install_pip_requirements_for_sandbox, local_configs, upgrade=True, user_install_if_no_venv=False, env=env, tool=self.tool
182
+ )
183
+ log_event(name="finish install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
182
184
 
183
185
  @trace_method
184
186
  async def _execute_tool_subprocess(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: letta-nightly
3
- Version: 0.8.11.dev20250708104317
3
+ Version: 0.8.12.dev20250709104346
4
4
  Summary: Create LLM agents with long-term memory and custom tools
5
5
  License: Apache License
6
6
  Author: Letta Team
@@ -1,4 +1,4 @@
1
- letta/__init__.py,sha256=MY4Eqs94gdtwy8X6KBPrk0zKk7LUqwyQWvQU-ssrpes,1223
1
+ letta/__init__.py,sha256=O18yG1Lw_7vBqjWzHjZ1QG1xU3TTjRvuxL3iG4G-GxM,1222
2
2
  letta/agent.py,sha256=esW2W5hBzO7aPr7ghEDb_fLnUxgYqBYDq_VWtQDrB0c,89153
3
3
  letta/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  letta/agents/base_agent.py,sha256=Z1jgCTMFRTLnaLRcfdo8TmsP8tuCYqNcOM8ov9kviMA,6869
@@ -74,8 +74,8 @@ letta/interfaces/openai_streaming_interface.py,sha256=FtVFHCw2KTwqqNAlCsggpINXX9
74
74
  letta/interfaces/utils.py,sha256=c6jvO0dBYHh8DQnlN-B0qeNC64d3CSunhfqlFA4pJTY,278
75
75
  letta/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  letta/jobs/helpers.py,sha256=kO4aj954xsQ1RAmkjY6LQQ7JEIGuhaxB1e9pzrYKHAY,914
77
- letta/jobs/llm_batch_job_polling.py,sha256=r_6D5RcqEJQgrdh-rnN7vdLD0GAQl-GGmIfCnV0naHQ,10299
78
- letta/jobs/scheduler.py,sha256=bnwvgT_72ULlKmSFG-26T6tfmiEzxSrm9ARl1MuOEvA,8818
77
+ letta/jobs/llm_batch_job_polling.py,sha256=HUCTa1lTOiLAB_8m95RUfeNJa4lxlF8paGdCV1NqOeA,10413
78
+ letta/jobs/scheduler.py,sha256=_KkOp0uL8C7WpZEwCvHYtvtEjU6RBFXzcS8dnv7fhUM,8947
79
79
  letta/jobs/types.py,sha256=K8GKEnqEgAT6Kq4F2hUrBC4ZAFM9OkfOjVMStzxKuXQ,742
80
80
  letta/llm_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
81
81
  letta/llm_api/anthropic.py,sha256=tbMy4483TySrEmbXD3juM6TpPRrV9_M3Fgp59sDBcqE,47935
@@ -299,7 +299,7 @@ letta/server/rest_api/routers/openai/chat_completions/__init__.py,sha256=47DEQpj
299
299
  letta/server/rest_api/routers/openai/chat_completions/chat_completions.py,sha256=QBWab1fn2LXVDMtc6li3gOzmrNzDiUw5WUJsMeeMZII,5076
300
300
  letta/server/rest_api/routers/v1/__init__.py,sha256=JfSSttkEWu0W18NVVDxl8AGnd8Qhj0BXJNxntOB7070,1768
301
301
  letta/server/rest_api/routers/v1/agents.py,sha256=i0zS-tEZlMf2gfVy-NOq-4mgicJHQBpqRJTLsRUU6L4,52709
302
- letta/server/rest_api/routers/v1/blocks.py,sha256=bxezefb92YWkM9mTuamhqq9AQPPRwhKeCejFKJqwD9s,4817
302
+ letta/server/rest_api/routers/v1/blocks.py,sha256=MArBBnC7k9bc-Z1xMf46aH4ij6qhKAQAOoK9KjiXatU,5257
303
303
  letta/server/rest_api/routers/v1/embeddings.py,sha256=PRaQlrmEXPiIdWsTbadrFsv3Afyv5oEFUdhgHA8FTi8,989
304
304
  letta/server/rest_api/routers/v1/groups.py,sha256=kR_oAuwPd9q-DaeK4Q6Xqu1XlXTXkwEvf2hH7tOiVuw,10978
305
305
  letta/server/rest_api/routers/v1/health.py,sha256=MoOjkydhGcJXTiuJrKIB0etVXiRMdTa51S8RQ8-50DQ,399
@@ -336,7 +336,7 @@ letta/server/ws_api/protocol.py,sha256=5mDgpfNZn_kNwHnpt5Dsuw8gdNH298sgxTGed3etz
336
336
  letta/server/ws_api/server.py,sha256=cBSzf-V4zT1bL_0i54OTI3cMXhTIIxqjSRF8pYjk7fg,5835
337
337
  letta/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
338
338
  letta/services/agent_manager.py,sha256=7xdWIchSUmlPCnNRsXjzd-9EKyk05t9WpGaerMwJLkg,121953
339
- letta/services/block_manager.py,sha256=YwDGdy6f6MNXVXVOxIMOOP6IEWT8h-k5uQlveof0pyE,22744
339
+ letta/services/block_manager.py,sha256=7EliXd0-LpSRwD2LbyjFpH5uiBdrtdZ6YLgb2_wKs3o,22905
340
340
  letta/services/context_window_calculator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
341
341
  letta/services/context_window_calculator/context_window_calculator.py,sha256=H0-Ello1DHV28MnzMseWrg--jarDc6YwCcgwPlWjtZk,6527
342
342
  letta/services/context_window_calculator/token_counter.py,sha256=Ai9-aPkNvhhMTj9zlvdiQAdVqroTzIyAn0TrHpHNQZY,2954
@@ -397,7 +397,7 @@ letta/services/tool_manager.py,sha256=6VI3mjXa6-vrPA74Aar_-ti9Rn3EEBq5TIiayyzoVA
397
397
  letta/services/tool_sandbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
398
398
  letta/services/tool_sandbox/base.py,sha256=Vt4CnxuY5otUD6Kv8PpJNrAtl9eI8tjfcwkOdtUFwKg,7917
399
399
  letta/services/tool_sandbox/e2b_sandbox.py,sha256=TrWWav56H1AsnaKgNZuq0RI-FeWHOZvOubtUywPH72s,11125
400
- letta/services/tool_sandbox/local_sandbox.py,sha256=RQ3iSZqP1nndSdU8pN8GoNDbQr8PRuRIK2-BinIYtK4,11810
400
+ letta/services/tool_sandbox/local_sandbox.py,sha256=mDMoBUl0asu03p7gp2BlzBCna68esMqIRwWF_dzteCA,11937
401
401
  letta/services/user_manager.py,sha256=Neik-mxXgf9jc9jBiiBIlK38UukJonUy9NRS2soFR98,10405
402
402
  letta/settings.py,sha256=lWaLL1t06s9pp4VK5ojQvTiI7D85VcJPjaVKak5LFxs,11304
403
403
  letta/streaming_interface.py,sha256=c-T7zoMTXGXFwDWJJXrv7UypeMPXwPOmNHeuuh0b9zk,16398
@@ -410,8 +410,8 @@ letta/templates/summary_request_text.j2,sha256=ZttQwXonW2lk4pJLYzLK0pmo4EO4EtUUI
410
410
  letta/templates/template_helper.py,sha256=uHWO1PukgMoIIvgqQdPyHq3o3CQ6mcjUjTGvx9VLGkk,409
411
411
  letta/types/__init__.py,sha256=hokKjCVFGEfR7SLMrtZsRsBfsC7yTIbgKPLdGg4K1eY,147
412
412
  letta/utils.py,sha256=4segcFYPNsPrzMpiouYoV6Qzj4TIHuqtCyzVwAMildM,36172
413
- letta_nightly-0.8.11.dev20250708104317.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
414
- letta_nightly-0.8.11.dev20250708104317.dist-info/METADATA,sha256=oeNwjzCwH4x7dMt85jJZ80dzNHIpOIC4rMrHz0bNpdQ,22892
415
- letta_nightly-0.8.11.dev20250708104317.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
416
- letta_nightly-0.8.11.dev20250708104317.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
417
- letta_nightly-0.8.11.dev20250708104317.dist-info/RECORD,,
413
+ letta_nightly-0.8.12.dev20250709104346.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
414
+ letta_nightly-0.8.12.dev20250709104346.dist-info/METADATA,sha256=NBLNREmyI2WWhwKP0V7qqVZ7ucr040lLC5g1HGmhTiY,22892
415
+ letta_nightly-0.8.12.dev20250709104346.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
416
+ letta_nightly-0.8.12.dev20250709104346.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
417
+ letta_nightly-0.8.12.dev20250709104346.dist-info/RECORD,,