fix: is_spam always returned None due to missing return statement#7
Open
Ridwannurudeen wants to merge 1 commit intoNousResearch:mainfrom
Open
fix: is_spam always returned None due to missing return statement#7Ridwannurudeen wants to merge 1 commit intoNousResearch:mainfrom
Ridwannurudeen wants to merge 1 commit intoNousResearch:mainfrom
Conversation
is_spam() built a list of regex patterns for spam detection but never evaluated them — the function fell off the end and implicitly returned None, so spam content was never identified and _should_reply() never penalised it. - Add the missing `return any(re.search(pattern, clean) for pattern in patterns)` - Move `from unicodedata import normalize` to the module-level imports and remove the redundant per-call `import re` / `from unicodedata import normalize` that were shadowing the top-level imports inside the function body Fixes NousResearch#4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4.
is_spam()inreply_manager.pybuilt an extensive list of regex patterns for detecting crypto spam but never evaluated them — the function fell off the end and implicitly returnedNone. As a result,_should_reply()never applied the-3spam penalty, and the agent replied to every piece of spam as if it were legitimate.Root cause
Fix
Also removes two redundant per-call imports (
import reandfrom unicodedata import normalize) that duplicated the module-level imports already present at the top of the file.Changes
agent/engines/twitter/reply_manager.pyreturntois_spam()from unicodedata import normalizeto module-level importsimport re/from unicodedata import normalizefrom inside the function bodyTest plan
is_spam("🚀 100x moon soon buy now")returnsTrueis_spam("interesting take on the consensus mechanism")returnsFalse_should_reply()correctly penalises spam content with a-3score adjustment