Skip to content

fix(prime): suppress spurious session_start on bare gt prime calls#3453

Open
mk-imagine wants to merge 1 commit intogastownhall:mainfrom
mk-imagine:fix/prime-spurious-session-start
Open

fix(prime): suppress spurious session_start on bare gt prime calls#3453
mk-imagine wants to merge 1 commit intogastownhall:mainfrom
mk-imagine:fix/prime-spurious-session-start

Conversation

@mk-imagine
Copy link
Copy Markdown

Problem

gt prime unconditionally emitted a session_start event via emitSessionEvent
inside setupPrimeSession, even when called without --hook. Any agent calling
gt prime <other-agent-dir> to read context would emit a spurious session_start
using the target agent's persisted session_id.

Observed symptom: Boot's formula calls cd ~/gt/deacon && gt prime to read
the Deacon's context. This caused every Boot triage cycle to emit two session_start
events — one for Boot itself (correct) and one for the Deacon (spurious), using the
Deacon's stored session_id from .runtime/session_id. Effects:

  • Polluted gt seance discovery with phantom sessions
  • Made the town event feed misleading (appeared as double spawning)
  • Made token cost attribution harder to audit

Fix

Guard emitSessionEvent behind primeHookMode in setupPrimeSession. Session
events are only emitted when gt prime is genuinely running as a SessionStart
or PreCompact hook (--hook flag set). Bare gt prime reads are unaffected
functionally.

Testing

With Gas Town running, observed ~/gt/.events.jsonl across multiple Boot triage
cycles. Before fix: two session_start events per cycle (one with Boot's session_id,
one with Deacon's). After fix: exactly one session_start per cycle.

Note

Pre-existing go vet failure in internal/cmd/compact_report_test.go:29
(wispTypeToCategory argument count mismatch) exists on main and is unrelated
to this change.

gt prime unconditionally called emitSessionEvent via setupPrimeSession,
even when invoked without --hook (e.g. an agent reading another agent's
context directory). This emitted a session_start event using the target
agent's persisted session_id, polluting the event stream with phantom
sessions and producing misleading double session_start entries in the
town feed every time Boot called "gt prime" from the Deacon's directory.

Guard emitSessionEvent behind primeHookMode so session_start is only
emitted when gt prime is genuinely running as a SessionStart or
PreCompact hook. Bare gt prime reads are unaffected functionally.
Copilot AI review requested due to automatic review settings April 1, 2026 03:44
@github-actions github-actions bot added the status/needs-triage Inbox — we haven't looked at it yet label Apr 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Suppresses unintended session_start emission when gt prime is invoked without --hook, preventing phantom sessions from being logged when one agent primes another agent’s directory for context reads.

Changes:

  • Guarded emitSessionEvent(ctx) behind primeHookMode in setupPrimeSession.
  • Added explanatory inline comment documenting why non-hook gt prime must not emit session_start.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage Inbox — we haven't looked at it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants