SessionTurnRunner
@Service public class SessionTurnRunner
io/agentscope/builder/web/managed/SessionTurnRunner.java:70–940会话轮次运行器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.managed 包。核心成员包括 runTurnAsync、resumeWithToolResults、abortManagedAttempt、interrupt、interruptRun、releaseSession。
Executes a managed session turn against the harness agent and records session events.
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void runTurnAsync(ManagedSessionDto session, String userMessage) | 运行轮次异步。 Runs a turn asynchronously so inbound HTTP handlers can return quickly. |
public void runTurnAsync(ManagedSessionDto session, String userMessage, Runnable onAdmitted) | 运行轮次异步。 Runs a turn asynchronously, invoking `onAdmitted` once the turn is certain to run — the
lease is held by then, so a caller can record the message that triggered it only if it will
actually be processed. |
public void resumeWithToolResults(ManagedSessionDto session, List<ToolResultBlock> toolResults) | 执行恢复使用工具结果相关操作。 Resumes a suspended turn with external tool results (self-hosted worker /
`user.tool_result`). |
public void abortManagedAttempt(String sessionId, String agentTaskId, String attemptId, long dispatchGeneration, String turnId, String reason) | 执行中止托管尝试相关操作。 Handles a fenced abort locally or queues it for the replica holding the matching turn lease. |
public void interrupt(String sessionId) | 请求中断当前执行。 Cancels an in-flight turn. |
public void interruptRun(String ownerId, String sessionId, String runId) | 执行中断运行相关操作。 Cancels an exact run after the caller has authorized access to the session. |
public void releaseSession(String sessionId, String ownerId) | 执行 `releaseSession` 方法。 Drops the footprint of a session the control plane has deleted: an in-flight turn is cancelled
first, then the team wakeup bindings, the cached instance with its persisted agent state, and
the per-session preview bookkeeping. |
public static ToolResultBlock toolResultFromPayload(Map<String, Object> payload)static | 构建`ToolResultBlock`来自工作进程/用户工具_结果负载。 Builds a `ToolResultBlock` from a worker/user tool_result payload. |
构造器详情Constructor Detail
SessionTurnRunner
public SessionTurnRunner(HarnessAgentBuildService agentBuildService, DataSessionService sessionService, SessionEventLog eventLog, SessionEventMapper eventMapper, SessionEventPreviewBus previewBus, DataEnvironmentService environmentService, HandsLeaseService handsLeaseService, TurnLeaseService turnLeaseService, CoordinationStore coordinationStore, DeletedSessionRegistry deletedSessions, ControlPlaneClient controlPlaneClient, ToolConfirmationCoordinator confirmationCoordinator, AgentRunRegistry runRegistry)
初始化 SessionTurnRunner 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentBuildService | HarnessAgentBuildService | 智能体构建服务(类型 `HarnessAgentBuildService`)。The agent build service. |
sessionService | DataSessionService | 会话服务(类型 `DataSessionService`)。The session service. |
eventLog | SessionEventLog | 事件日志(类型 `SessionEventLog`)。The event log. |
eventMapper | SessionEventMapper | 事件 Mapper(类型 `SessionEventMapper`)。The event mapper. |
previewBus | SessionEventPreviewBus | 预览总线(类型 `SessionEventPreviewBus`)。The preview bus. |
environmentService | DataEnvironmentService | 环境服务(类型 `DataEnvironmentService`)。The environment service. |
handsLeaseService | HandsLeaseService | hands Lease 服务(类型 `HandsLeaseService`)。The hands lease service. |
turnLeaseService | TurnLeaseService | 轮次 Lease 服务(类型 `TurnLeaseService`)。The turn lease service. |
coordinationStore | CoordinationStore | coordination 存储(类型 `CoordinationStore`)。The coordination store. |
deletedSessions | DeletedSessionRegistry | 已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions. |
controlPlaneClient | ControlPlaneClient | 控制面客户端(类型 `ControlPlaneClient`)。The control plane client. |
confirmationCoordinator | ToolConfirmationCoordinator | 确认 Coordinator(类型 `ToolConfirmationCoordinator`)。The confirmation coordinator. |
runRegistry | AgentRunRegistry | 运行注册表(类型 `AgentRunRegistry`)。The run registry. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:102–129方法详情Method Detail
runTurnAsync
public void runTurnAsync(ManagedSessionDto session, String userMessage)
运行轮次异步。
Runs a turn asynchronously so inbound HTTP handlers can return quickly.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
session | ManagedSessionDto | 会话(类型 `ManagedSessionDto`)。The session. |
userMessage | String | 用户消息(类型 `String`)。The user message. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:132–134runTurnAsync
public void runTurnAsync(ManagedSessionDto session, String userMessage, Runnable onAdmitted)
运行轮次异步。
Runs a turn asynchronously, invoking onAdmitted once the turn is certain to run — the lease is held by then, so a caller can record the message that triggered it only if it will actually be processed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
session | ManagedSessionDto | 会话(类型 `ManagedSessionDto`)。The session. |
userMessage | String | 用户消息(类型 `String`)。The user message. |
onAdmitted | Runnable | on Admitted(类型 `Runnable`)。The on admitted. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:141–144resumeWithToolResults
public void resumeWithToolResults(ManagedSessionDto session, List<ToolResultBlock> toolResults)
执行恢复使用工具结果相关操作。
Resumes a suspended turn with external tool results (self-hosted worker / user.tool_result).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
session | ManagedSessionDto | 会话(类型 `ManagedSessionDto`)。The session. |
toolResults | List<ToolResultBlock> | 工具结果(类型 `List`)。The tool results. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:150–161abortManagedAttempt
public void abortManagedAttempt(String sessionId, String agentTaskId, String attemptId, long dispatchGeneration, String turnId, String reason)
执行中止托管尝试相关操作。
Handles a fenced abort locally or queues it for the replica holding the matching turn lease.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
agentTaskId | String | 智能体任务标识(类型 `String`)。The agent task id. |
attemptId | String | 尝试标识(类型 `String`)。The attempt id. |
dispatchGeneration | long | dispatch Generation(类型 `long`)。The dispatch generation. |
turnId | String | 轮次标识(类型 `String`)。The turn id. |
reason | String | 原因(类型 `String`)。The reason. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:347–370interrupt
public void interrupt(String sessionId)
请求中断当前执行。
Cancels an in-flight turn.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:406–415interruptRun
public void interruptRun(String ownerId, String sessionId, String runId)
执行中断运行相关操作。
Cancels an exact run after the caller has authorized access to the session.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ownerId | String | 所有者标识(类型 `String`)。The owner id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
runId | String | 运行标识(类型 `String`)。The run id. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:422–437releaseSession
public void releaseSession(String sessionId, String ownerId)
执行 releaseSession 方法。
Drops the footprint of a session the control plane has deleted: an in-flight turn is cancelled first, then the team wakeup bindings, the cached instance with its persisted agent state, and the per-session preview bookkeeping.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
ownerId | String | 所有者标识(类型 `String`)。The owner id. |
io/agentscope/builder/web/managed/SessionTurnRunner.java:497–506toolResultFromPayload
public static ToolResultBlock toolResultFromPayload(Map<String, Object> payload)
构建ToolResultBlock来自工作进程/用户工具_结果负载。
Builds a ToolResultBlock from a worker/user tool_result payload.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
ToolResultBlockio/agentscope/builder/web/managed/SessionTurnRunner.java:858–891