fix(prime): suppress spurious session_start on bare gt prime calls#3453
Open
mk-imagine wants to merge 1 commit intogastownhall:mainfrom
Open
fix(prime): suppress spurious session_start on bare gt prime calls#3453mk-imagine wants to merge 1 commit intogastownhall:mainfrom
mk-imagine wants to merge 1 commit intogastownhall:mainfrom
Conversation
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.
Contributor
There was a problem hiding this comment.
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)behindprimeHookModeinsetupPrimeSession. - Added explanatory inline comment documenting why non-hook
gt primemust not emitsession_start.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
gt primeunconditionally emitted asession_startevent viaemitSessionEventinside
setupPrimeSession, even when called without--hook. Any agent callinggt prime <other-agent-dir>to read context would emit a spurioussession_startusing the target agent's persisted
session_id.Observed symptom: Boot's formula calls
cd ~/gt/deacon && gt primeto readthe Deacon's context. This caused every Boot triage cycle to emit two
session_startevents — one for Boot itself (correct) and one for the Deacon (spurious), using the
Deacon's stored
session_idfrom.runtime/session_id. Effects:gt seancediscovery with phantom sessionsFix
Guard
emitSessionEventbehindprimeHookModeinsetupPrimeSession. Sessionevents are only emitted when
gt primeis genuinely running as aSessionStartor
PreCompacthook (--hookflag set). Baregt primereads are unaffectedfunctionally.
Testing
With Gas Town running, observed
~/gt/.events.jsonlacross multiple Boot triagecycles. Before fix: two
session_startevents per cycle (one with Boot's session_id,one with Deacon's). After fix: exactly one
session_startper cycle.Note
Pre-existing
go vetfailure ininternal/cmd/compact_report_test.go:29(
wispTypeToCategoryargument count mismatch) exists onmainand is unrelatedto this change.