AS AgentScopeAPI 手册 / API Reference

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
usageStoreSkillUsageStore用量存储(类型 `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
agentAgent智能体(类型 `Agent`)。The agent.
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
inputActingInput输入消息(类型 `ActingInput`)。The input.
nextFunction<ActingInput, Flux<AgentEvent>>下一个(类型 `Function >`)。The next.
返回Returns Flux<AgentEvent>
返回Flux。Returns flux.
源码Source io/agentscope/harness/agent/middleware/SkillUsageMiddleware.java:62–74

继承成员Inherited Members

基于官方固定版本源码静态生成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.