Install
openclaw skills install @lawson2019/agent-task-takeover接管、理解或交接另一个 AI 编码 agent 的任务/对话(跨 agent 全局可用,CLI 与 Electron 桌面 agent 均可,不依赖任何终端复用器)。Use whenever the user asks to take over, resume, review, read, or summarize another agent's conversation or task — e.g. "zcode接管opencode对话", "接管 AP Research", "take over the codex session", "opencode接管workbuddy任务", "hand off this task to another agent", "看看另一个 agent 做了什么" — and also when the user asks to prepare the current task for handoff to a different agent. Covers locating foreign session stores (opencode SQLite, ZCode/Codex/Claude/Gemini CLI transcripts, Cursor/Trae/VS Code-family state.vscdb and chatSessions), safely reading and redacting transcripts, reconstructing task state from artifacts when no usable transcript exists, verifying it on disk, and writing takeover handoffs.
openclaw skills install @lawson2019/agent-task-takeoverCross-agent continuity: read another agent's conversation, reconstruct its task state, and continue the work — or package your own task so a different agent can take it over. Session stores are local files, so any agent with filesystem access can read them. Works for CLI agents (opencode, ZCode, Codex, Claude Code, Gemini CLI) and Electron desktop agents (Cursor, Trae, VS Code Copilot, Kiro, Windsurf) alike, with no dependency on any terminal multiplexer. The bundled dumpers are Python 3.8+, stdlib only.
If the user only says "look at / understand" (看看、理解), the deliverable is the state report in step 5 — stop there and do not execute the task. If it is unclear whether they want review or continuation, ask once before editing anything. When the user rejects the identified takeover target, discard the reconstructed state and restart at step 0; record the correction in the report.
Discover what exists. When the source agent is unknown or you need the big picture, run python scripts/discover_stores.py [--days 14] — it lists every known agent store present on the machine (CLI and Electron), with last-modified times, and opens nothing.
Identify the source agent and its store. Consult references/agent-stores.md for the known stores and their exact schemas. For an unknown agent, use the discovery recipe below.
Locate the conversation. List recent sessions and match by title / keyword / working directory / time. Session titles are unreliable ("New session - "), so when no keyword was given, present the shortlist and let the user pick rather than guessing. Note the store/session modification time.
2a. Disambiguate the target before committing. Treat short names, numbers, and relative phrases as ambiguous. Import scripts/state_model.py and call its needs_confirmation(session_mtime, artifact_mtime, now, candidate_count); when it returns true, confirm the takeover object with the user instead of proceeding (python scripts/state_model.py --self-check verifies the import on your machine — it is a library, not a CLI). State the report's first line as "takeover target / newest artifact / whether they agree".
2b. Reconstruct from artifacts when no usable transcript exists. Call reconstruct_needed(session_ref, session_mtime, artifact_mtime). When it returns true — no session, no session activity, or a transcript clearly older than the newest task artifact — collect read-only evidence instead of guessing from a stale title, in this priority order: build/export logs, agent scratch scripts, validation or quality-gate reports, source files, deliverable timestamps and content fingerprints, backup snapshots. Produce a last-action timeline and identify the unfinished pipeline step: classify_pipeline(source_mtime, deliverable_mtime) returning stale means the export is missing (a failed validation gate also counts as stale). Collect evidence with python scripts/discover_stores.py --artifacts --artifact-root <root> --source-glob <glob> --deliverable-glob <glob> [--evidence-glob <glob>] [--gate-failed] (opt-in, configurable, read-only; a missing root is reported, never silently empty). See references/agent-stores.md for the full procedure.
Extract efficiently. Read user messages first — they are the storyline. Then read the final assistant message: agents that compact context (opencode does) often leave a structured handoff there with ## Objective, ## Work State, ## Next Move, ## Relevant Files headers — if present, it is worth more than the whole transcript. Do not replay tool calls one by one.
python scripts/dump_opencode_session.py --list [--keyword X]
then --id ses_... --final-assistant or --user-only --chars 800python scripts/dump_jsonl_session.py <file.jsonl> --final-assistant
or --user-only --chars 800session-*.json) → same dump_jsonl_session.py; single-JSON format is auto-detectedpython scripts/dump_vscdb_chat.py --app trae --list to find chat keys and sessions,
then --key <k> or --session <chatSessions/x.json> to dump--last N is applied after role filtering, so --role assistant --last 1 returns the last assistant message; --final-assistant also disables truncation.ReadSessionContext tool (strategy='handoff', sessionId='sess_...'); no file parsing needed.--show-sensitive unless the user explicitly asks to inspect raw data; even then, do not paste the values into your reply or a handoff file. Redaction is pattern-based, not a guarantee — treat all transcript text as potentially sensitive.Reconstruct the task state. Objective, decisions already made (and why), what is done, what is active, what is blocked, next moves, and the exact file paths. Populate scripts/state_model.py's TaskState so the report has a stable shape regardless of the source agent. Treat file names, version strings, and "completed" claims inside a compaction summary as high-distortion fields, and prefer the source's own summary only after step 5 has verified it.
Verify on disk before trusting the transcript. Handoffs go stale — the disk wins over the transcript whenever they disagree. Turn this into a checklist, not a spot check:
verify_claims(claims, exists, contains) over every path in ## Relevant Files; record missing files and marker mismatches as conflicts.classify_pipeline(...); report stale as a next move to re-export.TaskState.report() with fixed sections: Objective / Evidence (including whether a transcript existed) / Timeline / Work State / Mismatches / Deliverables (with a final-version pointer) / Next Move.file:...?mode=ro) and close them when done.liveness_signal(store_mtime, session_mtime, artifact_mtime, now) and prefer the newest task artifact over a shared store write, since several sessions commonly share one store. A recent store write is a hint, not proof that the target task is active. Check for live writer processes and file locks before editing shared files; on Windows, also check processes whose command line references the task path.HANDOFF.md, or send them anywhere. Prefer summaries over raw transcript excerpts.archive/ folder and keep the originals; do not detach live build inputs or references.Use this only when the user asks to hand the task off. Do not create handoff files for pull/review-only requests.
HANDOFF.md already exists, read it and merge/update the relevant sections. Never overwrite unrelated project notes. If no file exists, create it at the project root.data/tables/*.md, build outputs) instead of pasting numbers or logs into the handoff.A minimal handoff block:
## Objective
(one sentence: deliverable + success criteria)
## Decisions
(what was decided and why; what was rejected)
## Work State
Completed: … | Active: … | Blocked: … (with the exact error if any)
## Next Move
1. … 2. …
## Relevant Files
(path — what it is; path — how to regenerate)
scripts/discover_stores.py and the known roots in references/agent-stores.md; then inspect the agent-specific folder under ~, ~/.config, ~/.local/share, ~/AppData/Roaming, or ~/AppData/Local. Do not recursively scan the whole home directory unless the targeted lookup fails and the user accepts the broader search.*.db, *.sqlite, *.vscdb, *.jsonl, and dirs named sessions/, projects/, conversations/, rollout/, history/, chats/, chatSessions/, workspaceStorage/. When no transcript matches, also look for task artifacts (build/export logs, validation reports, source trees, deliverables, backups) in configured roots; never hard-code a product's directory name into the discovery logic.SELECT name FROM sqlite_master WHERE type='table'), find the one with role/message/content-ish columns, inspect one row's JSON. JSONL → sample the first lines, find role/text fields. Redact sample content before quoting it.scripts/dump_jsonl_session.py's extractor or write a ten-line read-only query; do not guess blindly and do not modify the foreign store.These are conveniences, never requirements — the file-based procedure above always works:
HERDR_ENV=1), you may read the other pane live or prompt it directly. If it is not present, skip this entirely.ReadSessionContext instead of file parsing.references/agent-stores.md — per-agent store locations, schemas, reading notes, and the artifact-reconstruction procedure.scripts/discover_stores.py — scan the machine for known agent stores (read-only, opens nothing); --artifacts adds opt-in, configurable artifact evidence.scripts/state_model.py — agent-neutral decision helpers (pipeline classification, disambiguation, claim verification, liveness) and the TaskState report shape; importable by scripts and tests (python scripts/state_model.py --self-check verifies it).scripts/dump_opencode_session.py — list/dump opencode sessions, read-only, with role filtering, final-assistant mode, and default redaction.scripts/dump_jsonl_session.py — streaming reader for codex / claude / zcode JSONL rollouts and Gemini CLI session JSON, with the same safety options.scripts/dump_vscdb_chat.py — reader for Electron VS Code-family chat state (state.vscdb ItemTable + chatSessions/*.json).scripts/session_utils.py — shared content-block extraction, truncation, conservative secret redaction, and UTF-8-safe console output.tests/test_session_tools.py — stdlib regression tests, including synthetic fixtures for artifact reconstruction. Run from this skill directory:
python -B -m unittest discover -s tests -v