Skip to content

[Bug] Cron scheduler does not pass fallback_model to AIAgent — cron jobs have no fallback chain #6673

@MT-Automates

Description

@MT-Automates

Bug Description

The cron scheduler (cron/scheduler.py) does not load or pass fallback_model from config.yaml to the AIAgent constructor. This means cron jobs have no fallback chain when the primary model endpoint is unreachable. The gateway (gateway/run.py) and CLI (cli.py) both correctly load and pass fallback_model, so this is an inconsistency specific to cron.

Steps to Reproduce

  1. Configure a cron job in config.yaml with a per-job model pointing to a local endpoint (e.g., a local LM Studio instance).
  2. Shut down or make the local endpoint unreachable (e.g., reboot the machine overnight).
  3. Wait for the cron job to trigger.
  4. Observe that the AIAgent stalls with message_count=0 and ended_at=None — no fallback model is attempted.

Expected Behavior

Cron jobs should respect the fallback_model / fallback_providers configuration in config.yaml, matching the behavior of gateway and CLI sessions. When the per-job primary model is unreachable, the agent should attempt the configured fallback before giving up.

Actual Behavior

When a cron job's per-job model endpoint is unreachable (e.g., a local LM Studio instance on a machine that rebooted overnight), the AIAgent stalls with message_count=0 and ended_at=None. No fallback model is attempted because self._fallback_chain is empty.

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

No response

Operating System

Linux (Ubuntu 24.04 / Windows 11 WSL2)

Python Version

Python 3.11.x

Hermes Version

latest as of April 9, 2026

Relevant Logs / Traceback

Root Cause Analysis (optional)

cron/scheduler.py line ~653 constructs AIAgent(...) without a fallback_model parameter. The _cfg dict from config.yaml is already loaded at line ~578 but fallback_model / fallback_providers is never read from it.

For comparison:

  • gateway/run.py lines 1010-1028: _load_fallback_model() reads cfg.get("fallback_providers") or cfg.get("fallback_model") and passes it at lines 4587, 4761, 6692.
  • cli.py lines 1492-1497: same pattern, reads from CLI_CONFIG and passes at lines 2462, 4837, 4972.

Proposed Fix (optional)

After the smart_routing load (~line 621), add:

# Fallback provider chain — mirrors gateway/run.py._load_fallback_model()
_fallback_model = _cfg.get("fallback_providers") or _cfg.get("fallback_model") or None

Then in the AIAgent constructor call (~line 653), add the fallback_model kwarg:

agent = AIAgent(
    ...
    fallback_model=_fallback_model,
    ...
)

No other changes needed. The _cfg dict is already in scope and the AIAgent class already accepts fallback_model as an optional kwarg.

Are you willing to submit a PR for this?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    sweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions