Kalani

General Kalani is a super tactical droid who appeared in Star Wars: The Clone Wars and Star Wars Rebels. He served as a general to the Confederacy of Independent Systems during the Clone Wars.

Star Wars: The Clone Wars
During the Battle of Onderon, Kalani was sent by Count Dooku to aid King Sanjay Rash of Onderon in defeating the resistance movement against the Separatist occupation. However, after continued resistance, Kalani and Dooku came to the conclusion that the fighting on Onderon was not worth the time and resources required, and as such, Dooku ordered the Confederacy to abandon the planet and relocate to Agamar. As he left, Kalani killed Sanjay Rash with a shot from a blaster, ending his former ally as he tried to protest against the droid's departure.

Star Wars Rebels
When the war came to an end, the droid army was given a shutdown command. However, Kalani correctly deduced that it was a Republic trick and prevented the shutdown command. For the next fifteen years, Kalani and his forces remained operational on the planet Agamar while the rest of the galaxy fell to the control and tyranny of the Galactic Empire. About two years before the Battle of Yavin, General Kalani and his forces captured the Lothal Rebels and former Captain Rex, who were in search of proton bombs. He challenged the Rebels to one last battle that would end the clone wars on his terms, with Zeb as the hostage they had to save.

When it looked like the Rebels had won, Kalani almost turned the table only for Ezra to intervene and point out that this battle was irrelevant because "both" sides lost; the Empire was the only true winner of the war since Palpatine had played the two sides against each other. According to Ezra's reasoning, the shutdown order was meant to go out, the droids were always meant to lose, and the clones were never meant to beat the droids but their own Jedi commanders. Rex and Kalani were grieved by this but the droid general could not deny Ezra's logic. Ezra asked Kalani why he fought in the war and the tactical droid concluded that the Separatists were fighting against the tyranny of the Republic. Ezra pointed out that the Republic had become the Empire, which was now openly tyrannical. In the end, Kalani agreed that they now shared a common enemy. Their base was then assaulted by Imperial forces who had been dispatched by Governor Pryce. Working together, Kalani and the Rebels conjured up a successful plan to escape the Imperials, and afterwards Kalani and his remaining Battle Droids went their separate ways from Rex, Jarrus and Bridger, satisfied that the war was over with a victory for both the Republic and the Separatists. Despite having won the battle, Kalani also declined to join the Rebellion, as the droid calculated that they had a less than 1% chance of overthrowing the Empire.

Trivia

 * In the Rebels Recon featurette for "The Last Battle", Henry Gilroy, the Co-Executive Producer for the series, said that he thought in the near future Kalani would hire out his services as a military advisor to various groups such as the Hutt Clan—given that he doesn't think the nascent Rebellion has any realistic chance of defeating the Empire. Gilroy went on to say, however, that he thinks that the destruction of the Death Star at the Battle of Yavin (about two years after Kalani leaves Agamar) will change his mind, proving that the Empire isn't invincible and the rebellion has a real chance of winning.