Skip to content

Cron job fails to expand ${ENV_VAR} from .env file #15890

@szz1982

Description

@szz1982

GitHub Issue: Cron job fails to expand ${ENV_VAR} from .env file

Bug Description

When running a cron job without specifying a model, environment variables (e.g., ${HERMES_MODEL}, ${OPENROUTER_FALLBACK_MODEL}) from .env are not expanded. The literal string ${VAR} is passed to the API, causing a 400 error.

Steps to Reproduce

  1. Set variables in ~/.hermes/.env:

    HERMES_MODEL=some-model
    OPENROUTER_FALLBACK_MODEL=some-fallback-model
    
  2. Create a cron job WITHOUT specifying model:

    hermes cron create --name "test" --schedule "0 3 * * *" --prompt "test"
  3. Run: hermes cron run <job_id>

  4. Check logs: ~/.hermes/logs/agent.log

Expected Behavior

${HERMES_MODEL} should expand to some-model, and ${OPENROUTER_FALLBACK_MODEL} to some-fallback-model.

Actual Behavior

Logs show:

Fallback activated: ${HERMES_MODEL} → ${OPENROUTER_FALLBACK_MODEL}
...
Error: '${OPENROUTER_FALLBACK_MODEL}' is not a valid model ID

Root Cause (Speculation)

The .env file uses ${VAR} syntax, but the cron execution path may not apply expansion. The cli.py has "Expand ${ENV_VAR}" logic, but it may not be applied in cron context.

Workaround

Specify model explicitly (but loses flexibility):

hermes cron create ... --model "some-model" --provider "openrouter"

Environment

  • Hermes Version: v0.11.0
  • OS: Linux
  • Python Version: 3.x

Additional Context

Labels

bug, cron, environment-variables

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/cronCron scheduler and job managementtype/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