Skip to content

Commit acf80e0

Browse files
wesmclaude
andauthored
fix: recognize "helpful assistant" prefix as automated session (#330)
## Summary - Add "You are a helpful assistant working on a software project." to `automatedPrefixes` so analysis tasks using this prompt pattern are classified as automated - Bump backfill marker from v1 to v2 so existing sessions in both SQLite and PostgreSQL get re-scanned on next startup Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f7bf7e8 commit acf80e0

6 files changed

Lines changed: 19 additions & 11 deletions

File tree

internal/db/automated.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var automatedPrefixes = []string{
1919
"You are analyzing AI agent sessions.",
2020
"## Analysis Request",
2121
"# Fix Request",
22+
"You are a helpful assistant working on a software project.",
2223
}
2324

2425
// automatedSubstrings are patterns matched anywhere in the

internal/db/automated_backfill_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestBackfillIsAutomatedBidirectional(t *testing.T) {
3737

3838
// Clear the marker so the backfill will run.
3939
_, err = d.getWriter().Exec(
40-
"DELETE FROM stats WHERE key = 'is_automated_backfill_v1'",
40+
"DELETE FROM stats WHERE key = 'is_automated_backfill_v2'",
4141
)
4242
requireNoError(t, err, "clear marker")
4343

@@ -77,7 +77,7 @@ func TestBackfillIsAutomatedMarkerIdempotent(t *testing.T) {
7777

7878
// Clear the marker and run backfill.
7979
_, err := d.getWriter().Exec(
80-
"DELETE FROM stats WHERE key = 'is_automated_backfill_v1'",
80+
"DELETE FROM stats WHERE key = 'is_automated_backfill_v2'",
8181
)
8282
requireNoError(t, err, "clear marker")
8383

internal/db/automated_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ func TestIsAutomatedSession(t *testing.T) {
104104
true,
105105
},
106106

107+
// Helpful assistant analysis
108+
{
109+
"HelpfulAssistantAnalysis",
110+
"You are a helpful assistant working on a software project. Analyze the following sessions.",
111+
true,
112+
},
113+
107114
// Catch-all substring
108115
{
109116
"RoborevSubstringInMiddle",

internal/db/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ func (db *DB) migrateColumns() error {
412412
// Guarded by a stats marker so it only runs once per pattern
413413
// version.
414414
func (db *DB) backfillIsAutomatedLocked(w *sql.DB) error {
415-
const marker = "is_automated_backfill_v1"
415+
const marker = "is_automated_backfill_v2"
416416
var done int
417417
if err := w.QueryRow(
418418
`SELECT count(*) FROM stats

internal/postgres/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func EnsureSchema(
294294
return nil
295295
}
296296

297-
const isAutomatedBackfillMetadataKey = "is_automated_backfill_v1"
297+
const isAutomatedBackfillMetadataKey = "is_automated_backfill_v2"
298298

299299
// backfillIsAutomatedPG recomputes is_automated for all PG
300300
// sessions, correcting both false negatives (new patterns) and

internal/sync/engine_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (f fakeFileInfo) Mode() os.FileMode { return 0 }
3636
func (f fakeFileInfo) ModTime() time.Time {
3737
return time.Unix(0, f.mtime)
3838
}
39-
func (f fakeFileInfo) IsDir() bool { return false }
40-
func (f fakeFileInfo) Sys() any { return nil }
39+
func (f fakeFileInfo) IsDir() bool { return false }
40+
func (f fakeFileInfo) Sys() any { return nil }
4141

4242
func TestFilterEmptyMessages(t *testing.T) {
4343
tests := []struct {
@@ -716,12 +716,12 @@ func TestApplyRemoteRewrites(t *testing.T) {
716716
},
717717
},
718718
},
719-
wantSessID: "host~abc",
720-
wantParent: strPtr("host~parent-1"),
719+
wantSessID: "host~abc",
720+
wantParent: strPtr("host~parent-1"),
721721
wantFilePath: strPtr("/tmp/file"),
722-
wantMsgSess: "host~abc",
723-
wantSubs: []string{"host~sub-1", ""},
724-
wantEvSubs: []string{"host~ev-1", ""},
722+
wantMsgSess: "host~abc",
723+
wantSubs: []string{"host~sub-1", ""},
724+
wantEvSubs: []string{"host~ev-1", ""},
725725
},
726726
{
727727
name: "path rewriter applied",

0 commit comments

Comments
 (0)