fix(cron): read per-job max_tokens from job config and pass to AIAgent - #58440
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(cron): read per-job max_tokens from job config and pass to AIAgent#58440liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
run_job() never read job.get('max_tokens'), so any per-job max_tokens
setting in jobs.json was silently ignored. AIAgent always defaulted to
max_tokens=None regardless of the job config.
Extract the value, validate it as int, and pass it through to the
AIAgent constructor.
Contributor
|
Thanks — the diagnosis was correct (the scheduler never read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Wires up the per-job
max_tokensconfig key so cron jobs can override the output token limit. Previously,run_job()readjob.get("model"), reasoning config, prefill messages, toolsets, etc. from the job config — but never readmax_tokens, so any"max_tokens": 4096(or any value) in a job'sjobs.jsonentry was silently ignored andAIAgentalways defaulted tomax_tokens=None.Related Issue
Fixes #58423
Type of Change
Changes Made
cron/scheduler.py: Extractjob.get("max_tokens")with int validation and warning on invalid values, then pass it asmax_tokens=job_max_tokensto theAIAgent(...)constructor call inrun_job().How to Test
grep -n 'max_tokens' cron/scheduler.py— should now show the extraction (L2729) and the AIAgent kwarg (L2891).python -c "from cron.scheduler import run_job; print('import ok')"— should pass without errors.pytest tests/cron/ -q— should pass (pre-existing unrelated failures intest_all_token_case_insensitiveare upstream issues)."max_tokens": 4096in itsjobs.jsonentry, trigger it, and observe the agent respects the per-job limit instead of silently ignoring it.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (pre-existing failures in unrelated tests:test_all_token_case_insensitive,test_explicit_origin_no_origin_emits_notice,test_cron_duplicate_target_is_skipped_and_explained)grepandpython -cimport checks aboveDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture — or N/A