Skip to content

Agent sessions should adopt enabled repos when a long session switches git common dirs #1439

Description

@peyton-alt

Summary

A long-running agent session can move from one git repository into another enabled repository and make commits that get no Entire-Checkpoint trailer, even though the CLI is installed and git hooks are present in the second repo.

This is distinct from same-repo sibling worktree matching. In this case the two repositories have different git common dirs, so the second repo's prepare-commit-msg hook cannot see the session state that was initialized in the first repo.

Observed repro from local investigation

While working on entirehq/entire.io, a Codex session was active in:

/Users/peytonmontei/Documents/entire/devenv/entire.io/.worktrees/merge-in-trails

The session state exists in the entire.io repo:

/Users/peytonmontei/Documents/entire/devenv/entire.io/.git/entire-sessions/019ed223-016e-7181-b420-dafc7d141cf4.json

Summary of that state:

agent_type: Codex
phase: active
worktree_path: /Users/peytonmontei/Documents/entire/devenv/entire.io/.worktrees/merge-in-trails
last_interaction_time: 2026-06-16T19:44:57-04:00

During the same conversation, the agent switched to the CLI repo worktree:

/private/tmp/entire-session-match-fix

and committed/pushed:

f9005540ed2b822363cf9aeefa87574a83517073 Match sessions across sibling worktrees

That commit has no trailer:

git show -s --format=%B f9005540ed2b822363cf9aeefa87574a83517073

Match sessions across sibling worktrees

The CLI repo did have hooks installed:

/Users/peytonmontei/Documents/entire/devenv/entire/.git/hooks/prepare-commit-msg

#!/bin/sh
# Entire CLI hooks
entire hooks git prepare-commit-msg "$1" "$2" 2>/dev/null || true

But its repo-local session store was empty:

/Users/peytonmontei/Documents/entire/devenv/entire/.git/entire-sessions
# no *.json session states

The git common dirs are different:

entire.io repo: /Users/peytonmontei/Documents/entire/devenv/entire.io/.git
cli repo:       /Users/peytonmontei/Documents/entire/devenv/entire/.git

So the hook in the CLI repo fired, looked in the CLI repo's .git/entire-sessions, found no active session, and skipped trailer insertion.

Expected behavior

If an agent session with Entire enabled moves into a second enabled git repository and commits there, Entire should not silently lose provenance.

Possible acceptable behaviors:

  1. Adopt/create a repo-local session state in the second repo, keyed to the same agent session/transcript, so commits in that repo get trailers/checkpoints.
  2. Detect that an agent session is active elsewhere but missing in the current repo and emit a clear warning before/when the commit hook skips.
  3. Provide an explicit multi-repo/orchestrator session model that can attach one agent transcript to multiple repo-local checkpoint streams.

Actual behavior

The commit hook silently skips because the current repo has hooks installed but no repo-local session state. The resulting commit has no Entire-Checkpoint trailer.

Why this matters

Users reasonably expect "Entire is installed and the agent session is active" to mean commits made by that agent are checkpointed. Long agent sessions often inspect or patch multiple repositories. Today, a repo switch can produce uncheckpointed commits without any visible warning.

This is especially confusing because same-repo worktree fixes do not help here: the failure crosses git common dirs, so session lookup by shared common dir is intentionally not enough.

Related

Fix direction

Investigate agent lifecycle hooks for repo transitions. In particular:

  • Codex/Claude hooks should be able to initialize or adopt session state when the active agent begins operating inside a different enabled repo.
  • prepare-commit-msg should distinguish "Entire disabled" from "hooks installed but no active session in this repo during an agent-driven commit" and surface an actionable diagnostic.
  • Any cross-repo adoption must avoid accidentally attaching one repo's checkpoint metadata to another repo's commits; the checkpoint streams should remain repo-local even if they share an agent transcript/session identity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions