SessionTranscriptWriter
public class SessionTranscriptWriter
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_CHARSstaticfinal | int | 输入 TRUNCATE 字符数字段。 Soft cap for tool input JSON in the transcript (process-complete; content may truncate). |
OUTPUT_TRUNCATE_CHARSstaticfinal | int | 输出 TRUNCATE 字符数字段。 Soft cap for tool output text in the transcript. |
构造器摘要Constructor Summary
方法摘要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
输入 TRUNCATE 字符数字段。声明为 public static final int INPUT_TRUNCATE_CHARS。
Soft cap for tool input JSON in the transcript (process-complete; content may truncate).
io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:62OUTPUT_TRUNCATE_CHARS
public static final int OUTPUT_TRUNCATE_CHARS
输出 TRUNCATE 字符数字段。声明为 public static final int OUTPUT_TRUNCATE_CHARS。
Soft cap for tool output text in the transcript.
io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:65构造器详情Constructor Detail
SessionTranscriptWriter
public SessionTranscriptWriter(WorkspaceManager workspaceManager)
初始化 SessionTranscriptWriter 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceManager | WorkspaceManager | 工作区管理器(类型 `WorkspaceManager`)。The workspace manager. |
io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:71–73SessionTranscriptWriter
public SessionTranscriptWriter(WorkspaceManager workspaceManager, TranscriptStore transcriptStore, String tenant)
初始化 SessionTranscriptWriter 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceManager | WorkspaceManager | 工作区管理器(类型 `WorkspaceManager`)。The workspace manager. |
transcriptStore | TranscriptStore | transcript 存储(类型 `TranscriptStore`)。The transcript store. |
tenant | String | 租户(类型 `String`)。The tenant. |
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).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:86–160resolveContextPath
public String resolveContextPath(RuntimeContext rc, String agentId, String sessionId)
解析上下文路径。
Resolves the workspace-relative path of the session context JSONL (for compaction summary references).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
Stringio/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java:166–182