AS AgentScopeAPI 手册 / API Reference

SessionsTool

public class SessionsTool
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:61–577

会话工具,封装可被智能体调用的能力。位于 io.agentscope.harness.coding.session.tool 包。核心成员包括 sessionsSpawn、sessionsSend、sessionsList、sessionsHistory、sessionsPendingCompletions、SessionsTool。

Tool facade exposing managed subagent session operations to the agent.

Mirrors the OpenClaw sessions tool set:

  • sessions_spawn — spawn an isolated subagent session

  • sessions_send — send a message to an existing session by key or label

  • sessions_list — list managed sessions with optional filters

  • sessions_history — read a session's conversation transcript

Async operations (timeout_seconds=0) submit work to TaskRepository and return a task_id for retrieval via the companion TaskTool. The same completion may also be queued for the requester as a structured PendingCompletion (poll with sessions_pending_completions).

Uses SessionAgentManager for full session lifecycle management.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SessionsTool(SessionAgentManager sessionAgentManager, TaskRepository taskRepository, String parentSessionKey, int parentSpawnDepth)
初始化 `SessionsTool` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String sessionsSpawn(String agentId, String task, String label, String mode, Integer timeoutSeconds)
执行 `sessionsSpawn` 方法。
Performs the sessions spawn operation.
public String sessionsSend(String sessionKey, String label, String message, Integer timeoutSeconds)
执行会话发送相关操作。
Performs the sessions send operation.
public String sessionsList(String kinds, Integer limit, Integer activeMinutes)
执行会话列表相关操作。
Performs the sessions list operation.
public String sessionsHistory(String sessionKey, Integer limit)
执行会话历史相关操作。
Performs the sessions history operation.
public String sessionsPendingCompletions(String requesterSessionKey, Integer limit)
执行会话待处理补全相关操作。
Performs the sessions pending completions operation.

构造器详情Constructor Detail

SessionsTool

public SessionsTool(SessionAgentManager sessionAgentManager, TaskRepository taskRepository, String parentSessionKey, int parentSpawnDepth)

初始化 SessionsTool 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
sessionAgentManagerSessionAgentManager会话智能体管理器(类型 `SessionAgentManager`)。full session lifecycle manager
taskRepositoryTaskRepository任务仓库(类型 `TaskRepository`)。background task store (for async fire-and-forget)
parentSessionKeyString父级会话键(类型 `String`)。session key of the agent that owns this tool instance (null = main)
parentSpawnDepthint父级 Spawn Depth(类型 `int`)。spawn depth of the owning agent (0 = main agent)
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:86–96

方法详情Method Detail

sessionsSpawn

public String sessionsSpawn(String agentId, String task, String label, String mode, Integer timeoutSeconds)

执行 sessionsSpawn 方法。

Performs the sessions spawn operation.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
taskString任务(类型 `String`)。The task.
labelString标签(类型 `String`)。The label.
modeString模式(类型 `String`)。The mode.
timeoutSecondsInteger超时秒(类型 `Integer`)。The timeout seconds.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:102–251

sessionsSend

public String sessionsSend(String sessionKey, String label, String message, Integer timeoutSeconds)

执行会话发送相关操作。

Performs the sessions send operation.

参数Parameters
名称Name类型Type说明Description
sessionKeyString会话键(类型 `String`)。The session key.
labelString标签(类型 `String`)。The label.
messageString消息(类型 `String`)。The message.
timeoutSecondsInteger超时秒(类型 `Integer`)。The timeout seconds.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:257–352

sessionsList

public String sessionsList(String kinds, Integer limit, Integer activeMinutes)

执行会话列表相关操作。

Performs the sessions list operation.

参数Parameters
名称Name类型Type说明Description
kindsStringkinds(类型 `String`)。The kinds.
limitInteger数量上限(类型 `Integer`)。The limit.
activeMinutesIntegeractive 分钟(类型 `Integer`)。The active minutes.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:358–422

sessionsHistory

public String sessionsHistory(String sessionKey, Integer limit)

执行会话历史相关操作。

Performs the sessions history operation.

参数Parameters
名称Name类型Type说明Description
sessionKeyString会话键(类型 `String`)。The session key.
limitInteger数量上限(类型 `Integer`)。The limit.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:428–463

sessionsPendingCompletions

public String sessionsPendingCompletions(String requesterSessionKey, Integer limit)

执行会话待处理补全相关操作。

Performs the sessions pending completions operation.

参数Parameters
名称Name类型Type说明Description
requesterSessionKeyStringrequester 会话键(类型 `String`)。The requester session key.
limitInteger数量上限(类型 `Integer`)。The limit.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/session/tool/SessionsTool.java:469–520
基于官方固定版本源码静态生成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.