Skip to content

fix(cron): wire max_tokens from per-job config into AIAgent constructor - #58582

Closed
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:alex/fix-cron-max-tokens
Closed

fix(cron): wire max_tokens from per-job config into AIAgent constructor#58582
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:alex/fix-cron-max-tokens

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Summary

run_job() in cron/scheduler.py reads several job-config keys (model, reasoning_config, toolsets, etc.) into the AIAgent(...) constructor but never reads max_tokens. A cron job that sets max_tokens: 4096 gets it silently ignored.

Impact

Any cron job whose expected output exceeds the model's default max-output behavior fails with RuntimeError: Response remained truncated after 3 continuation attempts — and setting max_tokens in that job's config to fix it does nothing, silently.

Fix

Added max_tokens=job.get(max_tokens) to the AIAgent() constructor call in run_job().

Root Cause

AIAgent.__init__ accepts max_tokens: int = None and the plumbing exists everywhere downstream (agent_init.pybuild_api_kwargs()). The only missing link was the constructor call in cron/scheduler.py.

Fixes #58423

run_job() reads several job-config keys (model, reasoning, toolsets, etc.)
into the AIAgent constructor but never reads max_tokens. A cron job that
sets max_tokens: 4096 gets it silently ignored, causing
RuntimeError: Response remained truncated after 3 continuation attempts
for long-running outputs.

Fixes NousResearch#58423
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management duplicate This issue or pull request already exists labels Jul 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #58440 — both fix #58423 by wiring max_tokens from the per-job config into the AIAgent(...) constructor in run_job() (cron/scheduler.py). #58440 was opened earlier and is slightly more robust (adds int-validation + a warning on a bad value), so it is the canonical fix.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the missing constructor forwarding; the diagnosis and one-line implementation are clear.

This is an automated hermes-sweeper review. This change is being closed under the standing max-tokens-knob policy: Hermes does not add user-facing max_tokens configuration surfaces, including per-cron-job overrides.

For truncation cases, please use or improve the documented global model.max_tokens configuration and investigate provider context/output-cap settings rather than adding a per-job override.


Closed as not-planned per standing maintainer policy (max-tokens-knob). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

@teknium1 teknium1 closed this Jul 15, 2026
@teknium1 teknium1 added the sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] cron scheduler.py run_job() never reads per-job max_tokens — AIAgent() always gets None

3 participants