AS AgentScopeAPI 手册 / API Reference

SessionTranscriptWriter

public class SessionTranscriptWriter
源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:55–384

会话 Transcript Writer,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.harness.agent.memory.session 包。核心成员包括 appendMessages、resolveContextPath、SessionTranscriptWriter、INPUT_TRUNCATE_CHARS、OUTPUT_TRUNCATE_CHARS。

Independent writer for the session transcript JSONL (.jsonl / .log.jsonl).

Decoupled from io.agentscope.harness.agent.memory.MemoryFlushManager: transcript completeness must not depend on memory-flush triggers or prompts. Callers should invoke this at turn boundaries (see io.agentscope.harness.agent.middleware.TranscriptMiddleware).

Tool calls and results are recorded as structured SessionEntry.ToolUseEntry / SessionEntry.ToolResultEntry rows so the call/result process is machine-readable. Content may still be truncated; truncated fields carry truncated + originalSize.

字段摘要Field Summary

字段Field类型Type说明Description
INPUT_TRUNCATE_CHARS
staticfinal
int
输入 TRUNCATE 字符数字段。
Soft cap for tool input JSON in the transcript (process-complete; content may truncate).
OUTPUT_TRUNCATE_CHARS
staticfinal
int
输出 TRUNCATE 字符数字段。
Soft cap for tool output text in the transcript.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SessionTranscriptWriter(WorkspaceManager workspaceManager)
初始化 `SessionTranscriptWriter` 实例。
Creates a new instance.
public SessionTranscriptWriter(WorkspaceManager workspaceManager, TranscriptStore transcriptStore, String tenant)
初始化 `SessionTranscriptWriter` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void appendMessages(RuntimeContext rc, List<Msg> messages, String agentId, String sessionId)
追加消息。
Appends new messages to the session tree idempotently (dedup by stable entry ids).
public String resolveContextPath(RuntimeContext rc, String agentId, String sessionId)
解析上下文路径。
Resolves the workspace-relative path of the session context JSONL (for compaction summary references).

字段详情Field Detail

INPUT_TRUNCATE_CHARS

public static final int INPUT_TRUNCATE_CHARS
staticfinal

输入 TRUNCATE 字符数字段。声明为 public static final int INPUT_TRUNCATE_CHARS。

Soft cap for tool input JSON in the transcript (process-complete; content may truncate).

源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:62

OUTPUT_TRUNCATE_CHARS

public static final int OUTPUT_TRUNCATE_CHARS
staticfinal

输出 TRUNCATE 字符数字段。声明为 public static final int OUTPUT_TRUNCATE_CHARS。

Soft cap for tool output text in the transcript.

源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:65

构造器详情Constructor Detail

SessionTranscriptWriter

public SessionTranscriptWriter(WorkspaceManager workspaceManager)

初始化 SessionTranscriptWriter 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
workspaceManagerWorkspaceManager工作区管理器(类型 `WorkspaceManager`)。The workspace manager.
源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:71–73

SessionTranscriptWriter

public SessionTranscriptWriter(WorkspaceManager workspaceManager, TranscriptStore transcriptStore, String tenant)

初始化 SessionTranscriptWriter 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
workspaceManagerWorkspaceManager工作区管理器(类型 `WorkspaceManager`)。The workspace manager.
transcriptStoreTranscriptStoretranscript 存储(类型 `TranscriptStore`)。The transcript store.
tenantString租户(类型 `String`)。The tenant.
源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:75–80

方法详情Method Detail

appendMessages

public void appendMessages(RuntimeContext rc, List<Msg> messages, String agentId, String sessionId)

追加消息。

Appends new messages to the session tree idempotently (dedup by stable entry ids).

参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
messagesList<Msg>消息列表(类型 `List`)。The messages.
agentIdString智能体标识(类型 `String`)。The agent id.
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:86–160

resolveContextPath

public String resolveContextPath(RuntimeContext rc, String agentId, String sessionId)

解析上下文路径。

Resolves the workspace-relative path of the session context JSONL (for compaction summary references).

参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
agentIdString智能体标识(类型 `String`)。The agent id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:166–182
基于官方固定版本源码静态生成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.