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. Bind the catalog to the current RuntimeContext through SkillRuntime, which also (idempotently) registers load_skill_through_path on the runtime toolkit.
  7. 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

    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
    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.
    boolean
    Whether repository enumeration is frozen to the construction-time snapshot.
    Overrides the isolation dimension used to separate .skills-cache subtrees.
    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, 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 agent
      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

    • 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

      public SkillRuntime runtime()
      Visible for tests / introspection.
    • isolationScope

      public HarnessSkillMiddleware isolationScope(IsolationScope scope)
      Overrides the isolation dimension used to separate .skills-cache subtrees. Defaults to IsolationScope.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:
      onSystemPrompt in interface io.agentscope.core.middleware.MiddlewareBase