类 DynamicSkillMiddleware
- 所有已实现的接口:
MiddlewareBase,ToolkitAware
repositories
on every call() via onSystemPrompt(Agent, RuntimeContext, String), replacing the static
skill prompt with a per-call view that supports per-user skill isolation and one-click
marketplace integration.
The repository list is iterated low-priority first; when two repositories provide a skill
with the same AgentSkill.getName(), the later (higher-priority) entry wins.
Rebuilding on every call is intentional: per-user namespaced repositories may return
different content under the same skill name as the RuntimeContext switches users, so
caching by skill id alone would mask those swaps. bindToolkit /
registerSkillLoadTool are idempotent on a fresh SkillBox, so the rebuild stays
cheap.
Subclasses can plug runtime visibility logic (canary lists, environment gates, etc.) by
overriding filterVisible(List, RuntimeContext) — the default implementation returns
the input list unchanged.
-
构造器概要
构造器构造器说明DynamicSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit) DynamicSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter) DynamicSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, boolean codeExecutionEnabled, Path workDir) Full constructor. -
方法概要
修饰符和类型方法说明protected List<AgentSkill> filterVisible(List<AgentSkill> raw, RuntimeContext ctx) Hook for subclasses to drop skills that should not be visible in the current request (canary releases, allow-lists, environment gates, …).Returns the most recently materialisedSkillBox, ornullwhen no skills are visible yet (e.g. before the firstcall()).reactor.core.publisher.Mono<String> onSystemPrompt(Agent agent, RuntimeContext ctx, String currentPrompt) Transform the system prompt string (pipeline pattern).voidrebindToolkit(Toolkit toolkit) Replace this component's toolkit reference with the given instance.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.middleware.MiddlewareBase
onActing, onAgent, onModelCall, onReasoning
-
构造器详细资料
-
DynamicSkillMiddleware
-
DynamicSkillMiddleware
public DynamicSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter) -
DynamicSkillMiddleware
public DynamicSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, boolean codeExecutionEnabled, Path workDir) Full constructor.- 参数:
repositories- compose-ordered list (low-to-high priority); merged by skill nametoolkit- toolkit to registerload_skill_through_pathonbuilderFilter- optional builder-time skill filter; null treated asSkillFilter.all()codeExecutionEnabled- whentrue, toggles the prompt provider's code-execution block. Set this only when the agent has a shell-like tool wired in; otherwise the prompt asks the model to do things it cannot.workDir- stable working directory foruploadSkillFiles;null⇒ the middleware mkdtemps one on first reload and reuses it
-
-
方法详细资料
-
getCurrentSkillBox
Returns the most recently materialisedSkillBox, ornullwhen no skills are visible yet (e.g. before the firstcall()). -
rebindToolkit
从接口复制的说明:ToolkitAwareReplace this component's toolkit reference with the given instance.Called by the agent builder after deep-copying the toolkit. Implementations should update their internal toolkit reference and, if necessary, re-register any tools they had previously registered on the old toolkit.
- 指定者:
rebindToolkit在接口中ToolkitAware- 参数:
toolkit- the deep-copied toolkit that the agent will actually use; nevernull
-
onSystemPrompt
public reactor.core.publisher.Mono<String> onSystemPrompt(Agent agent, RuntimeContext ctx, String currentPrompt) 从接口复制的说明:MiddlewareBaseTransform the system prompt string (pipeline pattern).Multiple middlewares are applied sequentially; each receives the output of the previous one.
- 指定者:
onSystemPrompt在接口中MiddlewareBase- 参数:
agent- the agent instancectx- per-call runtime context (session, user, attributes)currentPrompt- the current system prompt- 返回:
- the (possibly transformed) system prompt
-
filterVisible
Hook for subclasses to drop skills that should not be visible in the current request (canary releases, allow-lists, environment gates, …). Called once percall(), after merging across repositories and before theSkillBoxis rebuilt.Default implementation returns
rawunchanged.- 参数:
raw- the merged, deduplicated skill list (low-to-high repository priority order)ctx- the per-callRuntimeContext; nevernull- 返回:
- the visible subset (must not be
null; an empty list short-circuits the prompt update for this call)
-