def test_continuation_offer_creates_proper_thread(self, mock_redis):
        """Test that continuation offers create properly formatted threads"""
        mock_client = Mock()
        mock_redis.return_value = mock_client

        # Mock the get call that add_turn makes to retrieve the existing thread
        # We'll set this up after the first setex call
        def side_effect_get(key):
            # Return the context from the first setex call
            if mock_client.setex.call_count > 0:
                first_call_data = mock_client.setex.call_args_list[0][0][2]
                return first_call_data
            return None

        mock_client.get.side_effect = side_effect_get

        request = ContinuationRequest(prompt="Initial analysis", files=["/test/file.py"])
        content = "Analysis result"
        continuation_data = {"remaining_turns": 4, "tool_name": "test_continuation"}

        self.tool._create_continuation_offer_response(content, continuation_data, request)

        # Verify thread creation was called (should be called twice: create_thread + add_turn)
        assert mock_client.setex.call_count == 2

        # Check the first call (create_thread)
        first_call = mock_client.setex.call_args_list[0]
        thread_key = first_call[0][0]
        assert thread_key.startswith("thread:")
        assert len(thread_key.split(":")[-1]) == 36  # UUID length

        # Check the second call (add_turn) which should have the assistant response
        second_call = mock_client.setex.call_args_list[1]
        thread_data = second_call[0][2]
        thread_context = json.loads(thread_data)

        assert thread_context["tool_name"] == "test_continuation"
        assert len(thread_context["turns"]) == 1  # Assistant's response added
        assert thread_context["turns"][0]["role"] == "assistant"
        assert thread_context["turns"][0]["content"] == content
        assert thread_context["turns"][0]["files"] == ["/test/file.py"]  # Files from request
        assert thread_context["initial_context"]["prompt"] == "Initial analysis"
        assert thread_context["initial_context"]["files"] == ["/test/file.py"]
Test that continuation offers create properly formatted threads
tests/test_claude_continuation.py