It appears that while Rowling herself knew what was coming, she did not release all of that information to Rickman, just a few pieces. As K-H-W states Rowling did want Rickman to play the part, so she must have envisioned him in this role to the end.
There is a longstanding story that Rowling let Rickman know early on
that Snape was not the bad guy or Voldemort henchman in waiting many
expected him to be. Before I could even finish my question about this
anecdote Rickman jumped in to clarify.
According to Alan Rickman.
"Not true. I don't know who thinks that is true, but it's not true," Rickman says. "She gave me one tiny, little, left of field piece of information that helped me think that he was more complicated and that the story was not going to be as straight down the line as everybody thought. If you remember when I did the first film she'd only written three or four books, so nobody knew where it was really going except her. And its was important for her that I know something, but she only gave me a tiny piece of information which helped me think it was a more ambiguous route."
LINK
Rickman adds,
"What I knew was he was a human being and not an automaton and I knew
there was some sense of protection for Harry or I worked that out. It
was enough to know, I didn't know he was a double agent."
"Three children have become adults since a phone call with Jo Rowling,
containing one small clue, persuaded me that there was more to Snape
than an unchanging costume, and that even though only three of the
books were out at that time, she held the entire massive but delicate
narrative in the surest of hands. quote
Here we see that by book 3, Rickman knew JRK had a plan in store for Snape.
"She certainly didn't tell me what the end of the story was going to
be in any way at all," Rickman said. "No, she gave me one little piece
of information, which I always said I would never share with anybody
and never have, and never will. It wasn't a plot point, or crucial in
any tangible way, but it was crucial to me as a piece of information
that made me travel down that road rather than that one or that one or
that one." Rowling revealed [on Twitter] what she had told Rickman: "I
told Alan what lies behind the word 'Always'." quote
This "Always" was most likely in reference to Snape Loving Lilly, showing that Rowling had planned Snapes story out by book 3, when hiring Rickman.