From 2ec20e76bd441c831aceacdfdeb1041f166768c4 Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Thu, 16 Apr 2026 01:47:28 +0700 Subject: [PATCH] fix(backend/copilot): address review comments cycle 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace redundant elif guard with plain else in service.py restore path - Use isinstance(…, Exception) instead of BaseException in gather error checks for upload_cli_session (BaseException swallows KeyboardInterrupt) - Use explicit list side_effect in test_returns_none_when_file_not_found to document the two-call contract of the concurrent retrieve gather --- autogpt_platform/backend/backend/copilot/sdk/service.py | 4 +--- autogpt_platform/backend/backend/copilot/transcript.py | 4 ++-- autogpt_platform/backend/backend/copilot/transcript_test.py | 5 ++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/autogpt_platform/backend/backend/copilot/sdk/service.py b/autogpt_platform/backend/backend/copilot/sdk/service.py index 89afb028f1..783e634e96 100644 --- a/autogpt_platform/backend/backend/copilot/sdk/service.py +++ b/autogpt_platform/backend/backend/copilot/sdk/service.py @@ -2503,9 +2503,7 @@ async def stream_chat_completion_sdk( log_prefix, ) transcript_covers_prefix = False - elif ( - config.claude_agent_use_resume and user_id and len(session.messages) > 1 - ): + else: # No CLI session in GCS — reconstruct from DB messages as last-resort fallback. prior = session.messages[:-1] reconstructed = _session_messages_to_transcript(prior) diff --git a/autogpt_platform/backend/backend/copilot/transcript.py b/autogpt_platform/backend/backend/copilot/transcript.py index 3f8448cf9f..e973377aed 100644 --- a/autogpt_platform/backend/backend/copilot/transcript.py +++ b/autogpt_platform/backend/backend/copilot/transcript.py @@ -762,12 +762,12 @@ async def upload_cli_session( ), return_exceptions=True, ) - if isinstance(session_result, BaseException): + if isinstance(session_result, Exception): logger.warning( "%s Failed to upload CLI session file: %s", log_prefix, session_result ) return - if isinstance(meta_result, BaseException): + if isinstance(meta_result, Exception): logger.warning( "%s Failed to upload CLI session meta: %s", log_prefix, meta_result ) diff --git a/autogpt_platform/backend/backend/copilot/transcript_test.py b/autogpt_platform/backend/backend/copilot/transcript_test.py index 3038d623cb..e2cb697826 100644 --- a/autogpt_platform/backend/backend/copilot/transcript_test.py +++ b/autogpt_platform/backend/backend/copilot/transcript_test.py @@ -982,7 +982,10 @@ class TestRestoreCliSession: from .transcript import restore_cli_session mock_storage = AsyncMock() - mock_storage.retrieve.side_effect = FileNotFoundError("not found") + mock_storage.retrieve.side_effect = [ + FileNotFoundError("no session"), + FileNotFoundError("no meta"), + ] with patch( "backend.copilot.transcript.get_workspace_storage",