Skip to content

perf(agent): cache plugin list instead of reading plugin config per a… - #1456

Merged
yileicn merged 1 commit into
SciSharp:masterfrom
yileicn:master
Oct 13, 2026
Merged

yileicn merged 1 commit into
SciSharp:masterfrom
yileicn:master

Conversation

@yileicn

@yileicn yileicn commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

perf(agent): cache plugin list instead of reading plugin config per agent

  • GetPlugin reads a shared cached plugin list; GetAgents loads it once per call
  • Clear the cache after a plugin is installed or removed

…gent

- GetPlugin reads a shared cached plugin list; GetAgents loads it once per call
- Clear the cache after a plugin is installed or removed
@qodo-code-review

qodo-code-review Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Cache plugin list for agent lookups

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Cache the plugin list across individual agent lookups to avoid repeated configuration reads.
• Load plugins once when listing agents, then match each agent against that list.
• Clear cached data after plugin status changes so agent lookups reflect them promptly.
Diagram

graph TD
  A["GetAgents"] --> D["PluginLoader"] --> E[("Plugin config")]
  B["GetPlugin"] --> C["Shared cache"] --> D
  F["UpdatePluginStatus"] --> G["Clear cache"] --> C
  F --> E
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Targeted plugin-cache invalidation
  • ➕ Preserves unrelated cached entries when plugin status changes.
  • ➖ Requires a cache-key-specific invalidation mechanism beyond the existing clear operation.
2. Request-scoped plugin list
  • ➕ Avoids cross-request staleness and explicit invalidation.
  • ➖ Still reads plugin configuration on each request rather than sharing the result.

Recommendation: The shared list is appropriate for reducing repeated reads across individual lookups, and loading once per listing avoids per-agent reads. Keep this approach unless plugin status changes are frequent enough that clearing all cached entries becomes costly; then add targeted invalidation.

Files changed (3) +20 / -2

Enhancement (3) +20 / -2
AgentService.GetAgents.csLoad plugins once per agent listing +3/-1

Load plugins once per agent listing

• Fetches the plugin list before iterating over agents and matches each agent against it, replacing a plugin lookup for every agent.

src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs

AgentService.GetPlugin.csCache the shared plugin list for individual lookups +14/-1

Cache the shared plugin list for individual lookups

• Adds a cached, argument-free plugin-list loader and extracts agent-to-plugin matching into a shared helper. Individual lookups retain the existing fallback plugin definition.

src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetPlugin.cs

PluginLoader.csClear caches after plugin status changes +3/-0

Clear caches after plugin status changes

• Clears cached entries after a plugin is enabled or disabled so subsequent agent lookups can reflect the changed status.

src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs

@yuyixg

yuyixg commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

reviewed

@yileicn
yileicn merged commit 94d0230 into SciSharp:master Oct 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants