Class HarnessSkillMiddleware
java.lang.Object
io.agentscope.harness.agent.middleware.HarnessSkillMiddleware
- All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase,HarnessRuntimeMiddleware
Harness-native skill middleware. Replaces the legacy
DynamicSkillMiddleware subclass
with a standalone implementation that owns a SkillRuntime.
Per onSystemPrompt pass:
- Resolve the current
RuntimeContextfrom the agent. - Iterate repositories low-to-high priority and merge by
AgentSkill.name(later wins). - Apply the optional
SkillVisibilityFilter. - Stage Layer-1/Layer-2 marketplace skills' resources into
<wsRoot>/.skills-cache/<source-ns>/<skill>/viaMarketplaceStager. - Build a
SkillCatalogofHarnessSkillEntry(with lazy resources and resolvedfilesRoot). - Bind the catalog to the current
RuntimeContextthroughSkillRuntime, which also (idempotently) registersload_skill_through_pathon the runtime toolkit. - Render the
<available_skills>prompt block and append it to the current system prompt.
Toolkit note: construction registers the load tool as ungrouped before ReActAgent copies the toolkit, so persisted sessions with an empty
active-group list still see it. Each system-prompt pass also verifies the live toolkit, so direct
middleware usage remains supported.
-
Constructor Summary
ConstructorsConstructorDescriptionHarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit) HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter) HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter) HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic HarnessSkillMiddlewarefrozen(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy) Creates a middleware whose merged repository view is captured once during construction.booleanisFrozen()Whether repository enumeration is frozen to the construction-time snapshot.isolationScope(IsolationScope scope) Overrides the isolation dimension used to separate.skills-cachesubtrees.reactor.core.publisher.Mono<String>onSystemPrompt(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, String currentPrompt) voidprestageMarketplaceSkills(io.agentscope.core.agent.RuntimeContext ctx) Pre-stages marketplace skill resources to.skills-cache/on the host workspace.runtime()Visible for tests / introspection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.middleware.MiddlewareBase
onActing, onAgent, onModelCall, onReasoning, order
-
Constructor Details
-
HarnessSkillMiddleware
public HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit) -
HarnessSkillMiddleware
public HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter) -
HarnessSkillMiddleware
public HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter) -
HarnessSkillMiddleware
public HarnessSkillMiddleware(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy) Full constructor.- Parameters:
repositories- compose-ordered list (low-to-high priority)toolkit- toolkit being assembled for the agentbuilderFilter- skill filter passed at agent build time (may benull)visibilityFilter- optional per-request filter (canary/allow-list)stager- marketplace stager;nulldisables staging entirelyshellPathPolicy- policy for resolving<files-root>per shell mode; nevernull— passShellPathPolicy.noShell()when no shell tool is registered
-
-
Method Details
-
frozen
public static HarnessSkillMiddleware frozen(List<io.agentscope.core.skill.repository.AgentSkillRepository> repositories, io.agentscope.core.tool.Toolkit toolkit, io.agentscope.core.skill.SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy) Creates a middleware whose merged repository view is captured once during construction. Filters remain per-call, and lazy resource access remains bound to the current context. -
runtime
Visible for tests / introspection. -
isolationScope
Overrides the isolation dimension used to separate.skills-cachesubtrees. Defaults toIsolationScope.USER, matching the default for runtime data. -
isFrozen
public boolean isFrozen()Whether repository enumeration is frozen to the construction-time snapshot. -
prestageMarketplaceSkills
public void prestageMarketplaceSkills(io.agentscope.core.agent.RuntimeContext ctx) Pre-stages marketplace skill resources to.skills-cache/on the host workspace. Intended to be called before sandbox start so that workspace projection picks up the staged content in the same call. Safe to call multiple times — staging is idempotent (content-hash guarded).- Parameters:
ctx- the per-call runtime context
-
onSystemPrompt
public reactor.core.publisher.Mono<String> onSystemPrompt(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, String currentPrompt) - Specified by:
onSystemPromptin interfaceio.agentscope.core.middleware.MiddlewareBase
-