Skip to content

fix(cron): honor per-job profile during scheduler runs#19958

Closed
Michaelyklam wants to merge 2 commits into
NousResearch:mainfrom
Michaelyklam:fix/cron-job-profile
Closed

fix(cron): honor per-job profile during scheduler runs#19958
Michaelyklam wants to merge 2 commits into
NousResearch:mainfrom
Michaelyklam:fix/cron-job-profile

Conversation

@Michaelyklam

Copy link
Copy Markdown

Summary

  • Adds scheduler-native resolution for optional cron job profile values, preserving missing/blank profile as legacy server-default behavior.
  • Runs profile-pinned scheduled jobs with that profile's HERMES_HOME, .env, config.yaml, SOUL/context identity, and profile env markers, while restoring process env afterward.
  • Warns and falls back to the server default if a stored profile is deleted or invalid.
  • Keeps tick output/run metadata in the owning scheduler cron store and serializes profile/workdir jobs to avoid process-global env races.

Related

Test Plan

  • RED observed before implementation: new scheduler profile tests failed because run_job loaded owner .env instead of the selected profile .env, and missing stored profiles did not warn.
  • python -m pytest tests/cron/test_scheduler_profiles.py -q -o 'addopts='
  • TMP_HOME=$(mktemp -d) && HERMES_HOME="$TMP_HOME" python -m pytest tests/cron/test_scheduler.py tests/cron/test_scheduler_profiles.py -q -o 'addopts='
  • Broader cron suite currently has one unrelated pre-existing failure: tests/cron/test_cron_script.py::TestBuildJobPromptWithScript::test_script_empty_output_noted expects a "no output" prompt but _build_job_prompt() returns None for empty script output.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management area/config Config system, migrations, profiles labels May 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #11470 (profile job model resolution) and #14703 (cron profile binding restore) — same subsystem, complementary fixes.

@Michaelyklam

Copy link
Copy Markdown
Author

Resolved the merge conflict against current origin/main in cron/scheduler.py and pushed the merge commit to the PR branch.

Follow-up commit: ce29663

Verification:

  • git diff --check
  • /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/cron/test_scheduler.py tests/cron/test_jobs.py -q ✅ (190 passed)

Current PR status: mergeable; no GitHub checks are configured on the PR at the moment.

daimon-nous Bot pushed a commit that referenced this pull request May 18, 2026
Avoids a brief window where other threads see an empty os.environ
during profile job teardown. Idea from PR #19958.
daimon-nous Bot pushed a commit that referenced this pull request May 18, 2026
Instead of raising FileNotFoundError (which silently bricks the job),
log a warning and fall back to the scheduler default home. Validates
at create/update time still catches typos. Idea from PR #19958.
@daimon-nous

daimon-nous Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Superseded by PR #28124 which merged #25917's more complete implementation (ContextVar isolation, CLI --profile, tool schema, subprocess bridging). Your delta-restore and graceful-fallback ideas from this PR were incorporated as follow-up commits — credited in the PR description.

#28124

Thank you @Michaelyklam!

@daimon-nous daimon-nous Bot closed this May 18, 2026
Lillard01 pushed a commit to Lillard01/hermes-agent that referenced this pull request May 21, 2026
Avoids a brief window where other threads see an empty os.environ
during profile job teardown. Idea from PR NousResearch#19958.
Lillard01 pushed a commit to Lillard01/hermes-agent that referenced this pull request May 21, 2026
Instead of raising FileNotFoundError (which silently bricks the job),
log a warning and fall back to the scheduler default home. Validates
at create/update time still catches typos. Idea from PR NousResearch#19958.
Mucky010 pushed a commit to Mucky010/hermes-agent that referenced this pull request May 24, 2026
Avoids a brief window where other threads see an empty os.environ
during profile job teardown. Idea from PR NousResearch#19958.
Mucky010 pushed a commit to Mucky010/hermes-agent that referenced this pull request May 24, 2026
Instead of raising FileNotFoundError (which silently bricks the job),
log a warning and fall back to the scheduler default home. Validates
at create/update time still catches typos. Idea from PR NousResearch#19958.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Avoids a brief window where other threads see an empty os.environ
during profile job teardown. Idea from PR NousResearch#19958.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Instead of raising FileNotFoundError (which silently bricks the job),
log a warning and fall back to the scheduler default home. Validates
at create/update time still catches typos. Idea from PR NousResearch#19958.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants