AS AgentScopeAPI 手册 / API Reference

HarnessSkillMiddleware

@SuppressWarnings("deprecation") public class HarnessSkillMiddleware implements HarnessRuntimeMiddleware
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:72–411

Harness 技能中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.harness.agent.middleware 包,实现 HarnessRuntimeMiddleware。核心成员包括 frozen、runtime、isolationScope、isFrozen、prestageMarketplaceSkills、onSystemPrompt。

Harness-native skill middleware. Replaces the legacy DynamicSkillMiddleware subclass with a standalone implementation that owns a SkillRuntime.

Per onSystemPrompt pass:

  • Resolve the current RuntimeContext from 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>/ via MarketplaceStager.

  • Build a SkillCatalog of HarnessSkillEntry (with lazy resources and resolved filesRoot).

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

构造器Constructor说明Description
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit)
初始化 `HarnessSkillMiddleware` 实例。
Creates a new instance.
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter)
初始化 `HarnessSkillMiddleware` 实例。
Creates a new instance.
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter)
初始化 `HarnessSkillMiddleware` 实例。
Creates a new instance.
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy)
初始化 `HarnessSkillMiddleware` 实例。
Full constructor.

方法摘要Method Summary

方法Method说明Description
public static HarnessSkillMiddleware frozen(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy)
static
执行 `frozen` 方法。
Creates a middleware whose merged repository view is captured once during construction.
public SkillRuntime runtime()
返回运行时。
Visible for tests / introspection.
public HarnessSkillMiddleware isolationScope(IsolationScope scope)
执行隔离范围相关操作。
Overrides the isolation dimension used to separate `.skills-cache` subtrees.
public boolean isFrozen()
判断是否 `isFrozen`。
Whether repository enumeration is frozen to the construction-time snapshot.
public void prestageMarketplaceSkills(RuntimeContext ctx)
设置该参数。
Pre-stages marketplace skill resources to `.skills-cache/` on the host workspace.
public Mono<String> onSystemPrompt(Agent agent, RuntimeContext ctx, String currentPrompt)
处理系统提示词事件。
Performs the on system prompt operation.

构造器详情Constructor Detail

HarnessSkillMiddleware

public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit)

初始化 HarnessSkillMiddleware 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
repositoriesList<AgentSkillRepository>repositories(类型 `List`)。The repositories.
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:116–118

HarnessSkillMiddleware

public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter)

初始化 HarnessSkillMiddleware 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
repositoriesList<AgentSkillRepository>repositories(类型 `List`)。The repositories.
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
builderFilterSkillFilter构建器过滤器(类型 `SkillFilter`)。The builder filter.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:120–123

HarnessSkillMiddleware

public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter)

初始化 HarnessSkillMiddleware 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
repositoriesList<AgentSkillRepository>repositories(类型 `List`)。The repositories.
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
builderFilterSkillFilter构建器过滤器(类型 `SkillFilter`)。The builder filter.
visibilityFilterSkillVisibilityFiltervisibility 过滤器(类型 `SkillVisibilityFilter`)。The visibility filter.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:125–137

HarnessSkillMiddleware

public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy)

初始化 HarnessSkillMiddleware 实例。

Full constructor.

参数Parameters
名称Name类型Type说明Description
repositoriesList<AgentSkillRepository>repositories(类型 `List`)。compose-ordered list (low-to-high priority)
toolkitToolkit工具包(类型 `Toolkit`)。toolkit being assembled for the agent
builderFilterSkillFilter构建器过滤器(类型 `SkillFilter`)。skill filter passed at agent build time (may be `null`)
visibilityFilterSkillVisibilityFiltervisibility 过滤器(类型 `SkillVisibilityFilter`)。optional per-request filter (canary/allow-list)
stagerMarketplaceStagerstager(类型 `MarketplaceStager`)。marketplace stager; `null` disables staging entirely
shellPathPolicyShellPathPolicyshell 路径策略(类型 `ShellPathPolicy`)。policy for resolving ` ` per shell mode; never `null` — pass `ShellPathPolicy#noShell()` when no shell tool is registered
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:151–166

方法详情Method Detail

frozen

public static HarnessSkillMiddleware frozen(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy)
static

执行 frozen 方法。

Creates a middleware whose merged repository view is captured once during construction.

参数Parameters
名称Name类型Type说明Description
repositoriesList<AgentSkillRepository>repositories(类型 `List`)。The repositories.
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
builderFilterSkillFilter构建器过滤器(类型 `SkillFilter`)。The builder filter.
visibilityFilterSkillVisibilityFiltervisibility 过滤器(类型 `SkillVisibilityFilter`)。The visibility filter.
stagerMarketplaceStagerstager(类型 `MarketplaceStager`)。The stager.
shellPathPolicyShellPathPolicyshell 路径策略(类型 `ShellPathPolicy`)。The shell path policy.
返回Returns HarnessSkillMiddleware
返回HarnessSkillMiddleware。Returns harness skill middleware.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:172–187

runtime

public SkillRuntime runtime()

返回运行时。

Visible for tests / introspection.

返回Returns SkillRuntime
返回SkillRuntime。Returns skill runtime.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:217–219

isolationScope

public HarnessSkillMiddleware isolationScope(IsolationScope scope)

执行隔离范围相关操作。

Overrides the isolation dimension used to separate .skills-cache subtrees.

参数Parameters
名称Name类型Type说明Description
scopeIsolationScope范围(类型 `IsolationScope`)。The scope.
返回Returns HarnessSkillMiddleware
返回HarnessSkillMiddleware。Returns harness skill middleware.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:225–228

isFrozen

public boolean isFrozen()

判断是否 isFrozen。

Whether repository enumeration is frozen to the construction-time snapshot.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:231–233

prestageMarketplaceSkills

public void prestageMarketplaceSkills(RuntimeContext ctx)

设置该参数。

Pre-stages marketplace skill resources to .skills-cache/ on the host workspace.

参数Parameters
名称Name类型Type说明Description
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。the per-call runtime context
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:243–259

onSystemPrompt

public Mono<String> onSystemPrompt(Agent agent, RuntimeContext ctx, String currentPrompt)

处理系统提示词事件。

Performs the on system prompt operation.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
currentPromptString当前提示词(类型 `String`)。The current prompt.
返回Returns Mono<String>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:261–315

继承成员Inherited Members

继承自Methods inherited from MiddlewareBase
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.