Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

chore: bump version 0.8.12 (#2712)

cthomasc0e2065ef50a
diff --git a/letta/__init__.py b/letta/__init__.py
index 2b6abb39c..f7de8edc4 100644
--- a/letta/__init__.py
+++ b/letta/__init__.py
@@ -5,8 +5,7 @@ try:
__version__ = version("letta")
except PackageNotFoundError:
# Fallback for development installations
- __version__ = "0.8.11"
-
+ __version__ = "0.8.12"
if os.environ.get("LETTA_VERSION"):
__version__ = os.environ["LETTA_VERSION"]
diff --git a/letta/server/rest_api/routers/v1/blocks.py b/letta/server/rest_api/routers/v1/blocks.py
index b09097ad5..9142e915b 100644
--- a/letta/server/rest_api/routers/v1/blocks.py
+++ b/letta/server/rest_api/routers/v1/blocks.py
@@ -101,6 +101,14 @@ async def retrieve_block(
@router.get("/{block_id}/agents", response_model=List[AgentState], operation_id="list_agents_for_block")
async def list_agents_for_block(
block_id: str,
+ include_relationships: list[str] | None = Query(
+ None,
+ description=(
+ "Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. "
+ "If not provided, all relationships are loaded by default. "
+ "Using this can optimize performance by reducing unnecessary joins."
+ ),
+ ),
server: SyncServer = Depends(get_letta_server),
actor_id: Optional[str] = Header(None, alias="user_id"),
):
@@ -110,7 +118,9 @@ async def list_agents_for_block(
"""
actor = await server.user_manager.get_actor_or_default_async(actor_id=actor_id)
try:
- agents = await server.block_manager.get_agents_for_block_async(block_id=block_id, actor=actor)
+ agents = await server.block_manager.get_agents_for_block_async(
+ block_id=block_id, include_relationships=include_relationships, actor=actor
+ )
return agents
except NoResultFound:
raise HTTPException(status_code=404, detail=f"Block with id={block_id} not found")
diff --git a/letta/services/block_manager.py b/letta/services/block_manager.py
index 820158050..6aa891449 100644
--- a/letta/services/block_manager.py
+++ b/letta/services/block_manager.py
@@ -286,14 +286,20 @@ class BlockManager:
@trace_method
@enforce_types
- async def get_agents_for_block_async(self, block_id: str, actor: PydanticUser) -> List[PydanticAgentState]:
+ async def get_agents_for_block_async(
+ self,
+ block_id: str,
+ actor: PydanticUser,
+ include_relationships: Optional[List[str]] = None,
+ ) -> List[PydanticAgentState]:
"""
Retrieve all agents associated with a given block.
"""
async with db_registry.async_session() as session:
block = await BlockModel.read_async(db_session=session, identifier=block_id, actor=actor)
agents_orm = block.agents
- return await asyncio.gather(*[agent.to_pydantic_async() for agent in agents_orm])
+ agents = await asyncio.gather(*[agent.to_pydantic_async(include_relationships=include_relationships) for agent in agents_orm])
+ return agents
@trace_method
@enforce_types
diff --git a/letta/services/tool_sandbox/local_sandbox.py b/letta/services/tool_sandbox/local_sandbox.py
index 901231ead..3f24fca13 100644
--- a/letta/services/tool_sandbox/local_sandbox.py
+++ b/letta/services/tool_sandbox/local_sandbox.py
@@ -158,6 +158,7 @@ class AsyncToolSandboxLocal(AsyncToolSandboxBase):
if not settings.debug:
os.remove(temp_file_path)
+ @trace_method
async def _prepare_venv(self, local_configs, venv_path: str, env: Dict[str, str]):
"""
Prepare virtual environment asynchronously (in a background thread).
@@ -174,11 +175,12 @@ class AsyncToolSandboxLocal(AsyncToolSandboxBase):
)
log_event(name="finish create_venv_for_local_sandbox")
- log_event(name="start install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
- await asyncio.to_thread(
- install_pip_requirements_for_sandbox, local_configs, upgrade=True, user_install_if_no_venv=False, env=env, tool=self.tool
- )
- log_event(name="finish install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
+ if local_configs.pip_requirements or (self.tool and self.tool.pip_requirements):
+ log_event(name="start install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
+ await asyncio.to_thread(
+ install_pip_requirements_for_sandbox, local_configs, upgrade=True, user_install_if_no_venv=False, env=env, tool=self.tool
+ )
+ log_event(name="finish install_pip_requirements_for_sandbox", attributes={"local_configs": local_configs.model_dump_json()})
@trace_method
async def _execute_tool_subprocess(
diff --git a/pyproject.toml b/pyproject.toml
index 9012cfcf5..6610bbe01 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "letta"
-version = "0.8.11"
+version = "0.8.12"
packages = [
{include = "letta"},
]