From 0abbbd1b4a9474adb7f707d62aa3fc8c82948590 Mon Sep 17 00:00:00 2001 From: Aditya Vikram Singh <247195684+avs-io@users.noreply.github.com> Date: Wed, 19 Aug 2026 18:28:07 +0530 Subject: [PATCH] fix(hermes): only attribute PRs mentioned by the user or assistant Tool dumps (gh pr list, changelog grep) were smearing one session across dozens of pull URLs. Capture links from user and assistant text only. --- src/providers/hermes.ts | 5 +++-- tests/providers/hermes.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/providers/hermes.ts b/src/providers/hermes.ts index cffa7d22..9b122ad0 100644 --- a/src/providers/hermes.ts +++ b/src/providers/hermes.ts @@ -413,8 +413,9 @@ function createParser(source: SessionSource, seenKeys: Set, hermesHome: seenKeys.add(dedupKey) const prLinks = extractGithubPullUrls( - ...messages.map(msg => msg.content), - ...messages.map(msg => msg.tool_calls), + ...messages + .filter(msg => msg.role === 'assistant' || msg.role === 'user') + .map(msg => msg.content), ) // Hermes bills reasoning tokens at the output rate (same as Gemini). diff --git a/tests/providers/hermes.test.ts b/tests/providers/hermes.test.ts index bf62656c..e2c19111 100644 --- a/tests/providers/hermes.test.ts +++ b/tests/providers/hermes.test.ts @@ -520,6 +520,28 @@ skipUnlessSqlite('hermes provider', () => { expect(calls[0]?.project).toBe('hermes') }) + it('ignores GitHub pull URLs that only appear in tool dumps', async () => { + const dbPath = createHermesDb(tmpDir) + withTestDb(dbPath, (db) => { + insertSession(db, { + id: 'tool-pr-noise', + inputTokens: 10, + outputTokens: 5, + cacheReadTokens: 0, + cacheWriteTokens: 0, + reasoningTokens: 0, + startedAt: 1779549200, + }) + db.prepare('INSERT INTO messages (session_id, role, content, timestamp) VALUES (?, ?, ?, ?)') + .run('tool-pr-noise', 'tool', 'https://github.com/getagentseal/codeburn/pull/677 https://github.com/getagentseal/codeburn/pull/691', 1779549201) + db.prepare('INSERT INTO messages (session_id, role, content, timestamp) VALUES (?, ?, ?, ?)') + .run('tool-pr-noise', 'assistant', 'Closed the stale draft. Next is Keychain.', 1779549202) + }) + + const calls = await collectCalls(tmpDir, `${dbPath}#hermes-session=tool-pr-noise`) + expect(calls[0]?.prLinks).toBeUndefined() + }) + it('infers projects from Windows current working directory messages', async () => { const dbPath = createHermesDb(tmpDir) withTestDb(dbPath, (db) => {