This patch addresses issue #2744 by adding bounds checking before accessing
messages[msg_i].get('tool_calls') in the ollama_pt function. The issue occurs
when an assistant message is the last message in the list, causing msg_i to
go out of bounds.
The fix is implemented as a monkey patch in CrewAI to avoid waiting for
an upstream fix in litellm.
Co-Authored-By: Joe Moura <joao@crewai.com>