Skip to content

fix: skip cron knowledge base injection#9059

Open
EterUltimate wants to merge 1 commit into
AstrBotDevs:masterfrom
EterUltimate:codex/automation-4-skip-cron-kb-20260628
Open

fix: skip cron knowledge base injection#9059
EterUltimate wants to merge 1 commit into
AstrBotDevs:masterfrom
EterUltimate:codex/automation-4-skip-cron-kb-20260628

Conversation

@EterUltimate

@EterUltimate EterUltimate commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Skip non-agentic automatic knowledge-base injection for scheduled cron events.
  • Add a regression test proving cron-triggered requests do not call retrieve_knowledge_base() or append KB results as user content.

Evidence

Verification

  • uv run pytest tests/unit/test_astr_main_agent.py -k "apply_kb" -v: 8 passed.
  • uv run ruff check astrbot/core/astr_main_agent.py tests/unit/test_astr_main_agent.py: passed.
  • uv run ruff format --check astrbot/core/astr_main_agent.py tests/unit/test_astr_main_agent.py: passed.
  • uv run astrbot --help: passed.
  • bunx pnpm@10.28.2 install --frozen-lockfile && bunx pnpm@10.28.2 run build in dashboard/: passed.
  • uv run pytest -q: 1648 passed, 28 failed locally on Windows in unrelated path/CRLF/file-uri/local-shell/config-directory tests.
  • tests/test_code_quality_typing.py: absent on current master.

Notes

  • Full ruff over the zipball copy scanned .venv because this was not a normal git checkout; source-file checks passed for the changed files.

Summary by Sourcery

Prevent knowledge-base injection from running for cron-triggered events and add coverage to ensure scheduled tasks do not treat KB results as user content.

Bug Fixes:

  • Skip non-agentic knowledge-base lookup when handling cron platform events to avoid injecting KB results into synthetic scheduled-task prompts.

Tests:

  • Add an async unit test verifying that _apply_kb does not call retrieve_knowledge_base or append extra user content for cron events.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend feature:knowledge-base The bug / feature is about knowledge base labels Jun 28, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a check in _apply_kb to skip applying the knowledge base when the event platform is 'cron' and agentic mode is disabled. Additionally, a unit test has been added to verify this behavior. There are no review comments, and I have no further feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@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 reviewed your changes and they look great!


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend feature:knowledge-base The bug / feature is about knowledge base size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant