Skip to content

feat(cron): support per-job max_iterations override - #2168

Closed
kpmfyi wants to merge 1 commit into
NousResearch:mainfrom
kpmfyi:feat/cron-per-job-max-iterations
Closed

feat(cron): support per-job max_iterations override#2168
kpmfyi wants to merge 1 commit into
NousResearch:mainfrom
kpmfyi:feat/cron-per-job-max-iterations

Conversation

@kpmfyi

@kpmfyi kpmfyi commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Allows individual cron jobs to specify max_iterations in their job definition (e.g., in jobs.json)
  • Overrides the global agent.max_turns / max_turns config on a per-job basis
  • Follows the existing per-job override pattern already used by model, provider, and base_url

Fallback chain: job.max_iterations > config.agent.max_turns > config.max_turns > 90

Use case

Research/accumulation jobs that use web search and file tools often need 20+ iterations, while simple notification jobs only need 3-5. Currently all jobs share the same global limit, forcing a compromise that either wastes resources on simple jobs or constrains complex ones.

Example

{
  "id": "daily-research",
  "name": "Daily Research Digest",
  "prompt": "Research and compile...",
  "max_iterations": 25,
  "schedule": "0 8 * * *"
}

Test plan

  • Job with max_iterations set uses that value
  • Job without max_iterations falls back to global config
  • Job without max_iterations and no global config falls back to 90

🤖 Generated with Claude Code

Allow individual cron jobs to specify `max_iterations` in their job
definition, overriding the global `agent.max_turns` config. This is
useful for jobs that need more (or fewer) iterations than the default,
such as research jobs that require extended tool use.

Follows the existing per-job override pattern used by `model`,
`provider`, and `base_url`.

Fallback chain: job.max_iterations > config.agent.max_turns > config.max_turns > 90

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@teknium1

teknium1 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Closing this one — the use case is real but too niche to justify expanding the cronjob tool schema further. The PR also only covers the scheduler read path; it would still need the tool schema parameter and create/update plumbing in cronjob_tools.py to be usable. The global max_iterations default works for most jobs, and jobs that need more room can be tuned via prompt design. Thanks for the contribution though!

@teknium1 teknium1 closed this Apr 3, 2026
inquistiff added a commit to inquistiff/hermes-agent-fork that referenced this pull request May 27, 2026
- Extract inline one-liner into validated block with logger.warning on
  invalid type (string, float, negative, zero) — matches spec from PR
  description; closes gap that got NousResearch#2168 closed
- Add tests/cron/test_scheduler_max_iterations.py: 13 tests covering
  fallback chain, type validation, boundary values, and scheduler import
- Fallback chain: job.max_iterations (positive int) > agent.max_turns >
  max_turns > 90 hard default

Production-validated: patch running in live cron fleet 6+ weeks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants