I was encountering this error since my ollama version did not support tool calling.
After upgrading ollama server version (to 0.4.2) now the role "tool" is available.