Machine Lieutenant
Medium construct, neutral 
Armor Class 20
Hit Points 60hp (8d8+24)
Speed 
      40ft
            
 
  Skills Perception +4
  Damage Resistances bludgeoning, piercing, and slashing from nonmagical weapons that aren't adamantine
  Damage Immunities force, necrotic, poison
  Condition Immunities blinded, charmed, deafened, frightened, paralyzed, petrified, poisoned, stunned
  Senses blindsight 60 ft.
passive perception 14
  Languages understands the languages of its creator but can't speak
 
  Challenge 4
  
  
    Magic Resistance. The machine lieutenant has advantage on saving throws against spells and other magical effects.
 
Both Guard and Ward. While the lieutenant is within 5 feet of the attuned owner of the Codex Automata, any attack targeting the codex's owner has a 50% chance to instead target the machine lieutenant.
 
   
  Actions
  Multiattack. The lieutenant makes two longsword attacks.
 
Longsword. Melee weapon attack: +6 to hit, reach 5ft., one target. Hit: 9 (1d10+4) slashing damage.