That's for the scenario described (agreeing to let defenders walk away and then attacking them after they surrender). There are additional considerations for acts of betrayal in other situations, but let's keep it simple. The first consideration could be a simple opinion & recent event check, which could be handled by a tagging/association system. The reason being you don't want lords to slaughter each other just because they dislike one another, as then they'll continue hating each other and be stuck in an endless cycle of butchery. So, check their opinion, and if it's negative then you check for tags associated with the opposing lord. Say Lord Rudeman is tagged for all kinds of mean stuff, like raiding caravans and villages, but there's one village in particular that he razed to the ground. Lord Angrypants owns that village, and has laid siege to Lord Rudeman's castle, with Lord Rudeman inside of it. Lord Angrypants not only has a negative opinion of Lord Rudeman, but he wants revenge because Rudeman utterly destroyed his fief. Lord Ridealong is helping Angrypants siege the castle, and Ridealong doesn't like Lord Rudeman either, but all Rudeman did to Ridealong was raid a couple of his caravans. Lord Ridealong isn't going to make the decision to slaughter Lord Rudeman after his surrender, and he may actually like Lord Angrypants less for it depending on Ridealong's honor value, but because he doesn't like Rudeman he isn't going to do anything to stop it from happening (maybe he would if he had a personality tag, like "merciful").
The second consideration is pretty straightforward: how much honor will I lose for doing this, will I gain or lose renown (I can see it going both ways), and will my liege lord punish me for doing it ostensibly in his name (assuming you're at war)? Some lords might not care at all, they could have a very vindictive personality or be impulsive. Others may feel justified for doing it, like Lord Angrypants, but would refrain because they know that their liege lord wouldn't care for it at all. This is more nuanced, unlike the above, because instead of asking "do I have a reason to do this" we're asking "is my reason good enough to justify my potential losses?" This could, practically speaking, be decided by a weighted dice roll which is modified by personality type of the lord in question, the personality of their liege lord (if it matters), and the weighted significance of their reason (e.g. the murder of one of your family members is a very compelling reason, but raiding your village isn't), which we can call the Justification Value. Check the result of his dice roll against a normalized average of the lord's holdings and material wealth, modified by their liege lord's current opinion if applicable, and away you go, which we'll call the Potential Loss Value.
As an example, Lord Angrypants may be vindictive so he'll believe a wider range of offenses are sufficient justification for what he's about to do. So, what goes through his mind is "I hate Lord Rudeman, but my liege lord would be a little upset if I murdered all of Rudeman's soldiers after they surrendered. That said, he murdered a bunch of my serfs and burned their houses down, so I think this is fair." Angrypants would have a pretty high modifier on his dice roll for determining his final Justification Value. We take that value and match it up against Lord Angrypants' estimated wealth and the current opinion his lord has of him. Let's say Angrypants doesn't have much in the way of fiefs, just a couple of villages (one of which was burned to the ground not too long ago) and maybe a castle or fort nearby. Also, Lord Angrypants has been at odds with his liege lord for a while, so while their relations aren't bad they are somewhat strained, close to neutral. Lord Angrypants would upset his lord by betraying Lord Rudeman, and because he's already straining that relationship there's a good chance that his liege lord would punish him by taking away some of his land. Lord Angrypants doesn't have much land, so he's keen to hang on to what he has left, so he's unlikely to risk it. He's likely to lose a large portion of his fiefs, which would make him even poorer, and his liege lord would actively dislike him, so his Potential Loss Value is very high. There's still a chance he would follow through, depending on the Justification Value dice roll.
For the third consideration, we can make a similar calculation to what we already do when lords decide to attack each other on the map. Basically, check their surroundings for additional parties and determine if they are a threat. The relations change you receive with your liege lord for a betrayal could be delayed for weeks, but if someone is with you when you do it then their relations would change immediately. Some may support you, some may be indifferent (like Lord Ridealong), and others may try to stop you. There could also just be a hostile party nearby that would take advantage of the opportunity to bushwhack you.
The fourth consideration could be applied in the second step, where we calculated what losses we might face for betraying a lord. If that lord is family and our culture places great significance on family loyalty, then we could heavily weight the calculation against betrayal. This could be applied in a very simple way as a percentage modifier of the Potential Loss Value. If family is very important, then we could multiply the value by 2.0, whereas if family is inconsequential then we could multiply it by 1.0. By carefully choosing our modifiers for the Justification Value, we could still make it remotely possible for loyal family members to betray each other, but they would have to hate each others' guts before they would do it.
The fifth and sixth considerations could all be lumped in to the first and second, but I feel they're important enough to discuss on their own. Social status & reputation are quite important, and with the wide variety of personalities that would be present it's quite possible to win as many new friends as you would lose old ones. Some of the friends you make could even be in your enemy's faction, and this could be a way to ingratiate yourself with them before you switch sides. Maybe Lord Angrypants won't care that his lord will take away his land, because he knows that Lord Rudeman is widely disliked in his own faction and Angrypants isn't content with his current status at home. So, Lord Angrypants decides to kick Rudeman while he's down, jumps ship, and goes looking for greener pastures. Alternatively, some of Lord Rudeman's family might get really upset with Lord Angrypants for what he's done and raze both of his villages, siege his castle, and do the same thing to him.