Skip to content

fix: skip queued LLM requests after disabling - #9843

Open
kidding-404 wants to merge 1 commit into
AstrBotDevs:masterfrom
kidding-404:codex/fix-9819-llm-disable-race
Open

fix: skip queued LLM requests after disabling#9843
kidding-404 wants to merge 1 commit into
AstrBotDevs:masterfrom
kidding-404:codex/fix-9819-llm-disable-race

Conversation

@kidding-404

@kidding-404 kidding-404 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Recheck the global and session-level LLM status after acquiring the session lock.
  • Skip queued requests when LLM access was disabled while they were waiting.
  • Add regression coverage for both global provider disabling and session-level LLM disabling.

Motivation

LLM availability was previously checked before entering the internal agent stage. A request that passed this check could wait for the session lock while an administrator disabled LLM access.

After acquiring the lock, the queued request continued without checking the latest state, which could cause delayed replies after LLM access had already been disabled.

This change performs a second authoritative check immediately before building and dispatching the agent request.

Fixes #9819.

Testing

  • uv run ruff format .
  • uv run ruff check .
  • uv run pytest tests/unit/test_session_lock.py -q
  • uv run pytest tests/unit/test_session_management_service.py -q
  • uv run pytest tests/test_conversation_checkpoint.py -q

Summary by Sourcery

Recheck LLM availability after queued requests acquire the session lock to prevent processing after access has been disabled.

Bug Fixes:

  • Skip queued LLM requests when global provider access or session-level LLM access is disabled while they wait for the session lock.

Tests:

  • Add regression coverage for queued requests affected by global and session-level LLM disabling.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Aug 27, 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 reviewed your changes and they look great!

Sourcery assessment

Approved.


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 area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

关闭了一会llm后bot还会主动发言

1 participant