SkillUsageMiddleware
public class SkillUsageMiddleware implements HarnessRuntimeMiddleware
源码Source
io/agentscope/harness/agent/middleware/SkillUsageMiddleware.java:42–137技能用量中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.harness.agent.middleware 包,实现 HarnessRuntimeMiddleware。核心成员包括 onActing、SkillUsageMiddleware。
Bumps SkillUsageStore counters whenever the agent invokes a SkillBox-registered skill
loader (e.g. load_skill_through_path). Provenance gating happens inside the store —
only skills tagged created_by="agent" or "agent-draft" are recorded.
Counter bumping is best-effort and runs eagerly when onActing is entered (before
the actual tool call returns). The semantics are "the model decided to invoke this skill on
this turn" — not "the call succeeded". This matches hermes-agent's telemetry shape and is
cheap to compute.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SkillUsageMiddleware(SkillUsageStore usageStore) | 初始化 `SkillUsageMiddleware` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Flux<AgentEvent> onActing(Agent agent, RuntimeContext ctx, ActingInput input, Function<ActingInput, Flux<AgentEvent>> next) | 处理执行事件。 Performs the on acting operation. |
构造器详情Constructor Detail
SkillUsageMiddleware
public SkillUsageMiddleware(SkillUsageStore usageStore)
初始化 SkillUsageMiddleware 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
usageStore | SkillUsageStore | 用量存储(类型 `SkillUsageStore`)。The usage store. |
源码Source
io/agentscope/harness/agent/middleware/SkillUsageMiddleware.java:58–60方法详情Method Detail
onActing
public Flux<AgentEvent> onActing(Agent agent, RuntimeContext ctx, ActingInput input, Function<ActingInput, Flux<AgentEvent>> next)
处理执行事件。
Performs the on acting operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | ActingInput | 输入消息(类型 `ActingInput`)。The input. |
next | Function<ActingInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>返回Flux。Returns flux.
源码Source
io/agentscope/harness/agent/middleware/SkillUsageMiddleware.java:62–74