You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sessions.message_count column not maintained for api_server and tui sources #45236
The message_count column in the sessions table remains NULL for sessions created through the API Server (source=api_server) and TUI (source=tui) paths, even though the messages table contains valid messages for these sessions.
This causes the Desktop sidebar (which queries with min_messages=1) to incorrectly filter out almost all sessions. For example:
150 TUI sessions: only 3 had message_count >= 1
35 api_server sessions: 0 had message_count >= 1
Impact
Desktop sidebar shows very few sessions despite having hundreds of conversations in the database
Any client that uses min_messages >= 1 loses visibility of most sessions
Users cannot see their conversation history without manual UPDATE queries
Workaround
Running the following SQL backfills the missing counts:
UPDATE sessions SET message_count = (
SELECTCOUNT(*) FROM messages WHEREmessages.session_id=sessions.id
) WHERE message_count IS NULLOR message_count =0;
Root Cause Investigation Needed
The message_count column should be maintained by the session creation/update code path. The fact that it's consistently NULL for api_server and tui sources (but correctly populated for messaging platform sources like weixin, feishu) suggests the increment logic is missing in the agent loop or gateway response path for these sources.
Two PRs address #45236: #45345 fixes NULL-propagating counter increments and attempts to backfill existing NULL rows, while #45475 only initializes counters for newly inserted sessions and does not repair affected historical rows.
Related pull requests
fix(state): heal null session message counts #45345best fix — (+62/-4) — best partial fix, revise before merge: the COALESCE increments directly fix the live NULL-arithmetic failure and the backfill targets existing affected sessions, but the visible keep_open review correctly notes that its v17 migration is unreachable for databases already migrated beyond v17; move the repair into a fresh post-current-schema migration and test reopening from the current pre-change version.
#45475 substantially overlaps the new-session portion of #45345's counter-recovery work, but #45345 additionally addresses NULL-safe increments and historical repair; treat #45475 as superseded once its applicable initialization is folded into #45345.
Suggested consolidation
Merge #45345 after rebasing it onto current main, relocating the historical backfill to a fresh post-current-schema migration, and adding current-version reopen coverage; optionally fold explicit zero initialization into the current upsert. Then close #45475 as superseded because its stale two-line insert change alone cannot recover the sessions reported in #45236.
Complex graph
flowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
I45236(["issue #45236 (open)"])
P45345["PR #45345 (open)"]
P45475["PR #45475 (open)"]
P45345 -->|best fix| I45236
P45475 -.->|partial| I45236
class I45236 open
class I45236 target
class P45345 open
class P45475 open
class P45345 best
click I45236 "https://github.com/NousResearch/hermes-agent/issues/45236"
click P45345 "https://github.com/NousResearch/hermes-agent/pull/45345"
click P45475 "https://github.com/NousResearch/hermes-agent/pull/45475"
Loading
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).
Cross-PR triage: Reviewed 2 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 6 kB of PR diffs, 3 kB of issue/PR text, 5 kB of discussion (6 comments), 3 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
Activity
fix(hermes_state): set message_count and tool_call_count to 0 on sess…
GottZ commentedon Jul 26, 2026
Summary
Two PRs address #45236: #45345 fixes NULL-propagating counter increments and attempts to backfill existing NULL rows, while #45475 only initializes counters for newly inserted sessions and does not repair affected historical rows.
Related pull requests
best fix— (+62/-4) — best partial fix, revise before merge: the COALESCE increments directly fix the live NULL-arithmetic failure and the backfill targets existing affected sessions, but the visible keep_open review correctly notes that its v17 migration is unreachable for databases already migrated beyond v17; move the repair into a fresh post-current-schema migration and test reopening from the current pre-change version.partial— (+2/-2) — narrower partial fix, supersede with fix(state): heal null session message counts #45345: explicit zero initialization prevents NULL counters on future inserts but neither repairs existing rows nor makes later increments NULL-safe. Despite the keep_open review on fix(hermes_state): set message_count and tool_call_count to 0 on session creation #45475, its diff targets the obsolete INSERT OR IGNORE form on current main and covers only initialization; preserve the current upsert and fold any still-needed explicit initialization into fix(state): heal null session message counts #45345 instead of maintaining a separate fix.Duplicates
#45475 substantially overlaps the new-session portion of #45345's counter-recovery work, but #45345 additionally addresses NULL-safe increments and historical repair; treat #45475 as superseded once its applicable initialization is folded into #45345.
Suggested consolidation
Merge #45345 after rebasing it onto current main, relocating the historical backfill to a fresh post-current-schema migration, and adding current-version reopen coverage; optionally fold explicit zero initialization into the current upsert. Then close #45475 as superseded because its stale two-line insert change alone cannot recover the sessions reported in #45236.
Complex graph
flowchart LR classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937 classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151 classDef best stroke-width:3px,stroke:#b45309 classDef target stroke-width:3px,stroke:#4338ca I45236(["issue #45236 (open)"]) P45345["PR #45345 (open)"] P45475["PR #45475 (open)"] P45345 -->|best fix| I45236 P45475 -.->|partial| I45236 class I45236 open class I45236 target class P45345 open class P45475 open class P45345 best click I45236 "https://github.com/NousResearch/hermes-agent/issues/45236" click P45345 "https://github.com/NousResearch/hermes-agent/pull/45345" click P45475 "https://github.com/NousResearch/hermes-agent/pull/45475"Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).
Cross-PR triage: Reviewed 2 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 6 kB of PR diffs, 3 kB of issue/PR text, 5 kB of discussion (6 comments), 3 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.