“Delaying something is part of what a good diplomat is supposed to know how to do,” said John, a young American diplomat who lives in Washington, D.C., where marijuana use became legal this year. “If you can’t put off a test for two weeks, I mean, come on.” He spoke on the condition that only his first name be used in an effort to avoid losing his job.

Government officials who have gotten high are hardly rare, and the long list of elected officials who have admitted to past use of marijuana — and other substances — starts with President Obama, who wrote that he had used both marijuana and cocaine. But there is a widening chasm between what voters are willing to tolerate and what federal agencies allow, leaving men and women who are trying to build careers in government with a choice between honesty and their ambitions.

The C.I.A. requires that its job candidates be “generally” drug free for at least a year, and asks potential hires about past use, according to Lyssa Asbill, an agency spokeswoman. But how much past use constitutes too much is not clear.

The F.B.I. has even tougher standards. The bureau insists that recruits refrain from marijuana use for at least three years before hire.

Yet even the director of the F.B.I., James B. Comey, acknowledged last year that his agency’s rule could hurt recruitment, although no federal agency has yet offered specific numbers or other evidence that they are having trouble filling jobs. “I have to hire a great work force to compete with those cybercriminals, and some of those kids want to smoke weed on the way to the interview,” he said at a conference on white collar crime in May 2014.