more logging

This commit is contained in:
John Burwell 2025-10-03 17:15:01 +00:00
parent 7ba19523ab
commit d3cedd9b2d

View File

@ -382,6 +382,12 @@ class Chat(callbacks.Plugin):
return False return False
decision = outcome.strip().split()[0].lower() decision = outcome.strip().split()[0].lower()
self.log.debug(
"Passive classifier outcome | decision=%s | raw=%s | channel=%s",
decision,
outcome.strip(),
msg.args[0],
)
return decision == "reply" return decision == "reply"
def _should_respond_passively(self, irc, msg, session, events): def _should_respond_passively(self, irc, msg, session, events):
@ -393,30 +399,63 @@ class Chat(callbacks.Plugin):
now = time.time() now = time.time()
mention = self._is_direct_mention(irc, text) mention = self._is_direct_mention(irc, text)
self.log.debug(
"Passive evaluate | mode=%s | state=%s | nick=%s | channel=%s | mention=%s | replies=%s",
passive_mode,
session.state.value,
msg.nick,
msg.args[0],
mention,
session.replies_in_thread,
)
if mention: if mention:
if session.state == EngagementState.COOLING: if session.state == EngagementState.COOLING:
session.reset() session.reset()
self.log.debug(
"Passive reset session for mention during cooldown | channel=%s",
msg.args[0],
)
session.thread_owner = msg.nick session.thread_owner = msg.nick
session.last_invitation = now session.last_invitation = now
session.state = EngagementState.INVITED session.state = EngagementState.INVITED
session.replies_in_thread = 0 session.replies_in_thread = 0
self.log.debug("Passive accepted mention | channel=%s", msg.args[0])
return True return True
if session.state == EngagementState.COOLING: if session.state == EngagementState.COOLING:
self.log.debug(
"Passive skip: cooling | channel=%s | until=%.2f | now=%.2f",
msg.args[0],
session.cooling_until,
now,
)
return False return False
if session.state in (EngagementState.INVITED, EngagementState.ENGAGED) and session.thread_owner: if session.state in (EngagementState.INVITED, EngagementState.ENGAGED) and session.thread_owner:
if ircutils.strEqual(msg.nick, session.thread_owner): if ircutils.strEqual(msg.nick, session.thread_owner):
self.log.debug(
"Passive continuing thread with owner | channel=%s | owner=%s",
msg.args[0],
session.thread_owner,
)
return True return True
if passive_mode == "mention": if passive_mode == "mention":
self.log.debug("Passive skip: mention mode without mention | channel=%s", msg.args[0])
return False return False
if session.state != EngagementState.IDLE: if session.state != EngagementState.IDLE:
self.log.debug(
"Passive skip: state not idle | channel=%s | state=%s",
msg.args[0],
session.state.value,
)
return False return False
candidate = self._looks_like_question(text) or self._contains_trigger_word(text) candidate = self._looks_like_question(text) or self._contains_trigger_word(text)
if not candidate: if not candidate:
self.log.debug("Passive skip: heuristics failed | channel=%s", msg.args[0])
return False return False
try: try:
@ -425,21 +464,28 @@ class Chat(callbacks.Plugin):
probability = 0.0 probability = 0.0
if probability <= 0: if probability <= 0:
self.log.debug("Passive skip: probability disabled | channel=%s", msg.args[0])
return False return False
roll = random.random() roll = random.random()
if roll > probability: if roll > probability:
self.log.debug(f"Passive skip due to probability gate ({roll:.2f} > {probability:.2f})") self.log.debug(
"Passive skip: probability gate | roll=%.2f | threshold=%.2f | channel=%s",
roll,
probability,
msg.args[0],
)
return False return False
if not self._classify_passive_trigger(irc, msg, events): if not self._classify_passive_trigger(irc, msg, events):
self.log.debug("Passive classifier opted to skip reply") self.log.debug("Passive skip: classifier veto | channel=%s", msg.args[0])
return False return False
session.thread_owner = msg.nick session.thread_owner = msg.nick
session.last_invitation = now session.last_invitation = now
session.state = EngagementState.INVITED session.state = EngagementState.INVITED
session.replies_in_thread = 0 session.replies_in_thread = 0
self.log.debug("Passive proceed: classifier approved | channel=%s", msg.args[0])
return True return True
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
@ -482,6 +528,11 @@ class Chat(callbacks.Plugin):
session.cooling_until = now + self.registryValue("passive_cooldown") session.cooling_until = now + self.registryValue("passive_cooldown")
session.thread_owner = None session.thread_owner = None
session.replies_in_thread = 0 session.replies_in_thread = 0
self.log.debug(
"Passive skip: reached max replies | channel=%s | max=%s",
msg.args[0],
max_replies,
)
return return
try: try:
@ -494,6 +545,7 @@ class Chat(callbacks.Plugin):
return return
self.handle_response(irc, msg, response, session=session) self.handle_response(irc, msg, response, session=session)
self.log.debug("Passive reply sent | channel=%s", msg.args[0])
def filter_prefix(self, msg, prefix): def filter_prefix(self, msg, prefix):
if msg.startswith(prefix): if msg.startswith(prefix):