AS AgentScopeAPI 手册 / API Reference

ContextSnapshot

public final class ContextSnapshot
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:44–417

上下文快照,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.aistio.model 包。核心成员包括 builder、getSessionId、getSystemPrompt、getMessages、getTools、isCompacted。

Level-4 effective-context snapshot: what the agent's next model call will actually see.

Carries both encodings — #toProto() for the ASDP ContextReport upstream push, and #toJsonMap() for GET /agentscope/sessions/{id}/context.

#computeHash() produces the same digest as the Go control plane and the Python SDK: SHA-256 over recursively key-sorted, separator-free JSON of the effective content, truncated to #HASH_LEN hex characters. The control plane compares hashes to detect context drift without fetching the body.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
ContextMessage记录record
承载上下文消息数据的记录类型。
One message in the effective context.
ToolInfo记录record
承载工具信息数据的记录类型。
One tool currently exposed to the agent.
Builder类class
用于`ContextSnapshot`的可变构建器。
Mutable builder for `ContextSnapshot`.

字段摘要Field Summary

字段Field类型Type说明Description
HASH_LEN
staticfinal
int
HASH LEN字段。
Number of leading hex characters of the SHA-256 digest kept as the context hash.

方法摘要Method Summary

方法Method说明Description
public static Builder builder(String sessionId)
static
返回构建器实例。
Performs the builder operation.
public String getSessionId()
获取会话标识。
Returns the session id.
public String getSystemPrompt()
获取系统提示词。
Returns the system prompt.
public List<ContextMessage> getMessages()
获取消息。
Returns the messages.
public List<ToolInfo> getTools()
获取工具。
Returns the tools.
public boolean isCompacted()
判断是否 `isCompacted`。
Returns whether the compacted.
public String getCompactionSummary()
获取压缩摘要。
Returns the compaction summary.
public int getOriginalMessageCount()
获取 `getOriginalMessageCount`。
Returns the original message count.
public long getCompactedAt()
获取 `getCompactedAt`。
Returns the compacted at.
public String getFramework()
获取 `getFramework`。
Returns the framework.
public String getModel()
获取模型。
Returns the model.
public byte[] getFrameworkState()
获取 `getFrameworkState`。
Returns the framework state.
public long getCapturedAt()
获取 `getCapturedAt`。
Returns the captured at.
public int getTotalTokens()
获取总数令牌数。
Returns the total tokens.
public int getMaxTokens()
获取最大令牌数。
Returns the max tokens.
public String getContextHash()
获取 `getContextHash`。
Returns the context hash.
public String refreshHash()
返回 `refreshHash` 结果。
Recomputes and stores `#getContextHash()`, returning the new value.
public String computeHash()
计算 `computeHash`。
Returns the compute hash.
public ContextReport toProto()
返回到协议。
Returns the to proto.
public Map<String, Object> toJsonMap()
用于`GET /agentscope/sessions/{id}/context`的响应正文。
Response body for `GET /agentscope/sessions/{id}/context`.

字段详情Field Detail

HASH_LEN

public static final int HASH_LEN
staticfinal

HASH LEN字段。声明为 public static final int HASH_LEN。

Number of leading hex characters of the SHA-256 digest kept as the context hash.

源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:47

方法详情Method Detail

builder

public static Builder builder(String sessionId)
static

返回构建器实例。

Performs the builder operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:87–89

getSessionId

public String getSessionId()

获取会话标识。

Returns the session id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:91–93

getSystemPrompt

public String getSystemPrompt()

获取系统提示词。

Returns the system prompt.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:95–97

getMessages

public List<ContextMessage> getMessages()

获取消息。

Returns the messages.

返回Returns List<ContextMessage>
返回列出。Returns list.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:99–101

getTools

public List<ToolInfo> getTools()

获取工具。

Returns the tools.

返回Returns List<ToolInfo>
返回列出。Returns list.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:103–105

isCompacted

public boolean isCompacted()

判断是否 isCompacted。

Returns whether the compacted.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:107–109

getCompactionSummary

public String getCompactionSummary()

获取压缩摘要。

Returns the compaction summary.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:111–113

getOriginalMessageCount

public int getOriginalMessageCount()

获取 getOriginalMessageCount。

Returns the original message count.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:115–117

getCompactedAt

public long getCompactedAt()

获取 getCompactedAt。

Returns the compacted at.

返回Returns long
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:119–121

getFramework

public String getFramework()

获取 getFramework。

Returns the framework.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:123–125

getModel

public String getModel()

获取模型。

Returns the model.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:127–129

getFrameworkState

public byte[] getFrameworkState()

获取 getFrameworkState。

Returns the framework state.

返回Returns byte[]
返回byte[]。Returns byte.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:131–133

getCapturedAt

public long getCapturedAt()

获取 getCapturedAt。

Returns the captured at.

返回Returns long
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:135–137

getTotalTokens

public int getTotalTokens()

获取总数令牌数。

Returns the total tokens.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:139–141

getMaxTokens

public int getMaxTokens()

获取最大令牌数。

Returns the max tokens.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:143–145

getContextHash

public String getContextHash()

获取 getContextHash。

Returns the context hash.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:147–149

refreshHash

public String refreshHash()

返回 refreshHash 结果。

Recomputes and stores #getContextHash(), returning the new value.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:152–155

computeHash

public String computeHash()

计算 computeHash。

Returns the compute hash.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:157–177

toProto

public ContextReport toProto()

返回到协议。

Returns the to proto.

返回Returns ContextReport
返回ContextReport。Returns context report.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:179–199

toJsonMap

public Map<String, Object> toJsonMap()

用于GET /agentscope/sessions/{id}/context的响应正文。

Response body for GET /agentscope/sessions/{id}/context.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/model/ContextSnapshot.java:202–246

嵌套类详情Nested Class Detail

ContextMessage

public record ContextMessage(String role, String content, boolean isCompaction)

承载上下文消息数据的记录类型。位于 io.agentscope.extensions.aistio.model 包。核心成员包括 role、content、isCompaction、of。

One message in the effective context.

ToolInfo

public record ToolInfo(String name, String description, Map<String, Object> parameters)

承载工具信息数据的记录类型。位于 io.agentscope.extensions.aistio.model 包。核心成员包括 name、description、parameters。

One tool currently exposed to the agent.

Builder

public static final class Builder

用于ContextSnapshot的可变构建器。位于 io.agentscope.extensions.aistio.model 包。核心成员包括 sessionId、systemPrompt、messages、tools、compacted、compactionSummary。

Mutable builder for ContextSnapshot.

基于官方固定版本源码静态生成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.