Class HarnessSkillMiddleware

java.lang.Object
io.agentscope.harness.agent.middleware.HarnessSkillMiddleware
All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase, HarnessRuntimeMiddleware

public class HarnessSkillMiddleware extends Object implements HarnessRuntimeMiddleware
Harness-native skill middleware. Replaces the legacy DynamicSkillMiddleware subclass with a standalone implementation that owns a SkillRuntime.

Per onSystemPrompt pass:

  1. Resolve the current RuntimeContext from the agent.
  2. Iterate repositories low-to-high priority and merge by AgentSkill.name (later wins).
  3. Apply the optional SkillVisibilityFilter.
  4. Stage Layer-1/Layer-2 marketplace skills' resources into <wsRoot>/.skills-cache/<source-ns>/<skill>/ via MarketplaceStager.
  5. Build a SkillCatalog of HarnessSkillEntry (with lazy resources and resolved filesRoot).
  6. Install the catalog into the SkillRuntime, which (idempotently) registers the load_skill_through_path tool on the agent's runtime toolkit.
  7. 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

    Constructors
    Constructor
    Description
    HarnessSkillMiddleware(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 Type
    Method
    Description
    reactor.core.publisher.Mono<String>
    onSystemPrompt(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, String currentPrompt)
     
    void
    prestageMarketplaceSkills(io.agentscope.core.agent.RuntimeContext ctx)
    Pre-stages marketplace skill resources to .skills-cache/ on the host workspace.
    Visible for tests / introspection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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 be null)
      visibilityFilter - optional per-request filter (canary/allow-list)
      stager - marketplace stager; null disables staging entirely
      shellPathPolicy - policy for resolving <files-root> per shell mode; never null — pass ShellPathPolicy.noShell() when no shell tool is registered
  • Method Details

    • runtime

      public SkillRuntime 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:
      onSystemPrompt in interface io.agentscope.core.middleware.MiddlewareBase