Turn
Parse the invocation.
$turnor@turn: no new task.$turn <prompt>or@turn <prompt>: preserve<prompt>as the new task.
Load and follow
${HOME}/.agents/skills/handoff/SKILL.mdwithout arguments. Do not pass the turn prompt tohandoff. Capture the absolute path of the generated handoff file and verify that it exists.Resolve the source thread ID with
codex_app__list_threads({}).- Match the active thread whose
cwdequals the current working directory and whose title, description, preview, or recent turns match this conversation. - If multiple candidates remain, use
codex_app__read_threadto identify the exact source. - Stop without creating a thread if the source cannot be identified unambiguously.
- Match the active thread whose
Resolve the source model and reasoning effort from its exact local session file.
- Under
${CODEX_HOME:-$HOME/.codex}/sessions, userg --filesto find the single filename ending in-<source_thread_id>.jsonl. Never search for files whose contents merely mention the ID. - Verify that the file contains
session_meta.payload.idexactly equal to the source thread ID. - Read the last
turn_contextrecord and capturepayload.modelandpayload.effort. - Stop if the file is missing or ambiguous, the ID check fails, or either value is missing or unsupported by
codex_app__create_thread.
- Under
Resolve the current Codex project with
codex_app__list_projects({}). Require an exact path match for the current working directory. Stop if no exact project exists.Build the new thread prompt with both identifiers:
handoff_file: <absolute handoff path> source_thread_id: <source thread id>Then append one behavior block:
- With a turn prompt: instruct the new thread to read the handoff file first, use it as context, and execute the supplied prompt as the new task.
- Without a turn prompt: instruct the new thread to read the handoff file only, not continue or execute unfinished work, confirm that context is loaded, and wait for the user to provide a new task.
Call
codex_app__create_threadwith the matchedprojectId,target.environment.type: local,modelset to the source model, andthinkingset to the source effort. Do not usecodex_app__fork_thread.After success, report the handoff path, source thread ID, source model and effort, and new thread ID. Emit
::created-thread{threadId="<new thread id>"}on its own line. Do not navigate to, archive, or send an extra message to either thread.
If handoff generation, file verification, source resolution, model or effort resolution, project resolution, or thread creation fails, report the real failure and do not claim completion.