John Hare, who had a wife and family, told his girlfriend he had killed people in the past and had agents watching him so always had to have a handgun close by.
Newcastle Crown Court heard the 53-year-old was armed during a dinner outing to a Toby carvery and would carry the .22 pistol on nights out with the woman.
A judge has said Hare, whose marriage broke down, was carrying out a "James Bond type fantasy" to impress his girlfriend, who he was seeing for five years before he attacked her during a confrontation at his home in May 2020.
'Unacceptable' HMO refused for Sunderland neighbourhood where there is already too much shared housing
Caught hook, line and sinker: Sunderland pair in court after social media posts brag about illegal salmon and sea trout fishing on River Wear
The 12 Sunderland streets with most disorder and anti-social behaviour in June
UPDATE: Man released under investigation after collision leaves 13-year-old boy cyclist in critical condition
Sunderland AFC reveal new Stadium of Light ticket office and club shop opening hours after fan complaints
The court heard Hare had punched his girlfriend three times and sent her to the floor.
He then put his palm to her face and caused her nose to bleed before he caused damage to her car wing mirror.
Hare denied assault and criminal damage but was convicted after a magistrates court trial.
Prosecutor Kelly Sherif told the court it was during an investigation into Hare that detectives received information about him having a firearm and he confessed when confronted.
When officers arrived at the farm to seize the firearm they were directed to the coop, containing around 30 chickens.
Miss Sherif said: "At this point, the defendant's wife entered the chicken coop, went behind units, dug the ground with her bare hands, pulled out a brick, then dug further.
"She pulled out a bread bag which contained the weapon and she threw this to the officers' feet."
The court heard the weapon was a .22 air pistol which was capable of firing.
Hare, of Carr House Farm, Murton, Seaham, admitted possession of a prohibited firearm, which he said he had bought over the internet in 2005 or 2006, to be used to shoot rats.
Judge Edward Bindloss sentenced him to five-and-a-half years behind bars with an order to pay £100 compensation for the damage.
Judge Bindloss said Hare's girlfriend had told police in a statement she had seen the handgun "lots of times" during their relationship.
She also said in her statement: "He even had it with him when he went to the Toby carvery at Washington and also had it on him on nights out, not all the time but quite frequently."
Judge Bindloss added: "She goes on to say you had made her believe that you had some kind of connection to the Secret Service and agents and had killed people due to your work and, because of threats made against you, you carried a weapon and agents were watching you.
"That was all complete fantasy.
"She says she believed you worked for the Secret Service and that was why you kept the weapon close by."
The court heard Hare's farm has a number or properties, including a bungalow he lived in and a house where his wife lived.
Judge Bindloss said he accepted Hare was not a danger to the public but said he was a "fantasist" and what he told his girlfriend was "froth and nonsense".
Thomas Welshman, defending, said Hare never threatened anyone with the gun and the deterioration of his marriage had led to a "build up of pressure".