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). - Install the catalog into the
SkillRuntime, which (idempotently) registers theload_skill_through_pathtool on the agent's runtime toolkit. - Render the
<available_skills>prompt block and append it to the current system prompt.
Toolkit note: the toolkit constructor parameter is accepted for API
compatibility but is not used for runtime tool registration. Instead,
onSystemPrompt(io.agentscope.core.agent.Agent, io.agentscope.core.agent.RuntimeContext, java.lang.String) always installs into agent.getToolkit() so the tool is
registered on the toolkit that the running agent actually uses for reasoning. This matters
because HarnessAgent makes a deep copy of
the toolkit when building the inner ReActAgent, so the
constructor-injected intermediate toolkit is not the same instance as the agent's live toolkit.
-
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 TypeMethodDescriptionreactor.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
-
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- accepted for API compatibility; not used for runtime registration (see class-level note on toolkit copy semantics)builderFilter- 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
-
runtime
Visible for tests / introspection. -
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
-