hermes - ✅(Solved) Fix [Bug]: kanban specify helpers leak sqlite connections in long-lived processes [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#28802Fetched 2026-05-20 04:01:54
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×2referenced ×1

Error Message

Operating System

Ubuntu on WSL2 (Windows 11)

Python Version

Python 3.12.3

Hermes Version

Hermes Agent v0.14.0 (2026.5.16)

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fix / Workaround

After patching the helper to close connections explicitly, the same repro becomes:

PR fix notes

PR #28803: fix(kanban): close sqlite connections in specify helpers

Description (problem / solution / changelog)

Fixes #28802

hermes_cli.kanban_specify currently uses with kb.connect() as conn: in helper paths like list_triage_ids() and specify_task().

For sqlite3.Connection, that pattern does not close the connection on exit. It only manages transaction scope, so repeated helper calls leak file descriptors in long-lived processes.

This patch switches those helper paths to explicit closing and adds regression coverage for sqlite-like connections whose context manager does not call close().

Validation: uv run --extra dev pytest tests/hermes_cli/test_kanban_specify.py -q -k 'closes_connection or test_list_triage_ids'

Result: 3 passed in 8.46s

Live repro before fix: {'base': 5, 'after': 52, 'delta': 47}

Live repro after fix: {'base': 5, 'after': 5, 'delta': 0}

Changed files

  • hermes_cli/kanban_specify.py (modified, +4/-3)
  • scripts/release.py (modified, +1/-0)
  • tests/hermes_cli/test_kanban_specify.py (modified, +63/-0)

PR #11: fix(kanban): close sqlite connections in specify helpers to prevent fd leak (#28802)

Description (problem / solution / changelog)

🟢 Merge order: 2 / 12 — trivial, uses stdlib pattern, zero risk

Closes #28802 (P2)

Problem

with kb.connect() as conn: only manages transaction scope for sqlite3.Connection, not connection lifetime. Repeated calls leak file descriptors in long-lived gateway processes.

Fix

Use contextlib.closing(kb.connect()) in all 3 helper paths.

Risk assessment

FactorRating
Lines changed4/-3
New code1 import
Side effectsNone — closing() is stdlib, same semantics
Revert complexityTrivial

Files changed

  • hermes_cli/kanban_specify.py (+4/-3)

Changed files

  • hermes_cli/kanban_specify.py (modified, +4/-3)

Code Example

import os, tempfile
os.environ["HERMES_HOME"] = tempfile.mkdtemp(prefix="hermes_fdleak_spec_")

from hermes_cli import kanban_db as kb
from hermes_cli import kanban_specify as ks

conn = kb.connect()
conn.close()

base = len(os.listdir("/proc/self/fd"))
for _ in range(50):
    ks.list_triage_ids()
after = len(os.listdir("/proc/self/fd"))

print({"base": base, "after": after, "delta": after - base})


### Expected Behavior

Repeated calls to these kanban specify helpers should not leave sqlite connections open or grow the process fd count over time.


### Actual Behavior

The fd count grows with repeated calls.

In my repro on current main:

`{'base': 5, 'after': 52, 'delta': 47}`

After patching the helper to close connections explicitly, the same repro becomes:

`{'base': 5, 'after': 5, 'delta': 0}`


### Affected Component

CLI (interactive chat)

### Messaging Platform (if gateway-related)

_No response_

### Debug Report

---

### Operating System

Ubuntu on WSL2 (Windows 11)

### Python Version

Python 3.12.3

### Hermes Version

Hermes Agent v0.14.0 (2026.5.16)

### Additional Logs / Traceback (optional)
RAW_BUFFERClick to expand / collapse

Bug Description

I found a real sqlite connection leak in the kanban specify helpers.

hermes_cli.kanban_specify currently uses with kb.connect() as conn: in helper paths like list_triage_ids() and specify_task().

For sqlite3.Connection, that context-manager pattern does not close the connection. It only manages the transaction scope. As a result, repeated calls leak file descriptors.

This becomes user-visible in long-lived processes that invoke kanban commands repeatedly, including the gateway /kanban command path, which routes through run_slash in-process.

What I expected instead was for these helpers to always close their sqlite connections explicitly.

Steps to Reproduce

  1. Start from current main
  2. In a single Python process, set a temporary HERMES_HOME
  3. Call hermes_cli.kanban_specify.list_triage_ids() repeatedly
  4. Watch the open fd count grow

Minimal repro I used:

import os, tempfile
os.environ["HERMES_HOME"] = tempfile.mkdtemp(prefix="hermes_fdleak_spec_")

from hermes_cli import kanban_db as kb
from hermes_cli import kanban_specify as ks

conn = kb.connect()
conn.close()

base = len(os.listdir("/proc/self/fd"))
for _ in range(50):
    ks.list_triage_ids()
after = len(os.listdir("/proc/self/fd"))

print({"base": base, "after": after, "delta": after - base})


### Expected Behavior

Repeated calls to these kanban specify helpers should not leave sqlite connections open or grow the process fd count over time.


### Actual Behavior

The fd count grows with repeated calls.

In my repro on current main:

`{'base': 5, 'after': 52, 'delta': 47}`

After patching the helper to close connections explicitly, the same repro becomes:

`{'base': 5, 'after': 5, 'delta': 0}`


### Affected Component

CLI (interactive chat)

### Messaging Platform (if gateway-related)

_No response_

### Debug Report

```shell
Report     https://paste.rs/NPzLw
agent.log  https://paste.rs/lSpan

Operating System

Ubuntu on WSL2 (Windows 11)

Python Version

Python 3.12.3

Hermes Version

Hermes Agent v0.14.0 (2026.5.16)

Additional Logs / Traceback (optional)

This is a steady-state resource leak rather than an immediate traceback.

The practical failure mode is fd exhaustion in long-lived processes that keep invoking these helpers, which can eventually surface as sqlite open failures or broader `too many open files` symptoms.

Root Cause Analysis (optional)

hermes_cli.kanban_specify uses with kb.connect() as conn:.

kb.connect() returns a sqlite3.Connection. In sqlite, with conn: does not close the connection on exit; it only commits or rolls back the transaction.

So these helpers leak a connection each time they run unless the process exits immediately afterward.

Proposed Fix (optional)

Wrap these helper connections with contextlib.closing(kb.connect()) so the sqlite handle is always closed.

I also prepared regression coverage that uses a sqlite-like fake connection whose context manager does not call close(), to make sure the helpers explicitly close their connections.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING