Release v0.51.268 — Release IJ (stage-b1 — low-risk perf + provider/clarify fixes) (#3671)
Some checks failed
Release & Docker / release (push) Has been cancelled
Some checks failed
Release & Docker / release (push) Has been cancelled
* perf(providers): O(1) codex cache merge membership checks (#3656) Co-authored-by: Pamnard <pamnard@users.noreply.github.com> * fix(models): add MiniMax-M3 to WebUI MiniMax fallback catalog test (#3627) Co-authored-by: Rod Boev <rod.boev@gmail.com> * fix(config): make DeepSeek reasoning-effort heuristic position-independent (#3650) Co-authored-by: happy5318 <happy5318@users.noreply.github.com> * fix(clarify): don't stash clarify draft while submission is in flight (#3651) Co-authored-by: carryzuo00 <carryzuo00@gmail.com> * perf(sessions): batch lineage report child fetch by parent id (#3659) Co-authored-by: Pamnard <pamnard@users.noreply.github.com> * perf(sessions): batch orphan sidecar state.db existence probes (#3657) Co-authored-by: Pamnard <pamnard@users.noreply.github.com> * test(streaming): pin DOM-INFLIGHT reattach invariant (#3572) Co-authored-by: Rod Boev <rod.boev@gmail.com> * docs(changelog): v0.51.268 — Release IJ (stage-b1) --------- Co-authored-by: nesquena-hermes <[email protected]> Co-authored-by: Pamnard <pamnard@users.noreply.github.com> Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: happy5318 <happy5318@users.noreply.github.com> Co-authored-by: carryzuo00 <carryzuo00@gmail.com>
This commit is contained in:
@@ -2723,6 +2723,71 @@ def _active_state_db_path() -> Path:
|
||||
return hermes_home / 'state.db'
|
||||
|
||||
|
||||
def _agent_state_db_path(*, profile=None) -> Path | None:
|
||||
"""Return agent ``state.db`` for *profile*, or ``None`` when unavailable."""
|
||||
if isinstance(profile, str) and profile:
|
||||
db_path = _get_profile_home(profile) / 'state.db'
|
||||
if not db_path.exists():
|
||||
db_path = _active_state_db_path()
|
||||
else:
|
||||
db_path = _active_state_db_path()
|
||||
if not db_path.exists():
|
||||
return None
|
||||
return db_path
|
||||
|
||||
|
||||
def agent_session_rows_existing(
|
||||
session_ids: list[str] | set[str] | frozenset[str],
|
||||
*,
|
||||
profile=None,
|
||||
) -> frozenset[str]:
|
||||
"""Return session ids confirmed present in the agent ``sessions`` table.
|
||||
|
||||
Used by the sidebar orphan-prune path (#3238) to batch existence probes
|
||||
instead of opening one SQLite connection per candidate row.
|
||||
|
||||
Degrades safely to ``frozenset(wanted)`` (assume all present) on any error,
|
||||
when the DB is missing, or when the ``sessions`` table is absent — matching
|
||||
``agent_session_row_exists()`` so a transient failure never causes pruning.
|
||||
"""
|
||||
wanted = {str(sid).strip() for sid in (session_ids or []) if str(sid or "").strip()}
|
||||
if not wanted:
|
||||
return frozenset()
|
||||
try:
|
||||
import sqlite3
|
||||
except ImportError:
|
||||
return frozenset(wanted)
|
||||
db_path = _agent_state_db_path(profile=profile)
|
||||
if db_path is None:
|
||||
return frozenset(wanted)
|
||||
try:
|
||||
with closing(sqlite3.connect(str(db_path))) as conn:
|
||||
cur = conn.cursor()
|
||||
cur.execute("PRAGMA table_info(sessions)")
|
||||
cols = {str(row[1]) for row in cur.fetchall()}
|
||||
if 'id' not in cols:
|
||||
return frozenset(wanted)
|
||||
existing: set[str] = set()
|
||||
ids = list(wanted)
|
||||
chunk_size = 500
|
||||
for i in range(0, len(ids), chunk_size):
|
||||
chunk = ids[i:i + chunk_size]
|
||||
placeholders = ','.join('?' * len(chunk))
|
||||
cur.execute(
|
||||
f"SELECT id FROM sessions WHERE id IN ({placeholders})",
|
||||
chunk,
|
||||
)
|
||||
existing.update(str(row[0]).strip() for row in cur.fetchall())
|
||||
return frozenset(existing)
|
||||
except Exception:
|
||||
logger.debug(
|
||||
"agent_session_rows_existing probe failed for %d ids",
|
||||
len(wanted),
|
||||
exc_info=True,
|
||||
)
|
||||
return frozenset(wanted)
|
||||
|
||||
|
||||
def agent_session_row_exists(session_id: str, *, profile=None) -> bool:
|
||||
"""Return True if ``session_id`` still has a backing row in the agent state.db.
|
||||
|
||||
@@ -2739,31 +2804,7 @@ def agent_session_row_exists(session_id: str, *, profile=None) -> bool:
|
||||
sid = str(session_id or "").strip()
|
||||
if not sid:
|
||||
return False
|
||||
try:
|
||||
import sqlite3
|
||||
except ImportError:
|
||||
return True
|
||||
if isinstance(profile, str) and profile:
|
||||
db_path = _get_profile_home(profile) / 'state.db'
|
||||
if not db_path.exists():
|
||||
db_path = _active_state_db_path()
|
||||
else:
|
||||
db_path = _active_state_db_path()
|
||||
if not db_path.exists():
|
||||
# No agent DB at all on this instance — can't claim the row is gone.
|
||||
return True
|
||||
try:
|
||||
with closing(sqlite3.connect(str(db_path))) as conn:
|
||||
cur = conn.cursor()
|
||||
cur.execute("PRAGMA table_info(sessions)")
|
||||
cols = {str(row[1]) for row in cur.fetchall()}
|
||||
if 'id' not in cols:
|
||||
return True
|
||||
cur.execute("SELECT 1 FROM sessions WHERE id = ? LIMIT 1", (sid,))
|
||||
return cur.fetchone() is not None
|
||||
except Exception:
|
||||
logger.debug("agent_session_row_exists probe failed for %s", sid, exc_info=True)
|
||||
return True
|
||||
return sid in agent_session_rows_existing([sid], profile=profile)
|
||||
|
||||
|
||||
def _sidebar_title_is_generic_webui(title: str | None) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user