HarnessSkillMiddleware
@SuppressWarnings("deprecation") public class HarnessSkillMiddleware implements HarnessRuntimeMiddleware
io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:72–411Harness 技能中间件,在智能体执行流程中提供横切扩展。位于 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
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 (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
方法摘要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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repositories | List<AgentSkillRepository> | repositories(类型 `List`)。The repositories. |
toolkit | Toolkit | 工具包(类型 `Toolkit`)。The toolkit. |
io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:116–118HarnessSkillMiddleware
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter)
初始化 HarnessSkillMiddleware 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repositories | List<AgentSkillRepository> | repositories(类型 `List`)。The repositories. |
toolkit | Toolkit | 工具包(类型 `Toolkit`)。The toolkit. |
builderFilter | SkillFilter | 构建器过滤器(类型 `SkillFilter`)。The builder filter. |
io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:120–123HarnessSkillMiddleware
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter)
初始化 HarnessSkillMiddleware 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repositories | List<AgentSkillRepository> | repositories(类型 `List`)。The repositories. |
toolkit | Toolkit | 工具包(类型 `Toolkit`)。The toolkit. |
builderFilter | SkillFilter | 构建器过滤器(类型 `SkillFilter`)。The builder filter. |
visibilityFilter | SkillVisibilityFilter | visibility 过滤器(类型 `SkillVisibilityFilter`)。The visibility filter. |
io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:125–137HarnessSkillMiddleware
public HarnessSkillMiddleware(List<AgentSkillRepository> repositories, Toolkit toolkit, SkillFilter builderFilter, SkillVisibilityFilter visibilityFilter, MarketplaceStager stager, ShellPathPolicy shellPathPolicy)
初始化 HarnessSkillMiddleware 实例。
Full constructor.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repositories | List<AgentSkillRepository> | repositories(类型 `List`)。compose-ordered list (low-to-high priority) |
toolkit | Toolkit | 工具包(类型 `Toolkit`)。toolkit being assembled for the agent |
builderFilter | SkillFilter | 构建器过滤器(类型 `SkillFilter`)。skill filter passed at agent build time (may be `null`) |
visibilityFilter | SkillVisibilityFilter | visibility 过滤器(类型 `SkillVisibilityFilter`)。optional per-request filter (canary/allow-list) |
stager | MarketplaceStager | stager(类型 `MarketplaceStager`)。marketplace stager; `null` disables staging entirely |
shellPathPolicy | ShellPathPolicy | shell 路径策略(类型 `ShellPathPolicy`)。policy for resolving ` ` per shell mode; never `null` — pass `ShellPathPolicy#noShell()` when no shell tool is registered |
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)
执行 frozen 方法。
Creates a middleware whose merged repository view is captured once during construction.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repositories | List<AgentSkillRepository> | repositories(类型 `List`)。The repositories. |
toolkit | Toolkit | 工具包(类型 `Toolkit`)。The toolkit. |
builderFilter | SkillFilter | 构建器过滤器(类型 `SkillFilter`)。The builder filter. |
visibilityFilter | SkillVisibilityFilter | visibility 过滤器(类型 `SkillVisibilityFilter`)。The visibility filter. |
stager | MarketplaceStager | stager(类型 `MarketplaceStager`)。The stager. |
shellPathPolicy | ShellPathPolicy | shell 路径策略(类型 `ShellPathPolicy`)。The shell path policy. |
HarnessSkillMiddlewareio/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:172–187runtime
public SkillRuntime runtime()
返回运行时。
Visible for tests / introspection.
SkillRuntimeio/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:217–219isolationScope
public HarnessSkillMiddleware isolationScope(IsolationScope scope)
执行隔离范围相关操作。
Overrides the isolation dimension used to separate .skills-cache subtrees.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
scope | IsolationScope | 范围(类型 `IsolationScope`)。The scope. |
HarnessSkillMiddlewareio/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:225–228isFrozen
public boolean isFrozen()
判断是否 isFrozen。
Whether repository enumeration is frozen to the construction-time snapshot.
booleanio/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:231–233prestageMarketplaceSkills
public void prestageMarketplaceSkills(RuntimeContext ctx)
设置该参数。
Pre-stages marketplace skill resources to .skills-cache/ on the host workspace.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。the per-call runtime context |
io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:243–259onSystemPrompt
public Mono<String> onSystemPrompt(Agent agent, RuntimeContext ctx, String currentPrompt)
处理系统提示词事件。
Performs the on system prompt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
currentPrompt | String | 当前提示词(类型 `String`)。The current prompt. |
Mono<String>io/agentscope/harness/agent/middleware/HarnessSkillMiddleware.java:261–315