Tudou Lab 土豆实验室
Codex kit · two explicit commands

Know how long you were away. Pick up where you left off.

An agent cannot tell a minute from a night, and a new Session starts cold. Come back after a night away, say “good morning”, and it answers as if a minute had passed. Open a new Session, and the running joke, the mood, and the thing you meant to finish are gone until you retell them.

$time-sync · $handoff
MeasuredThe host measures elapsed time. The agent never guesses it.
Handed offMood, open matters, and shared phrases reach the next Session.
ExplicitNothing runs until you type a command.
SmallTwo hooks, two skills, standard-library Python, tests.

Two layers that cover each other

Inside one Session, the gap comes from the transcript. A brand-new Session has no previous message, so $time-sync carries the last handoff across instead, together with how long ago it was written.

TIME · MEASURED

$time-sync

Local time and the gap since your previous message, measured from transcript timestamps. “Good morning” after ten hours reads as a return, not a continuation. If measurement fails, the agent says so instead of estimating.

STATE · HANDED OFF

$handoff

Before you leave, the agent writes the mood, up to two open matters, up to three shared phrases, and the last topic. The next $time-sync in a new Session brings it back once.

What the agent sees

The first $time-sync in a new Session, with a handoff left the night before. Every example here is fictional.

TemporalSync error=no preceding user message. Do not infer elapsed time.
SessionHandoff source_session=0a0a0a0a-0000-4000-8000-000000000001; written_at=2030-01-02T22:41:07+01:00; age=9h 12m. Host-read packet from a previous Session's $handoff: recorded observations, not verified current state.
## Mood
Tired after the ridge survey, but in good spirits

## Unfinished
- Recalibrate the snow gauge before the next storm

## Phrases
- velvet teapot protocol — the crew's name for boiling water twice at altitude

## Last topic
Where to pitch camp two; ended with good night

The skill tells the agent to treat this as dated observations, pick things up where they fit, and not recite the packet. Later in the same Session, $time-sync costs two short lines.

Install in three steps

Copy two folders, trust two hooks, open a new Session.

1

Copy

Copy .codex/ and .agents/ from the kit into the root of your Git repository. If you already have .codex/hooks.json, merge the two UserPromptSubmit handlers into it.

2

Trust the hooks

Codex does not run a new or changed hook until you review it, and it fails silently. Open the Codex CLI in the repository and accept Hooks need review, or run /hooks. Repeat after any edit to hooks.json.

3

Open a new Session

Then use it: $handoff good night when you leave, $time-sync good morning when you come back.

The packet lives in .session-continuity/handoff.md. That folder writes its own .gitignore on first use, so mood notes cannot be committed by accident. Set SESSION_HANDOFF_PATH to move it. Run the tests from the kit folder:

python3 -m unittest discover -s tests

Every state is explicit

Silence means a hook did not run, so every other outcome says what happened.

LineMeaning
TemporalSync gap=…Measured gap since your previous message in this Session
TemporalSync error=no preceding user messageA new Session: use the handoff's age instead
SessionHandoff age=…The packet follows
SessionHandoff later_activity=…Other Codex conversations in this repository ran after the handoff was written
SessionHandoff long_gapOlder than 7 days: carry open matters, not the recorded tone
SessionHandoff omittedWritten in this Session, or already provided earlier in it
SessionHandoff unavailable / errorNothing usable, and the agent must not guess
HandoffTarget source_session=…The id the agent writes the packet under

How it is built

The decisions worth borrowing even if you never use Codex.

MEASURE

The host measures, the agent never infers

Elapsed time comes from transcript timestamps. A failed measurement is reported, not estimated.

SKIP

Ignore what the host injected

Finding your previous message skips instructions, environment context, and skill payloads the client adds itself. Otherwise the first turn always measures zero.

SPLIT

The model writes, the host identifies

Only the model can summarize; only the host knows the Session id. One write command validates the template before it overwrites, so a bad packet never replaces a good one.

ONE COPY

Warm context, not a second memory

One overwritten file, outside Git and any index. Mood is an observation, not an instruction; after a long gap, the old tone is dropped.

FILTER

The previous file is not the previous conversation

Codex's session folder mixes other repositories, subagents, and reviewer threads. Only your threads in this repository count, and the kit reports later activity rather than claiming there was none.

BUDGET

Once per Session, within a cap

At most 800 characters of packet and 160 per line, injected on the first $time-sync only. The worst case fits the hook limit even counted in UTF-8 bytes.

The failure tests cannot reach: every script passes when run by hand while Codex is not running it, because a changed hook is untrusted. That is why the install has a trust step, and why every other outcome states itself.

Limits

What this kit does not claim.

  • Codex-specific: it relies on the hook event's transcript_path, rollout filenames ending in the Session id, and the cwd and thread_source fields of session_meta. Built against Codex 0.154 (CLI and Desktop) on macOS; other versions and platforms are untested.
  • The repository must be a Git repository, because the hooks resolve paths with git rev-parse.
  • later_activity compares file modification times, so unrelated work in the same repository can trigger it. It says the handoff may not cover it, nothing stronger.
  • A handoff holds one Session's warm context. It is not durable memory, and it makes no claim about what is true now.
  • The mechanism carries over to other agent hosts; the transcript parsing and hook contract do not. It has not been ported.