AS AgentScopeAPI 手册 / API Reference

SessionBridge

public final class SessionBridge implements ContractProvider, AutoCloseable
源码Source io/agentscope/extensions/aistio/SessionBridge.java:68–1276

会话 Bridge,承载智能体的部署、调度与服务化运行。位于 io.agentscope.extensions.aistio 包,实现 ContractProvider、AutoCloseable。核心成员包括 attach、getAdapter、getConfig、getRegisteredIdentity、getContractPort、start。

The reporting engine that sits between a framework adapter and the aistio control plane.

It owns everything the adapter should not care about: sequence numbering, the Level-2 event durable event outbox, incremental context tracking, Level-1 aggregation, debounced Level-4 pushes, inventory, command dispatch from both channels, and the in-process contract server.

Bypass principle: every reporting path swallows its own failures. Nothing here may propagate into the agent's conversation path.

字段摘要Field Summary

字段Field类型Type说明Description
SDK_VERSION
staticfinal
String
SDK 版本字段。
The SDK VERSION field.
CONTRACT_LEVEL
staticfinal
int
契约级别字段。
Contract level 3: discovery, sessions, and commands.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SessionBridge(AistioConfig config)
初始化 `SessionBridge` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public SessionBridge attach(Object target, FrameworkAdapter adapter)
执行 `attach` 方法。
Mounts `adapter` onto `target`; must be called before `#start()`.
public FrameworkAdapter getAdapter()
获取适配器。
Returns the adapter.
public AistioConfig getConfig()
获取配置。
Returns the config.
public HttpSelfRegistration.RegisteredIdentity getRegisteredIdentity()
获取已注册身份。
Returns the stable Catalog identity issued by the latest successful self-registration.
public int getContractPort()
获取 `getContractPort`。
Actual contract HTTP port, which matters when the configured port was 0.
public synchronized SessionBridge start()
synchronized
返回启动。
Returns the start.
public synchronized void close()
synchronized
关闭连接并释放相关资源。
Releases resources and connections.
public Set<String> capabilities()
返回能力。
Returns the capabilities.
public void onEvent(SessionEvent event)
处理事件事件。
Adapter callback.
public void describeSession(String sessionId, String systemPrompt, List<ContextSnapshot.ToolInfo> tools, int maxTokens)
执行 `describeSession` 方法。
Lets the adapter seed the tracker with data the event stream does not carry.
public void describeSession(String sessionId, String systemPrompt, List<ContextSnapshot.ToolInfo> tools, int maxTokens, String model)
执行 `describeSession` 方法。
Lets the adapter seed the tracker, including the model name when known.
public void setEffectiveSystemPrompt(String sessionId, String prompt)
设置 `setEffectiveSystemPrompt`。
Stores the last middleware-composed system prompt for a session.
public String effectiveSystemPrompt(String sessionId)
设置该参数。
Last effective system prompt for the session, or empty.
public void setBusy(String sessionId, boolean busy)
设置 `setBusy`。
Records whether a turn is in progress by driving `phase`: `active` while busy, `idle` when the turn ends.
public void setPhase(String sessionId, String phase)
设置阶段。
Sets operational phase explicitly (e.g.
public void setContextUsedTokens(String sessionId, int usedTokens)
设置 `setContextUsedTokens`。
Updates context-window occupancy used for Level-1 `contextPressure`.
public Map<String, Object> info()
返回信息。
Returns the info.
public List<Map<String, Object>> sessions()
返回会话。
Returns the sessions.
public Map<String, Object> sessionState(String sessionId)
设置会话状态。
Performs the session state operation.
public Map<String, Object> context(String sessionId)
设置上下文。
Performs the context operation.
public Map<String, Object> messages(String sessionId, int offset, int limit)
执行消息相关操作。
Performs the messages operation.
public List<Map<String, Object>> subagents()
返回 `subagents` 结果。
Returns the subagents.
public List<Map<String, Object>> workspaces()
返回 `workspaces` 结果。
Returns the workspaces.
public void compress(String sessionId)
设置压缩。
Performs the compress operation.
public void terminate(String sessionId)
设置该参数。
Performs the terminate operation.
public void abort(String sessionId)
设置中止。
Performs the abort operation.
public Map<String, Object> tasks(String sessionId)
设置任务。
Performs the tasks operation.
public Map<String, Object> subagentTasks(String sessionId)
设置子智能体任务。
Performs the subagent tasks operation.
public void cancelSubagentTask(String sessionId, String taskId)
执行取消子智能体任务相关操作。
Performs the cancel subagent task operation.
public void planMode(String sessionId, byte[] body)
执行计划模式相关操作。
Performs the plan mode operation.
public void postMessage(String sessionId, byte[] body)
执行后置消息相关操作。
Performs the post message operation.
public Map<String, Object> exportTranscript(String sessionId)
设置该参数。
Performs the export transcript operation.
public String sessionPhase(String sessionId)
设置会话阶段。
Performs the session phase operation.

字段详情Field Detail

SDK_VERSION

public static final String SDK_VERSION
staticfinal

SDK 版本字段。声明为 public static final String SDK_VERSION。

The SDK VERSION field.

源码Source io/agentscope/extensions/aistio/SessionBridge.java:72

CONTRACT_LEVEL

public static final int CONTRACT_LEVEL
staticfinal

契约级别字段。声明为 public static final int CONTRACT_LEVEL。

Contract level 3: discovery, sessions, and commands.

源码Source io/agentscope/extensions/aistio/SessionBridge.java:75

构造器详情Constructor Detail

SessionBridge

public SessionBridge(AistioConfig config)

初始化 SessionBridge 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
configAistioConfig配置对象(类型 `AistioConfig`)。The config.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:128–143

方法详情Method Detail

attach

public SessionBridge attach(Object target, FrameworkAdapter adapter)

执行 attach 方法。

Mounts adapter onto target; must be called before #start().

参数Parameters
名称Name类型Type说明Description
targetObject目标(类型 `Object`)。The target.
adapterFrameworkAdapter适配器(类型 `FrameworkAdapter`)。The adapter.
返回Returns SessionBridge
返回SessionBridge。Returns session bridge.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:148–157

getAdapter

public FrameworkAdapter getAdapter()

获取适配器。

Returns the adapter.

返回Returns FrameworkAdapter
返回FrameworkAdapter。Returns framework adapter.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:159–161

getConfig

public AistioConfig getConfig()

获取配置。

Returns the config.

返回Returns AistioConfig
返回AistioConfig。Returns aistio config.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:163–165

getRegisteredIdentity

public HttpSelfRegistration.RegisteredIdentity getRegisteredIdentity()

获取已注册身份。

Returns the stable Catalog identity issued by the latest successful self-registration.

返回Returns HttpSelfRegistration.RegisteredIdentity
返回HttpSelfRegistration.RegisteredIdentity。Returns http self registration registered identity.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:172–174

getContractPort

public int getContractPort()

获取 getContractPort。

Actual contract HTTP port, which matters when the configured port was 0.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:177–179

start

public synchronized SessionBridge start()
synchronized

返回启动。

Returns the start.

返回Returns SessionBridge
返回SessionBridge。Returns session bridge.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:183–315

close

public synchronized void close()
synchronized

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/extensions/aistio/SessionBridge.java:329–362

capabilities

public Set<String> capabilities()

返回能力。

Returns the capabilities.

返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:366–375

onEvent

public void onEvent(SessionEvent event)

处理事件事件。

Adapter callback.

参数Parameters
名称Name类型Type说明Description
eventSessionEvent事件(类型 `SessionEvent`)。The event.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:380–432

describeSession

public void describeSession(String sessionId, String systemPrompt, List<ContextSnapshot.ToolInfo> tools, int maxTokens)

执行 describeSession 方法。

Lets the adapter seed the tracker with data the event stream does not carry.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
systemPromptString系统提示词(类型 `String`)。The system prompt.
toolsList<ContextSnapshot.ToolInfo>工具列表(类型 `List`)。The tools.
maxTokensint最大令牌数(类型 `int`)。The max tokens.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:435–441

describeSession

public void describeSession(String sessionId, String systemPrompt, List<ContextSnapshot.ToolInfo> tools, int maxTokens, String model)

执行 describeSession 方法。

Lets the adapter seed the tracker, including the model name when known.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
systemPromptString系统提示词(类型 `String`)。The system prompt.
toolsList<ContextSnapshot.ToolInfo>工具列表(类型 `List`)。The tools.
maxTokensint最大令牌数(类型 `int`)。The max tokens.
modelString模型实例(类型 `String`)。The model.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:444–468

setEffectiveSystemPrompt

public void setEffectiveSystemPrompt(String sessionId, String prompt)

设置 setEffectiveSystemPrompt。

Stores the last middleware-composed system prompt for a session.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
promptString提示词(类型 `String`)。The prompt.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:471–481

effectiveSystemPrompt

public String effectiveSystemPrompt(String sessionId)

设置该参数。

Last effective system prompt for the session, or empty.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:484–492

setBusy

public void setBusy(String sessionId, boolean busy)

设置 setBusy。

Records whether a turn is in progress by driving phase: active while busy, idle when the turn ends.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
busybooleanbusy(类型 `boolean`)。The busy.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:498–513

setPhase

public void setPhase(String sessionId, String phase)

设置阶段。

Sets operational phase explicitly (e.g.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
phaseString阶段(类型 `String`)。The phase.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:516–524

setContextUsedTokens

public void setContextUsedTokens(String sessionId, int usedTokens)

设置 setContextUsedTokens。

Updates context-window occupancy used for Level-1 contextPressure.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
usedTokensintused 令牌数(类型 `int`)。The used tokens.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:527–537

info

public Map<String, Object> info()

返回信息。

Returns the info.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:872–892

sessions

public List<Map<String, Object>> sessions()

返回会话。

Returns the sessions.

返回Returns List<Map<String, Object>>
返回列出>。Returns list.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:894–949

sessionState

public Map<String, Object> sessionState(String sessionId)

设置会话状态。

Performs the session state operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:951–999

context

public Map<String, Object> context(String sessionId)

设置上下文。

Performs the context operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1001–1022

messages

public Map<String, Object> messages(String sessionId, int offset, int limit)

执行消息相关操作。

Performs the messages operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
offsetint偏移量(类型 `int`)。The offset.
limitint数量上限(类型 `int`)。The limit.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1024–1035

subagents

public List<Map<String, Object>> subagents()

返回 subagents 结果。

Returns the subagents.

返回Returns List<Map<String, Object>>
返回列出>。Returns list.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1037–1049

workspaces

public List<Map<String, Object>> workspaces()

返回 workspaces 结果。

Returns the workspaces.

返回Returns List<Map<String, Object>>
返回列出>。Returns list.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1051–1063

compress

public void compress(String sessionId)

设置压缩。

Performs the compress operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1065–1079

terminate

public void terminate(String sessionId)

设置该参数。

Performs the terminate operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1081–1085

abort

public void abort(String sessionId)

设置中止。

Performs the abort operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1087–1091

tasks

public Map<String, Object> tasks(String sessionId)

设置任务。

Performs the tasks operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1093–1115

subagentTasks

public Map<String, Object> subagentTasks(String sessionId)

设置子智能体任务。

Performs the subagent tasks operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1117–1127

cancelSubagentTask

public void cancelSubagentTask(String sessionId, String taskId)

执行取消子智能体任务相关操作。

Performs the cancel subagent task operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
taskIdString任务标识(类型 `String`)。The task id.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1129–1135

planMode

public void planMode(String sessionId, byte[] body)

执行计划模式相关操作。

Performs the plan mode operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
bodybyte[]正文(类型 `byte[]`)。The body.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1137–1143

postMessage

public void postMessage(String sessionId, byte[] body)

执行后置消息相关操作。

Performs the post message operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
bodybyte[]正文(类型 `byte[]`)。The body.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1145–1159

exportTranscript

public Map<String, Object> exportTranscript(String sessionId)

设置该参数。

Performs the export transcript operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1177–1185

sessionPhase

public String sessionPhase(String sessionId)

设置会话阶段。

Performs the session phase operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/SessionBridge.java:1187–1190
基于官方固定版本源码静态生成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.