AS AgentScopeAPI 手册 / API Reference

SessionTurnGate

public interface SessionTurnGate
源码Source io/agentscope/harness/agent/gateway/SessionTurnGate.java:26–47

定义会话轮次 Gate契约的接口。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 acquire、isRunning。

Per-key mutual exclusion for gateway turns (user/channel inbound runs and subagent notification).

Implementations include LocalSessionTurnGate (process-local fair semaphore) and control-plane hosted locks for cross-node coordination. When using a distributed turn gate, io.agentscope.core.ReActAgent conflictPolicy should be set to FAIL so concurrent state writes surface as errors rather than silent overwrites.

方法摘要Method Summary

方法Method说明Description
public TurnLease acquire(String key) throws InterruptedException, TurnBusyException
设置该参数。
Acquires the turn slot for the given key, blocking until available or throwing when busy.
public boolean isRunning(String key)
判断是否运行中。
Non-blocking check: returns `true` when a turn is currently held for the given key.

方法详情Method Detail

acquire

public TurnLease acquire(String key) throws InterruptedException, TurnBusyException

设置该参数。

Acquires the turn slot for the given key, blocking until available or throwing when busy.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。canonical gate key (typically `MsgContext#canonicalKey()`)
返回Returns TurnLease
返回TurnLease。a lease that must be closed to release the slot
抛出Throws
  • InterruptedException 可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
  • TurnBusyException 可能抛出 `TurnBusyException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/gateway/SessionTurnGate.java:37

isRunning

public boolean isRunning(String key)

判断是否运行中。

Non-blocking check: returns true when a turn is currently held for the given key.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。canonical gate key
返回Returns boolean
返回布尔值,表示判断结果。`true` when a turn is in progress for the key
源码Source io/agentscope/harness/agent/gateway/SessionTurnGate.java:46
基于官方固定版本源码静态生成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.