ContextSnapshot
public final class ContextSnapshot
io/agentscope/extensions/controlplane/model/ContextSnapshot.java:44–417上下文快照,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.controlplane.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_LENstaticfinal | 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
HASH LEN字段。声明为 public static final int HASH_LEN。
Number of leading hex characters of the SHA-256 digest kept as the context hash.
io/agentscope/extensions/controlplane/model/ContextSnapshot.java:47方法详情Method Detail
builder
public static Builder builder(String sessionId)
返回构建器实例。
Performs the builder operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Builderio/agentscope/extensions/controlplane/model/ContextSnapshot.java:87–89getSessionId
public String getSessionId()
获取会话标识。
Returns the session id.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:91–93getSystemPrompt
public String getSystemPrompt()
获取系统提示词。
Returns the system prompt.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:95–97getMessages
public List<ContextMessage> getMessages()
获取消息。
Returns the messages.
List<ContextMessage>io/agentscope/extensions/controlplane/model/ContextSnapshot.java:99–101getTools
public List<ToolInfo> getTools()
获取工具。
Returns the tools.
List<ToolInfo>io/agentscope/extensions/controlplane/model/ContextSnapshot.java:103–105isCompacted
public boolean isCompacted()
判断是否 isCompacted。
Returns whether the compacted.
booleanio/agentscope/extensions/controlplane/model/ContextSnapshot.java:107–109getCompactionSummary
public String getCompactionSummary()
获取压缩摘要。
Returns the compaction summary.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:111–113getOriginalMessageCount
public int getOriginalMessageCount()
获取 getOriginalMessageCount。
Returns the original message count.
intio/agentscope/extensions/controlplane/model/ContextSnapshot.java:115–117getCompactedAt
public long getCompactedAt()
获取 getCompactedAt。
Returns the compacted at.
longio/agentscope/extensions/controlplane/model/ContextSnapshot.java:119–121getFramework
public String getFramework()
获取 getFramework。
Returns the framework.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:123–125getModel
public String getModel()
获取模型。
Returns the model.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:127–129getFrameworkState
public byte[] getFrameworkState()
获取 getFrameworkState。
Returns the framework state.
byte[]io/agentscope/extensions/controlplane/model/ContextSnapshot.java:131–133getCapturedAt
public long getCapturedAt()
获取 getCapturedAt。
Returns the captured at.
longio/agentscope/extensions/controlplane/model/ContextSnapshot.java:135–137getTotalTokens
public int getTotalTokens()
获取总数令牌数。
Returns the total tokens.
intio/agentscope/extensions/controlplane/model/ContextSnapshot.java:139–141getMaxTokens
public int getMaxTokens()
获取最大令牌数。
Returns the max tokens.
intio/agentscope/extensions/controlplane/model/ContextSnapshot.java:143–145getContextHash
public String getContextHash()
获取 getContextHash。
Returns the context hash.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:147–149refreshHash
public String refreshHash()
返回 refreshHash 结果。
Recomputes and stores #getContextHash(), returning the new value.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:152–155computeHash
public String computeHash()
计算 computeHash。
Returns the compute hash.
Stringio/agentscope/extensions/controlplane/model/ContextSnapshot.java:157–177toProto
public ContextReport toProto()
返回到协议。
Returns the to proto.
ContextReportio/agentscope/extensions/controlplane/model/ContextSnapshot.java:179–199toJsonMap
public Map<String, Object> toJsonMap()
用于GET /agentscope/sessions/{id}/context的响应正文。
Response body for GET /agentscope/sessions/{id}/context.
Map<String, Object>io/agentscope/extensions/controlplane/model/ContextSnapshot.java:202–246嵌套类详情Nested Class Detail
ContextMessage
public record ContextMessage(String role, String content, boolean isCompaction)承载上下文消息数据的记录类型。位于 io.agentscope.extensions.controlplane.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.controlplane.model 包。核心成员包括 name、description、parameters。
One tool currently exposed to the agent.
Builder
public static final class Builder用于ContextSnapshot的可变构建器。位于 io.agentscope.extensions.controlplane.model 包。核心成员包括 sessionId、systemPrompt、messages、tools、compacted、compactionSummary。
Mutable builder for ContextSnapshot.