From c0e2065ef50a7e1e57a8edda72c8bfee096bc60e Mon Sep 17 00:00:00 2001 From: cthomas Date: Tue, 8 Jul 2025 17:06:54 -0700 Subject: [PATCH] chore: bump version 0.8.12 (#2712) --- letta/__init__.py | 3 +-- letta/server/rest_api/routers/v1/blocks.py | 12 +++++++++++- letta/services/block_manager.py | 10 ++++++++-- letta/services/tool_sandbox/local_sandbox.py | 12 +++++++----- pyproject.toml | 2 +- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/letta/__init__.py b/letta/__init__.py index 2b6abb39..f7de8edc 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 b09097ad..9142e915 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 82015805..6aa89144 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 901231ea..3f24fca1 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 9012cfcf..6610bbe0 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"}, ]