AS AgentScopeAPI 手册 / API Reference

SkillRuntime

public final class SkillRuntime
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:36–154

技能运行时,让智能体以受控方式调用外部能力。位于 io.agentscope.harness.agent.skill.runtime 包。核心成员包括 currentCatalog、loadTool、prepareToolkit、install、renderPrompt、SkillRuntime。

Aggregates the singleton SkillLoadTool and the SkillPromptBuilder. io.agentscope.harness.agent.middleware.HarnessSkillMiddleware owns one instance and installs each filtered SkillCatalog into that call's RuntimeContext.

The load_skill_through_path tool is prepared during agent construction and verified idempotently on later installs. Normal tool calls resolve the catalog from their RuntimeContext, so concurrent sessions cannot overwrite or observe one another's filtered skill view. A separate compatibility catalog is retained only for deprecated, context-free callers.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SkillRuntime()
初始化 `SkillRuntime` 实例。
Creates a new instance.
public SkillRuntime(SkillPromptBuilder promptBuilder)
初始化 `SkillRuntime` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public SkillCatalog currentCatalog()
deprecated
返回当前目录。
Returns the catalog installed through the deprecated context-free API.
public SkillCatalog currentCatalog(RuntimeContext context)
设置当前目录。
Returns the catalog bound to `context`, or an empty catalog when none is bound.
public AgentTool loadTool()
加载工具。
Underlying stateless tool instance.
public void prepareToolkit(Toolkit toolkit)
设置该参数。
Ensures the skill loading tool is present as an ungrouped tool.
public void install(SkillCatalog catalog, RuntimeContext context, Toolkit toolkit)
执行 `install` 方法。
Bind a catalog to the current call and ensure the load tool is registered on the toolkit (idempotent).
public void install(SkillCatalog catalog, Toolkit toolkit)
deprecated
执行 `install` 方法。
Installs a catalog for legacy context-free callers.
public String renderPrompt(SkillCatalog catalog, SkillFilter filter)
渲染提示词。
Renders the `<available_skills>` block + (when applicable) the code-execution prompt.

构造器详情Constructor Detail

SkillRuntime

public SkillRuntime()

初始化 SkillRuntime 实例。

Creates a new instance.

源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:46–48

SkillRuntime

public SkillRuntime(SkillPromptBuilder promptBuilder)

初始化 SkillRuntime 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
promptBuilderSkillPromptBuilder提示词构建器(类型 `SkillPromptBuilder`)。The prompt builder.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:50–53

方法详情Method Detail

currentCatalog

public SkillCatalog currentCatalog()
deprecated

返回当前目录。

Returns the catalog installed through the deprecated context-free API.

已弃用。Deprecated. 已弃用,请改用受支持的替代 API。Use `#currentCatalog(RuntimeContext)` so catalog lookup is request-scoped.
返回Returns SkillCatalog
返回SkillCatalog。Returns skill catalog.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:60–63

currentCatalog

public SkillCatalog currentCatalog(RuntimeContext context)

设置当前目录。

Returns the catalog bound to context, or an empty catalog when none is bound.

参数Parameters
名称Name类型Type说明Description
contextRuntimeContext上下文(类型 `RuntimeContext`)。The context.
返回Returns SkillCatalog
返回SkillCatalog。Returns skill catalog.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:66–68

loadTool

public AgentTool loadTool()

加载工具。

Underlying stateless tool instance.

返回Returns AgentTool
返回AgentTool。Returns agent tool.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:82–84

prepareToolkit

public void prepareToolkit(Toolkit toolkit)

设置该参数。

Ensures the skill loading tool is present as an ungrouped tool.

参数Parameters
名称Name类型Type说明Description
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:94–110

install

public void install(SkillCatalog catalog, RuntimeContext context, Toolkit toolkit)

执行 install 方法。

Bind a catalog to the current call and ensure the load tool is registered on the toolkit (idempotent).

参数Parameters
名称Name类型Type说明Description
catalogSkillCatalog目录(类型 `SkillCatalog`)。the call snapshot; pass `SkillCatalog#empty()` to clear visibility
contextRuntimeContext上下文(类型 `RuntimeContext`)。the current call context; may be `null`, in which case no catalog is exposed
toolkitToolkit工具包(类型 `Toolkit`)。the toolkit to install onto; may be `null` (then only catalog is updated)
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:125–130

install

public void install(SkillCatalog catalog, Toolkit toolkit)
deprecated

执行 install 方法。

Installs a catalog for legacy context-free callers.

已弃用。Deprecated. 已弃用,请改用受支持的替代 API。Use `#install(SkillCatalog, RuntimeContext, Toolkit)`.
参数Parameters
名称Name类型Type说明Description
catalogSkillCatalog目录(类型 `SkillCatalog`)。The catalog.
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:141–146

renderPrompt

public String renderPrompt(SkillCatalog catalog, SkillFilter filter)

渲染提示词。

Renders the block + (when applicable) the code-execution prompt.

参数Parameters
名称Name类型Type说明Description
catalogSkillCatalog目录(类型 `SkillCatalog`)。The catalog.
filterSkillFilter过滤条件(类型 `SkillFilter`)。The filter.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/skill/runtime/SkillRuntime.java:149–153
基于官方固定版本源码静态生成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.