The three were arrested after arranging a meeting with the agent, who pretended to be the buyer.
Police say they recovered 60 bags of heroin. Task force Sgt. Brett Orlich says, "Their bad luck is our good luck."
The three are due in town court in Pine Plains on Wednesday to face felony charges of criminal possession of a controlled substance.