From 9392adc8f5d2e329de1e160befadf8b60c81e6ea Mon Sep 17 00:00:00 2001 From: cthomas Date: Sun, 20 Jul 2025 14:41:40 -0700 Subject: [PATCH] feat: skip job load in step logging (#3433) --- letta/services/step_manager.py | 2 -- tests/test_managers.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/letta/services/step_manager.py b/letta/services/step_manager.py index c1034ebb..32be8275 100644 --- a/letta/services/step_manager.py +++ b/letta/services/step_manager.py @@ -158,8 +158,6 @@ class StepManager: if stop_reason: step_data["stop_reason"] = stop_reason.stop_reason async with db_registry.async_session() as session: - if job_id: - await self._verify_job_access_async(session, job_id, actor, access=["write"]) new_step = StepModel(**step_data) await new_step.create_async(session, no_commit=True, no_refresh=True) pydantic_step = new_step.to_pydantic() diff --git a/tests/test_managers.py b/tests/test_managers.py index c6a7e1e5..3d868eec 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.py @@ -46,7 +46,7 @@ from letta.jobs.types import ItemUpdateInfo, RequestStatusUpdateInfo, StepStatus from letta.orm import Base, Block from letta.orm.block_history import BlockHistory from letta.orm.enums import ToolType -from letta.orm.errors import NoResultFound, UniqueConstraintViolationError +from letta.orm.errors import ForeignKeyConstraintViolationError, NoResultFound, UniqueConstraintViolationError from letta.orm.file import FileContent as FileContentModel from letta.orm.file import FileMetadata as FileMetadataModel from letta.schemas.agent import CreateAgent, UpdateAgent @@ -6565,7 +6565,7 @@ async def test_job_usage_stats_add_nonexistent_job(server: SyncServer, sarah_age """Test adding usage statistics for a nonexistent job.""" step_manager = server.step_manager - with pytest.raises(NoResultFound): + with pytest.raises(ForeignKeyConstraintViolationError): await step_manager.log_step_async( agent_id=sarah_agent.id, provider_name="openai",