Pi: thread identity is derived from the session file path, so every new Pi session re-opens the identity gate
Pi: thread identity is derived from the session file path, so every new Pi session re-opens the identity gate
Host surface: pi (loopx/pi_goal_mode)
Checked on: main @ bb6e78ee62129e256bc53093cc1c164f1b780825; Pi 1.4.0; macOS
Related: #5675 (the adapter previously forwarded no thread id at all — that part is fixed on main, not yet in loopx==2.0.0)
Summary
piThreadId() derives the LoopX host thread id from the Pi session file path:
// loopx/pi_goal_mode/pi-goal-loop-runtime.mjs:108
export function piThreadId(sessionFile) {
return typeof sessionFile === "string" && sessionFile.trim() && !sessionFile.endsWith(path.sep)
? sessionKey(sessionFile) // <label>-<digest of the FULL path>
: null;
}
// loopx/pi_goal_mode/loopx-goal.ts:356
const threadId = piThreadId(ctx.sessionManager.getSessionFile());
Pi creates a new session file per launch, named <ISO timestamp>_<uuid>.jsonl:
~/.pi/agent/sessions/--Users-me-proj--/2026-10-22T10-43-51-124Z_01a16335-....jsonl
~/.pi/agent/sessions/--Users-me-proj--/2026-11-03T09-12-04-887Z_01a17c02-....jsonl
So the thread id changes on every fresh pi launch. A project that already has a
registered agent and a previously bound thread still reports binding: missing
on the next launch:
# one thread was already bound to the agent earlier
loopx bind-agent-thread --goal-id <goal> --thread-id <old-thread> \
--host-surface pi --agent-id <agent> --execute
# -> written: true, binding: bound
# next Pi launch derives a different thread id; the adapter's exact argv:
loopx --format json start-goal --guided --project . --goal-text '<goal>' \
--host-surface pi --thread-id <new-thread> \
--available-capability task_lease_v0
Observed on two simulated consecutive launches of the same project:
launch 1 -> 2026-10-22T01-00-00-000Z_session1_jsonl-e02714d4a6da1ad4
launch 2 -> 2026-10-22T02-00-00-000Z_session2_jsonl-9d7c675fb8dba7ac
launch 1: activation_allowed=False state=thread_binding_selection_required binding=missing
launch 2: activation_allowed=False state=thread_binding_selection_required binding=missing
Why this matters
The adapter cannot mint pi_session_authority while the gate is closed, and the
gate is closed on every new Pi session, not only on first onboarding. In
practice the user has to:
- start
pi, - run
/loopx <goal>, - get a packet that registers nothing and cannot activate,
- bind the identity (CLI
bind-agent-thread, with the thread id the extension computed internally and did not surface), - run
/loopx <goal>again.
Steps 3–5 repeat for every fresh Pi session in the same project. Using
pi --session <fixed path> avoids it because the path stops changing, but that
is not documented anywhere in pi_goal_mode/README.md, and it is not discoverable
from the failure.
There is also no override: grep process.env in loopx-goal.ts shows only
LOOPX_BIN. LOOPX_PI_STATE_DIR moves the binding store, not the thread
identity, so it cannot help.
Reproduction (no model calls)
PROJ=/tmp/pi-thread-repro; mkdir -p "$PROJ"; cd "$PROJ"; git init -q
loopx bootstrap --project . --goal-id repro-goal --objective repro \
--adapter-kind read_only_project_map_v0 --adapter-status connected-read-only
loopx --format json register-agent --goal-id repro-goal --agent-id repro-agent \
--require-new --execute
bind() {
loopx --format json bind-agent-thread --goal-id repro-goal \
--thread-id "$1" --host-surface pi --agent-id repro-agent --execute >/dev/null
}
gate() {
loopx --format json start-goal --guided --project . --goal-text x \
--host-surface pi --thread-id "$1" --available-capability task_lease_v0 \
| python3 -c 'import json,sys;d=json.load(sys.stdin);a=(d.get("command_pack") or {}).get("host_loop_activation") or {};g=a.get("identity_selection_gate") or {};print("allowed=%s state=%s binding=%s token=%s"%(a.get("activation_allowed"),g.get("state"),(g.get("thread_binding") or {}).get("status"),"pi_session_authority" in d))'
}
bind thread-A; gate thread-A # allowed=True (bound; the extension mints pi_session_authority from this packet)
gate thread-B # allowed=False, binding=missing <-- next launch
Expected: the second gate closes even though the project, goal and agent are unchanged.
Suggested options
Any one of these closes the gap; the first is least surprising.
- Documented stable identity. Accept an explicit override such as
LOOPX_PI_THREAD_ID, and documentpi --session <path>as the supported way to keep one host thread across launches. - Project-scoped identity, opt-in. For
host_surface=pi, when the project has exactly one registered agent, allow a single opt-in (LOOPX_PI_PERSIST_THREAD=1) that reuses that lane for new threads. This stays inside the "never infer takeover" policy because it is an explicit opt-in and only applies to a single-lane project. - Fail with instructions. If neither, the delivered packet should state that
the user must send
/loopx <goal>again in the same session, and print the exactbind-agent-threadcommand with the thread id the extension computed.
Non-goals
This is not a request to weaken the identity gate. Refusing to guess an agent from a sole registry candidate is a reasonable boundary; the problem is that the resulting state is indistinguishable from "LoopX is broken" and that it recurs on every launch.
Confirmed against current main (01f61ee): the full Pi session-file path still determines the thread ID. #5678 forwards that ID; it does not provide cross-session identity recovery. Current derivation.
The least disruptive workaround to try is to reopen the already-bound Pi session, then run /loopx <goal text> inside it. Pi 1.4.0 provides pi --resume to select a saved session, or --session <path|id> to select one explicitly. Pi's /session shows the current file and ID. Pi CLI, session inspection.
For a genuinely new session, your distinction is correct: explicitly register/select and bind the intended lane to the new thread, then run /loopx <goal text> again in that same Pi session. The extension attaches pi_session_authority during this handler; running CLI onboarding alone cannot supply its token. Handler.
/loopx resume is for an existing binding after a pause. Without a binding it falls back to inspection, so it is not first-time identity recovery. Dispatch.
This remains an onboarding gap. Showing the exact current-thread binding command and the required extension re-entry would help without silently taking over a sole candidate. The findings above are source-checked; I have not verified the workaround in a real Pi 1.4.0 TUI, and this is not a fix-complete claim.