Skip to content

fix: honor realtime setting for V2 learning - #233

Merged
EterUltimate merged 3 commits into
NickCharlie:mainfrom
EterUltimate:codex/reduce-persona-review-log-noise
Jul 1, 2026
Merged

fix: honor realtime setting for V2 learning#233
EterUltimate merged 3 commits into
NickCharlie:mainfrom
EterUltimate:codex/reduce-persona-review-log-noise

Conversation

@EterUltimate

@EterUltimate EterUltimate commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • honor enable_realtime_learning before V2 per-message processing so realtime-off setups do not keep triggering V2 tiered learning on every message
  • add default-off enable_realtime_v2_processing in config/schema as an explicit opt-in for users who still want V2 realtime ingestion while realtime learning is off
  • keep the earlier /api/persona_updates polling logs at DEBUG so dashboard refreshes no longer look like learning jobs

Evidence

  • Issue [Bug] #232 now reports real model calls: realtime learning off, learning interval set to 6h, but about 59 model calls in 30 minutes and 1000+ calls total.
  • services/learning/message_pipeline.py previously called self._v2_integration.process_message(...) for every inbound message whenever V2 integration existed, independent of enable_realtime_learning.
  • services/core_learning/v2_learning_integration.py registers Tier 2 LLM-heavy operations including LightRAG/Mem0 ingestion flush every 5 messages or 60 seconds and jargon inference every 20 messages or 180 seconds using llm.generate_response.
  • services/learning/group_orchestrator.py still respects learning_interval_hours, so the high-frequency path is the V2 realtime/tiered trigger, not the 6-hour scheduler.
  • The original [Bug] #232 WebUI logs also map to routine /api/persona_updates polling; those diagnostics remain downgraded from INFO to DEBUG.

Tests

  • python -m pytest tests\unit\test_learning_chain_regressions.py tests\unit\test_config.py tests\unit\test_config_service.py tests\unit\test_persona_review_service.py -q (159 passed)
  • python -m py_compile services\learning\message_pipeline.py config.py tests\unit\test_learning_chain_regressions.py tests\unit\test_config.py webui\services\persona_review_service.py tests\unit\test_persona_review_service.py
  • python -m ruff check services\learning\message_pipeline.py config.py tests\unit\test_learning_chain_regressions.py tests\unit\test_config.py webui\services\persona_review_service.py tests\unit\test_persona_review_service.py
  • git diff --check

Install validation

  • Attempted earlier to copy into C:\Users\zacza\Desktop\x\AstrBot\data\plugins\astrbot_plugin_self_learning, run py_compile, import smoke, and pre-review.
  • Blocked by Windows ACL Access denied reading/writing the installed plugin directory; no permission changes attempted.

Refs #232

@sourcery-ai

sourcery-ai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adjusts persona review polling logs to use DEBUG instead of INFO for routine dashboard polling, and adds a regression test to ensure these diagnostic messages no longer appear at INFO level.

Sequence diagram for dashboard persona update polling with DEBUG logging

sequenceDiagram
    actor Dashboard
    participant WebServer
    participant PersonaReviewService
    participant PersonaUpdater
    participant DatabaseManager
    participant Logger

    Dashboard->>WebServer: GET /api/persona_updates
    WebServer->>PersonaReviewService: get_pending_persona_updates(limit, offset)

    opt persona_updater available
        PersonaReviewService->>Logger: debug("正在获取传统人格更新...")
        PersonaReviewService->>PersonaUpdater: get_pending_persona_updates()
        PersonaUpdater-->>PersonaReviewService: traditional_updates
        PersonaReviewService->>Logger: debug("获取到 {len(traditional_updates)} 个传统人格更新")
    end

    opt database_manager available (persona learning)
        PersonaReviewService->>Logger: debug("正在获取人格学习审查...")
        PersonaReviewService->>DatabaseManager: get_pending_persona_learning_reviews()
        DatabaseManager-->>PersonaReviewService: persona_learning_reviews
        PersonaReviewService->>Logger: debug("获取到 {len(persona_learning_reviews)} 个人格学习审查")
    end

    opt database_manager available (style learning)
        PersonaReviewService->>Logger: debug("正在获取风格学习审查...")
        PersonaReviewService->>DatabaseManager: get_pending_style_reviews()
        DatabaseManager-->>PersonaReviewService: style_reviews
        PersonaReviewService->>Logger: debug("获取到 {len(style_reviews)} 个风格学习审查")
    end

    PersonaReviewService->>Logger: debug("共 {total} 条人格更新记录 ...")
    PersonaReviewService->>Logger: debug("分页返回: offset={offset}, limit={limit}, 本页 {len(paged_updates)} 条")

    PersonaReviewService-->>WebServer: paged_updates
    WebServer-->>Dashboard: JSON persona updates
Loading

File-Level Changes

Change Details Files
Downgrade routine persona review polling logs from INFO to DEBUG to reduce dashboard polling noise while preserving existing behavior and warnings/errors.
  • Changed log level from info to debug around fetching traditional persona updates, persona learning reviews, and style learning reviews within get_pending_persona_updates.
  • Changed the summary log of total persona update records from info to debug.
  • Changed the pagination log for offset/limit/page size from info to debug while leaving warning/error logging intact.
webui/services/persona_review_service.py
Add regression test to assert persona polling diagnostics no longer emit at INFO and still emit at DEBUG.
  • Imported the persona_review_service module under an alias to allow monkeypatching its logger.
  • Introduced a FakeLogger capturing info and debug messages while ignoring warning/error.
  • Used monkeypatch to replace the module logger, invoked get_pending_persona_updates with empty results, and asserted that routine markers do not appear in info logs but that pagination is logged at debug.
tests/unit/test_persona_review_service.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@EterUltimate EterUltimate added the bug Something isn't working label Jul 1, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The regression test hardcodes all the Chinese log message substrings, which makes it brittle to future rewording; consider asserting on log level and a smaller number of distinctive markers (or using a pattern) rather than the full text for each step.
  • Instead of monkeypatching the module-level logger with a custom FakeLogger, you could use pytest's caplog fixture to assert on log levels and messages, which would keep the test closer to the real logging behavior and reduce boilerplate.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The regression test hardcodes all the Chinese log message substrings, which makes it brittle to future rewording; consider asserting on log level and a smaller number of distinctive markers (or using a pattern) rather than the full text for each step.
- Instead of monkeypatching the module-level `logger` with a custom `FakeLogger`, you could use pytest's `caplog` fixture to assert on log levels and messages, which would keep the test closer to the real logging behavior and reduce boilerplate.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@EterUltimate EterUltimate changed the title fix: reduce persona review polling log noise fix: honor realtime setting for V2 learning Jul 1, 2026
@EterUltimate
EterUltimate force-pushed the codex/reduce-persona-review-log-noise branch from 43ae82a to 17ae8c4 Compare July 1, 2026 09:06
@EterUltimate
EterUltimate merged commit da0b30c into NickCharlie:main Jul 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant