Are there any limits in the government's ability to offer immunity from prosecution?

In the final show of a well known police drama the central character, who is a rogue cop, is offered blanket immunity on everything he’s done if he will agree to testify against others and work for the government.

As a condition of this deal he confesses his litany of crimes, which includes theft, murdering fellow policeman, massive corruption, torturing suspects, etc., etc., and which are so extensive his handlers are shocked and stunned, but they can do nothing as they have offered the deal.

Can the government really make you immune from prosecution against anything?

Sammy “The Bull” Gravano, who worked with the government to bring down John Gotti comes to mind.

From his Wiki article:

I guess it’s not total immunity but doing five years for 19 murders is a complete joke. The article mentions that he got off early but doesn’t say how much he actually spent in the slammer.

IIRC there was a Law and Order episode where they trapped the guy because the DA that offered the immunity only offered it for crimes under his jurisdiction - Manhattan (county?). Staten Island was a separate jurisdiction.

IANAL but…
Basically, if the DA does not have the jurisdiction for that crime, they obviously cannot offer immunity. Of course, if the evidence was given under a government offer of immunity, and then it turns out there was no immunity, it would be inadmissible evidence, I would think. Just as if the cops promised the suspect “we’ll let you go if you confess” and are lying.

I suspect all “immunity deals” are pretty explicit and carefully written, or the perp should get a better lawyer. Usually they include the stipulation that if you lie or “forget” something, the deal is off and all evidence is admissible, along with what crime(s) are immunized. If the wording is sufficient that it covers other crimes the authorities did not suspect, well that’s what happens when you buy a pig in a poke.

Some of the deals only include crimes you admit to at the time of the deal - if they later find out you did other stuff then you are liable for those.