fix(cron): tag persisted cron sessions and test wiring

- store cron-run sessions with source=cron instead of falling back to cli
- close the per-run SessionDB after completion
- add regression coverage for cron session_db/platform wiring
This commit is contained in:
teknium1
2026-03-14 00:12:34 -07:00
parent 9283877204
commit f5cf1f8a45
2 changed files with 47 additions and 0 deletions

View File

@@ -269,6 +269,7 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
providers_order=pr.get("order"),
provider_sort=pr.get("sort"),
quiet_mode=True,
platform="cron",
session_id=f"cron_{job_id}_{_hermes_now().strftime('%Y%m%d_%H%M%S')}",
session_db=_session_db,
)
@@ -325,6 +326,11 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
# Clean up injected env vars so they don't leak to other jobs
for key in ("HERMES_SESSION_PLATFORM", "HERMES_SESSION_CHAT_ID", "HERMES_SESSION_CHAT_NAME"):
os.environ.pop(key, None)
if _session_db:
try:
_session_db.close()
except Exception as e:
logger.debug("Job '%s': failed to close SQLite session store: %s", job_id, e)
def tick(verbose: bool = True) -> int: