session-handoff

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hand-Off Session

会话交接

Response Format

响应格式

Begin the first response to this skill invocation with the line:
Entire Session Handoff:
followed by a blank line, then the content. The header applies to the full compaction-summary flow, including the "Unanswered Question" branch (which is still a successful run — the skill summarized the transcript and surfaced the question).
  • Apply the header to the first response of the invocation only. Do not re-print it on follow-up turns within the same invocation (e.g. after the user answers the surfaced unanswered question).
  • Do not include the header on error or early-exit responses (e.g. no
    .git/entire-sessions/
    directory, no sessions found after filtering, transcript file missing at the path the session JSON points to). The header's presence should signal that the skill ran and produced real output.
调用该技能后的首次响应需以以下内容开头:
Entire Session Handoff:
随后空一行,再展示内容。该标题适用于完整的压缩总结流程,包括“未回答问题”分支(这仍属于成功运行——技能已总结对话记录并提出问题)。
  • 仅在技能调用的首次响应中添加该标题。在同一次调用的后续交互中(例如用户回答提出的未回答问题后),请勿重复打印该标题。
  • 在错误或提前退出的响应中(例如不存在
    .git/entire-sessions/
    目录、过滤后未找到会话、会话JSON指向的路径中缺少对话记录文件),请勿添加该标题。该标题的存在应表明技能已运行并生成有效输出。

STOP — Read these rules before doing ANYTHING

注意——在执行任何操作前请阅读以下规则

  1. Do NOT ask clarifying questions. Auto-detect the session and read the transcript.
  2. Do NOT run
    entire sessions list
    ,
    entire sessions info
    ,
    entire explain --session
    ,
    git log
    ,
    git status
    ,
    git branch
    ,
    ps aux
    , or any other exploratory commands. They waste time and don't give you the transcript.
  3. Do NOT say "Would you like me to continue?" or "Let me know if you want me to pick this up." Just read the transcript and start working. (Exception: if the previous agent asked the user a question that was never answered, you MUST ask the user that question before proceeding.)
  4. Do NOT summarize the session as having "0 turns" or "no progress" without first reading the actual transcript file. The
    entire
    CLI metadata often undercounts — the transcript is the source of truth.
  5. Skip your own session. Your agent (e.g. Claude Code) also has a session in
    .git/entire-sessions/
    . Exclude any session whose
    agent_type
    matches your own agent type from the results.
  1. 请勿提出澄清问题。自动检测会话并读取对话记录。
  2. 请勿运行
    entire sessions list
    entire sessions info
    entire explain --session
    git log
    git status
    git branch
    ps aux
    或任何其他探索性命令。这些命令会浪费时间且无法获取对话记录。
  3. 请勿说“是否需要我继续?”或“如果需要我接手请告知。”直接读取对话记录并开始工作。(例外情况:如果之前的Agent向用户提出了未被回答的问题,你必须先向用户询问该问题,然后再继续。)
  4. 请勿在未读取实际对话记录文件的情况下总结会话“0轮次”或“无进展”。
    entire
    CLI的元数据经常计数不足——对话记录是唯一的真实来源。
  5. 跳过你自己的会话。你的Agent(例如Claude Code)在
    .git/entire-sessions/
    中也有会话。从结果中排除任何
    agent_type
    与你自身Agent类型匹配的会话。

Flow: Active / current session handoff

流程:活跃/当前会话交接

When the user says "current", "active", or just "hand off this session":
当用户说“current”、“active”或仅说“交接此会话”时:

Step 1: Run
entire status

步骤1:运行
entire status

entire status
This returns the active session ID. If the user mentioned an agent name (e.g. "codex"), look for that agent's session in the output.
entire status
该命令会返回活跃会话ID。如果用户提到了Agent名称(例如“codex”),请在输出中查找该Agent的会话。

Step 2: Find the transcript path

步骤2:查找对话记录路径

Read the session file at
.git/entire-sessions/<session-id>.json
using the Read tool:
Read: .git/entire-sessions/<session-id>.json
The file looks like this:
json
{
  "session_id": "019d730f-e099-7910-a946-b5b20e2cfafc",
  "agent_type": "Codex",
  "phase": "active",
  "started_at": "2026-04-09T09:25:21.725231-07:00",
  "last_interaction_time": "2026-04-09T09:25:21.725657-07:00",
  "transcript_path": "/Users/alisha/.codex/sessions/2026/04/09/rollout-....jsonl",
  "last_prompt": "create solitaire game"
}
Extract the
transcript_path
field. This is the path to the full conversation transcript.
Fallback: If
entire status
doesn't give you a session ID, or the session JSON doesn't exist, use the Glob tool to find all
.git/entire-sessions/*.json
files, read them, and pick the most recent one (by
last_interaction_time
or
started_at
). Filter by agent name if the user specified one. Always exclude sessions matching your own agent type.
使用读取工具读取
.git/entire-sessions/<session-id>.json
路径下的会话文件:
Read: .git/entire-sessions/<session-id>.json
文件内容如下:
json
{
  "session_id": "019d730f-e099-7910-a946-b5b20e2cfafc",
  "agent_type": "Codex",
  "phase": "active",
  "started_at": "2026-04-09T09:25:21.725231-07:00",
  "last_interaction_time": "2026-04-09T09:25:21.725657-07:00",
  "transcript_path": "/Users/alisha/.codex/sessions/2026/04/09/rollout-....jsonl",
  "last_prompt": "create solitaire game"
}
提取
transcript_path
字段,这是完整对话记录的路径。
备选方案: 如果
entire status
未返回会话ID,或会话JSON不存在,使用Glob工具查找所有
.git/entire-sessions/*.json
文件,读取这些文件,选择最近的一个(按
last_interaction_time
started_at
排序)。如果用户指定了Agent名称,按名称过滤。始终排除与你自身Agent类型匹配的会话。

Step 3: Extract and summarize the transcript

步骤3:提取并总结对话记录

Phase A — Extract raw transcript (do NOT show this to the user):
bash
grep -E '"type":"(message|function_call|user|assistant)"' <transcript_path> | cut -c1-2000
If the output exceeds ~500 lines, read the last 100 lines (final state) and first 20 lines (original task):
bash
grep -E '"type":"(message|function_call|user|assistant)"' <transcript_path> | tail -100 | cut -c1-2000
grep -E '"type":"(message|function_call|user|assistant)"' <transcript_path> | head -20 | cut -c1-2000
Phase B — Produce a compaction summary. Internally process the extracted transcript and produce a structured summary with these sections:
  1. Task Overview — The user's core request, success criteria, and any stated constraints or clarifications.
  2. Current State — Completed work: files created/modified, key decisions made, artifacts produced.
  3. Important Discoveries — Technical constraints uncovered, rationale behind decisions, errors hit and their resolutions, failed approaches and why they failed.
  4. Next Steps — Specific remaining actions, blockers, and priority ordering.
  5. Context to Preserve — User preferences, domain-specific details, and commitments made during the session.
  6. Unanswered Question (only if applicable) — If the previous agent's last message asked the user a question or presented options that were never answered, capture it here exactly as asked.
Be concise but complete — err on the side of including information that would prevent duplicate work or repeated mistakes.
阶段A — 提取原始对话记录(请勿向用户展示此内容):
bash
grep -E '"type":"(message|function_call|user|assistant)"' <transcript_path> | cut -c1-2000
如果输出超过约500行,读取最后100行(最终状态)和前20行(原始任务):
bash
grep -E '"type":"(message|function_call|user|assistant)"' <transcript_path> | tail -100 | cut -c1-2000
grep -E '"type":"(message|function_call|user|assistant)"' <transcript_path> | head -20 | cut -c1-2000
阶段B — 生成压缩总结。内部处理提取的对话记录,生成包含以下部分的结构化总结:
  1. 任务概述 — 用户的核心需求、成功标准,以及任何明确的约束或澄清信息。
  2. 当前状态 — 已完成的工作:创建/修改的文件、关键决策、生成的成果。
  3. 重要发现 — 发现的技术约束、决策背后的理由、遇到的错误及其解决方案、失败的方法及原因。
  4. 下一步计划 — 具体的剩余操作、障碍及优先级排序。
  5. 需保留的上下文 — 用户偏好、领域特定细节,以及会话中做出的承诺。
  6. 未回答问题(仅在适用时) — 如果之前的Agent最后一条消息向用户提出了未被回答的问题或提供了选项,请在此处准确记录该问题。
内容需简洁但完整——宁可包含能避免重复工作或重复错误的信息。

Step 4: Present summary, then continue

步骤4:展示总结并继续工作

Show the compaction summary from Phase B to the user.
Critical rule — unanswered questions go to the user, not you. If section 6 (Unanswered Question) exists, present that question to the user and wait for their answer. Do NOT answer it yourself or pick a default. The user is the decision-maker.
If there is no unanswered question, immediately pick up the work — start planning, coding, or doing whatever the next step is. Do not ask permission.
向用户展示阶段B生成的压缩总结。
关键规则——未回答问题需提交给用户,而非由你处理。如果存在第6部分(未回答问题),请向用户提出该问题并等待回答。请勿自行回答或选择默认选项。用户是决策者。
如果没有未回答问题,立即接手工作——开始规划、编码或执行下一步操作。无需请求许可。

Flow: Checkpoint handoff (user gives a checkpoint ID)

流程:检查点交接(用户提供检查点ID)

  1. Run
    entire explain --checkpoint <checkpoint-id> --full --no-pager
  2. If
    --full
    fails, fall back to
    entire explain --checkpoint <checkpoint-id> --raw-transcript --no-pager
  3. Extract conversation content from ALL session transcripts (do NOT show raw output to the user):
bash
grep -rE '"type":"(message|function_call|user|assistant)"' <transcript_dir_or_files> | cut -c1-2000
For large checkpoints with many sessions, focus on the last 100 lines per transcript to understand final state, and the first 20 lines for the original task.
  1. Produce and present a compaction summary using the same 5-section format from Step 3 Phase B above, then continue.
Resolve checkpoint repos in order: explicit override → local
entire/checkpoints/v1
branch →
.entire/settings.json
checkpoint_remote
→ nearby local clone.
  1. 运行
    entire explain --checkpoint <checkpoint-id> --full --no-pager
  2. 如果
    --full
    失败,改用
    entire explain --checkpoint <checkpoint-id> --raw-transcript --no-pager
  3. 从所有会话对话记录中提取对话内容(请勿向用户展示原始输出):
bash
grep -rE '"type":"(message|function_call|user|assistant)"' <transcript_dir_or_files> | cut -c1-2000
对于包含多个会话的大型检查点,重点关注每个对话记录的最后100行以了解最终状态,以及前20行以了解原始任务。
  1. 使用上述步骤3阶段B中的5部分格式生成并展示压缩总结,然后继续工作。
按以下顺序解析检查点仓库:显式覆盖 → 本地
entire/checkpoints/v1
分支 →
.entire/settings.json
中的
checkpoint_remote
→ 附近的本地克隆。

Flow: No specific request (bare invocation)

流程:无特定请求(直接调用)

Use the Glob tool to find
.git/entire-sessions/*.json
. Read each file, exclude your own agent type, pick the most recent by
last_interaction_time
. Read the transcript at
transcript_path
. Summarize and continue.
使用Glob工具查找
.git/entire-sessions/*.json
文件。读取每个文件,排除你自身的Agent类型,选择
last_interaction_time
最新的会话。读取
transcript_path
对应的对话记录。总结并继续工作。

Agent name filtering

Agent名称过滤

Words like "codex", "claude", "kiro", "gemini" in the user's request are filters for session selection. Match them case-insensitively against the
agent_type
field (fall back to
agent
field). Never invoke another agent's CLI.
用户请求中的“codex”、“claude”、“kiro”、“gemini”等词汇是会话选择的过滤器。不区分大小写地与
agent_type
字段匹配(如果没有则匹配
agent
字段)。请勿调用其他Agent的CLI。