Skip to content

fix: refresh in-memory provider config after deleting provider - #9568

Merged
Soulter merged 1 commit into
AstrBotDevs:masterfrom
Enterpr1se0:fix/provider-manager-delete-stale-config
Aug 7, 2026
Merged

fix: refresh in-memory provider config after deleting provider#9568
Soulter merged 1 commit into
AstrBotDevs:masterfrom
Enterpr1se0:fix/provider-manager-delete-stale-config

Conversation

@Enterpr1se0

@Enterpr1se0 Enterpr1se0 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Modifications / 改动点

ProviderManager.delete_provider() removes the provider from the persisted config and terminates its instance, but it never syncs the in-memory providers_config. As a result, the dashboard's provider list (which reads provider_manager.providers_config) keeps showing the deleted provider until the process restarts or another operation triggers a reload.

This change syncs providers_config with the just-saved config immediately after deletion (same pattern already used in create_provider), covering both delete-by-provider_id and delete-by-provider_source_id paths.

  • Modified: astrbot/core/provider/manager.py (delete_provider)

Screenshots or Test Results / 运行截图或测试结果

Verified in a fully-synced dev environment:

  • Regression test (tests/unit/test_provider_manager_delete.py) for this fix: 2 passed.
  • Reverse check: with the fix removed, the same test fails (confirms it reproduces the stale-list bug); restoring the fix makes it pass again.
  • Related existing unit tests (test_provider_stats.py, test_config.py, test_core_lifecycle.py, test_star_context.py): 78 passed.
  • ruff check and ruff format --check pass on the modified file.

Note: 3 t2i template tests in tests/test_dashboard.py fail, but they also fail on a clean checkout of master and are unrelated to this change.

Checklist / 检查清单

  • This is NOT a breaking change. / 这不是一个破坏性变更。
  • My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • No new dependencies are introduced.
  • My changes do not introduce malicious code.

Summary by Sourcery

Ensure provider deletions immediately refresh the in-memory provider configuration to keep API consumers in sync with persisted config.

Bug Fixes:

  • Fix stale provider list after deleting a provider by reloading the in-memory providers configuration from the saved config.

Tests:

  • Add a regression unit test verifying that deleting a provider updates the in-memory provider list and prevents stale entries from appearing.

ProviderManager.delete_provider removed the provider from the persisted
config but left self.providers_config pointing at the stale list, so the
dashboard kept showing deleted providers until a reload or restart.

Sync self.providers_config with the just-saved config after deletion so
the API/provider list reflects the removal immediately.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Aug 6, 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:

  • Consider extracting the providers_config refresh logic into a small helper used by create_provider, delete_provider, and any other mutating operations to ensure the in-memory config is consistently updated across all code paths.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the `providers_config` refresh logic into a small helper used by `create_provider`, `delete_provider`, and any other mutating operations to ensure the in-memory config is consistently updated across all code paths.

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.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 7, 2026
@Soulter
Soulter merged commit 609e576 into AstrBotDevs:master Aug 7, 2026
21 checks passed
@Enterpr1se0
Enterpr1se0 deleted the fix/provider-manager-delete-stale-config branch August 7, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants