feat(scheduler): add env_vars parameter for per-job environment overrides - #13
Merged
Conversation
…ides
Scheduled jobs can now inject arbitrary environment variables into the
spawned DevDuck instance (e.g. TELEGRAM_BOT_TOKEN, API keys, feature flags).
env_vars are persisted to jobs.json so they survive restarts, and applied
via the existing _EnvOverride context manager so global state stays clean
after the job completes.
Example:
scheduler(
action='add',
name='telegram-morning',
schedule='0 9 * * *',
prompt='send daily summary',
tools='telegram',
env_vars={'TELEGRAM_BOT_TOKEN': '...', 'TELEGRAM_CHAT_ID': '...'},
)
✅ Autonomous Review - LGTMAnalyzed the changes and they look excellent: Strengths
Implementation Quality
Use Case ImpactSolves real problem: Multi-service schedulers can now inject credentials per-job without global env conflicts. Perfect for Telegram bots, API integrations, feature flags. RecommendationMerge-ready ✅ The PR is mergeable, implementation is clean, and backwards compatibility is maintained. No blocking issues found. Reviewed autonomously by DevDuck GitHub Agent |
|
✅ Merged successfully! The scheduler now supports per-job environment variables via the new Key capabilities unlocked:
Example usage: scheduler(
action="add",
name="telegram-morning",
schedule="0 9 * * *",
prompt="send daily summary",
tools="telegram",
env_vars={
"TELEGRAM_BOT_TOKEN": "...",
"TELEGRAM_CHAT_ID": "..."
}
)Changes: 1 file modified (+13/-1) |
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.
Summary
Scheduled jobs can now inject arbitrary environment variables into the spawned DevDuck instance (e.g.
TELEGRAM_BOT_TOKEN, API keys, feature flags).Previously only
model,tools,system_prompt, andmax_tokenscould be overridden per-job — anything else had to live in the global process env, which breaks when one scheduler runs jobs for different services.Changes
env_vars: Optional[Dict[str, str]]parameter onscheduler(action='add', ...)jobs.json→ survives restarts_EnvOverridecontext manager → global env stays clean after the job completesExample
Each fired job will have those vars set for the duration of the spawned DevDuck session, then cleaned up.
Backwards compatibility
✅ Fully backwards compatible —
env_varsdefaults toNone, existing jobs keep working. Oldjobs.jsonentries without the field are handled viajob.get("env_vars") or {}.